source: trunk/kBuild/tools/GXX3PLAIN.kmk@ 1259

Last change on this file since 1259 was 1259, checked in by bird, 17 years ago

Don't basename the library file, just strip leading 'lib'.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 12.5 KB
Line 
1# $Id: GXX3PLAIN.kmk 1259 2007-11-07 16:02:56Z bird $
2## @file
3#
4# kBuild Tool Config - Generic GCC v3.2.x or later using the system GCC, any Unix linker and Unix archiver to build C++ code.
5#
6# Copyright (c) 2004-2007 knut st. osmundsen <bird-kBuild-spam@anduin.net>
7#
8#
9# This file is part of kBuild.
10#
11# kBuild is free software; you can redistribute it and/or modify
12# it under the terms of the GNU General Public License as published by
13# the Free Software Foundation; either version 2 of the License, or
14# (at your option) any later version.
15#
16# kBuild is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19# GNU General Public License for more details.
20#
21# You should have received a copy of the GNU General Public License
22# along with kBuild; if not, write to the Free Software
23# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24#
25#
26
27TOOL_GXX3PLAIN := Generic GCC v3.2.x or later using the system GCC, any Unix linker and Unix archiver to build C++ code.
28
29# Tool Specific Properties
30TOOL_GXX3PLAIN_CC ?= gcc$(HOSTSUFF_EXE)
31TOOL_GXX3PLAIN_CXX ?= g++$(HOSTSUFF_EXE)
32TOOL_GXX3PLAIN_AS ?= gcc$(HOSTSUFF_EXE)
33TOOL_GXX3PLAIN_AR ?= ar$(HOSTSUFF_EXE)
34TOOL_GXX3PLAIN_RANLIB ?= ranlib$(HOSTSUFF_EXE)
35TOOL_GXX3PLAIN_LD ?= g++$(HOSTSUFF_EXE)
36TOOL_GXX3PLAIN_LD_SYSMOD ?= ld$(HOSTSUFF_EXE)
37TOOL_GXX3PLAIN_LD_SYSMOD.os2 ?= g++$(HOSTSUFF_EXE)
38TOOL_GXX3PLAIN_LDFLAGS.dll.os2 ?= -Zdll
39TOOL_GXX3PLAIN_LDFLAGS.dll.darwin ?= -dynamiclib
40ifndef TOOL_GXX3PLAIN_LDFLAGS.$(BUILD_TARGET)
41 TOOL_GXX3PLAIN_LDFLAGS.dll ?= -shared
42else
43 TOOL_GXX3PLAIN_LDFLAGS.dll ?= $(TOOL_GXX3PLAIN_LDFLAGS.$(BUILD_TARGET))
44endif
45TOOL_GXX3PLAIN_LD_SONAME.darwin ?= $(NO_SUCH_VARIABLE)
46TOOL_GXX3PLAIN_LD_SONAME.os2 ?= $(NO_SUCH_VARIABLE)
47TOOL_GXX3PLAIN_LD_SONAME.solaris ?= -Wl,-h,$(firstword $($(1)_SONAME.$(BUILD_TARGET).$(BUILD_TYPE)) $($(1)_SONAME.$(BUILD_TARGET)) $($(1)_SONAME.$(BUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
48TOOL_GXX3PLAIN_LD_SONAME.win ?= $(NO_SUCH_VARIABLE)
49ifndef TOOL_GXX3PLAIN_LD_SONAME.$(BUILD_TARGET)
50 TOOL_GXX3PLAIN_LD_SONAME ?= -Wl,-soname=$(firstword $($(1)_SONAME.$(BUILD_TARGET).$(BUILD_TYPE)) $($(1)_SONAME.$(BUILD_TARGET)) $($(1)_SONAME.$(BUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
51else
52 TOOL_GXX3PLAIN_LD_SONAME ?= $(TOOL_GXX3PLAIN_LD_SONAME.$(BUILD_TARGET))
53endif
54ifdef SLKRUNS
55 TOOL_GXX3PLAIN_CC += -fmessage-length=0
56 TOOL_GXX3PLAIN_CXX += -fmessage-length=0
57endif
58
59# General Properties used by kBuild
60TOOL_GXX3PLAIN_COBJSUFF ?= .o
61TOOL_GXX3PLAIN_CFLAGS ?=
62TOOL_GXX3PLAIN_CFLAGS.debug ?= -g
63TOOL_GXX3PLAIN_CFLAGS.profile ?= -O2 #-g -pg
64TOOL_GXX3PLAIN_CFLAGS.release ?= -O2
65TOOL_GXX3PLAIN_CINCS ?=
66TOOL_GXX3PLAIN_CDEFS ?=
67
68TOOL_GXX3PLAIN_CXXOBJSUFF ?= .o
69TOOL_GXX3PLAIN_CXXOBJSUFF ?= .o
70TOOL_GXX3PLAIN_CXXFLAGS ?=
71TOOL_GXX3PLAIN_CXXFLAGS.debug ?= -g
72TOOL_GXX3PLAIN_CXXFLAGS.profile ?= -O2 #-g -pg
73TOOL_GXX3PLAIN_CXXFLAGS.release ?= -O2
74TOOL_GXX3PLAIN_CXXINCS ?=
75TOOL_GXX3PLAIN_CXXDEFS ?=
76
77TOOL_GXX3PLAIN_ASFLAGS ?= -x assembler-with-cpp
78TOOL_GXX3PLAIN_ASFLAGS.debug ?= -g
79TOOL_GXX3PLAIN_ASFLAGS.profile ?= -g
80TOOL_GXX3PLAIN_ASOBJSUFF ?= .o
81
82TOOL_GXX3PLAIN_ARFLAGS ?= cr
83TOOL_GXX3PLAIN_ARLIBSUFF ?= .a
84
85TOOL_GXX3PLAIN_LDFLAGS ?=
86
87
88## Compile C source.
89# @param $(target) Normalized main target name.
90# @param $(source) Source filename (relative).
91# @param $(obj) Object file name. This shall be (re)created by the compilation.
92# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
93# @param $(flags) Flags.
94# @param $(defs) Definitions. No -D or something.
95# @param $(incs) Includes. No -I or something.
96# @param $(dirdep) Directory creation dependency.
97# @param $(deps) Other dependencies.
98#
99# @param $(outbase) Output basename (full). Use this for list files and such.
100# @param $(objsuff) Object suffix.
101TOOL_GXX3PLAIN_COMPILE_C_DEPEND =
102TOOL_GXX3PLAIN_COMPILE_C_DEPORD =
103ifdef USE_KOBJCACHE
104TOOL_GXX3PLAIN_COMPILE_C_USES_KOBJCACHE = 1
105TOOL_GXX3PLAIN_COMPILE_C_OUTPUT = $(outbase).i
106define TOOL_GXX3PLAIN_COMPILE_C_CMDS
107 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
108 --kObjCache-cpp $(outbase).i\
109 $(TOOL_GXX3PLAIN_CC) -E -o -\
110 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
111 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
112 $(abspath $(source))\
113 --kObjCache-cc $(obj)\
114 $(TOOL_GXX3PLAIN_CC) -c\
115 $(flags) -fpreprocessed -x c\
116 -o $(obj)\
117 -
118endef
119else # !USE_KOBJCACHE
120TOOL_GXX3PLAIN_COMPILE_C_OUTPUT =
121define TOOL_GXX3PLAIN_COMPILE_C_CMDS
122 $(QUIET)$(TOOL_GXX3PLAIN_CC) -c\
123 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
124 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
125 -o $(obj)\
126 $(abspath $(source))
127endef
128endif # !USE_KOBJCACHE
129
130
131## Compile C++ source.
132# @param $(target) Normalized main target name.
133# @param $(source) Source filename (relative).
134# @param $(obj) Object file name. This shall be (re)created by the compilation.
135# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
136# @param $(flags) Flags.
137# @param $(defs) Definitions. No -D or something.
138# @param $(incs) Includes. No -I or something.
139# @param $(dirdep) Directory creation dependency.
140# @param $(deps) Other dependencies.
141# @param $(outbase) Output basename (full). Use this for list files and such.
142# @param $(objsuff) Object suffix.
143TOOL_GXX3PLAIN_COMPILE_CXX_DEPEND =
144TOOL_GXX3PLAIN_COMPILE_CXX_DEPORD =
145ifdef USE_KOBJCACHE
146TOOL_GXX3PLAIN_COMPILE_CXX_USES_KOBJCACHE = 1
147TOOL_GXX3PLAIN_COMPILE_CXX_OUTPUT = $(outbase).ii
148define TOOL_GXX3PLAIN_COMPILE_CXX_CMDS
149 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
150 --kObjCache-cpp $(outbase).ii\
151 $(TOOL_GXX3PLAIN_CXX) -E -o -\
152 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
153 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
154 $(abspath $(source))\
155 --kObjCache-cc $(obj)\
156 $(TOOL_GXX3PLAIN_CXX) -c\
157 $(flags) -fpreprocessed -x c++\
158 -o $(obj)\
159 -
160endef
161else # !USE_KOBJCACHE
162TOOL_GXX3PLAIN_COMPILE_CXX_OUTPUT =
163define TOOL_GXX3PLAIN_COMPILE_CXX_CMDS
164 $(QUIET)$(TOOL_GXX3PLAIN_CXX) -c\
165 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
166 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
167 -o $(obj)\
168 $(abspath $(source))
169endef
170endif # !USE_KOBJCACHE
171
172
173## Compile Assembly source.
174# @param $(target) Normalized main target name.
175# @param $(source) Source filename (relative).
176# @param $(obj) Object file name. This shall be (re)created by the compilation.
177# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
178# @param $(flags) Flags.
179# @param $(defs) Definitions. No -D or something.
180# @param $(incs) Includes. No -I or something.
181# @param $(dirdep) Directory creation dependency.
182# @param $(deps) Other dependencies.
183# @param $(outbase) Output basename (full). Use this for list files and such.
184# @param $(objsuff) Object suffix.
185#
186TOOL_GXX3PLAIN_COMPILE_AS_OUTPUT =
187TOOL_GXX3PLAIN_COMPILE_AS_DEPEND =
188TOOL_GXX3PLAIN_COMPILE_AS_DEPORD =
189define TOOL_GXX3PLAIN_COMPILE_AS_CMDS
190 $(QUIET)$(TOOL_GXX3PLAIN_AS) -c\
191 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
192 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
193 -o $(obj)\
194 $(abspath $(source))
195endef
196
197
198## Link library
199# @param $(target) Normalized main target name.
200# @param $(out) Library name.
201# @param $(objs) Object files to put in the library.
202# @param $(flags) Flags.
203# @param $(dirdep) Directory creation dependency.
204# @param $(deps) Other dependencies.
205# @param $(othersrc) Unhandled sources.
206# @param $(outbase) Output basename (full). Use this for list files and such.
207TOOL_GXX3PLAIN_LINK_LIBRARY_OUTPUT =
208TOOL_GXX3PLAIN_LINK_LIBRARY_DEPEND = $(othersrc)
209TOOL_GXX3PLAIN_LINK_LIBRARY_DEPORD =
210define TOOL_GXX3PLAIN_LINK_LIBRARY_CMDS
211 $(call xargs,$(QUIET)$(TOOL_GXX3PLAIN_AR) $(flags) $(out),$(objs))
212 $(foreach lib,$(othersrc)\
213 ,$(NL)$(TAB)$(call MSG_AR_MERGE,$(target),$(out),$(lib)) \
214 $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))ar.tmp.dir/* \
215 $(NL)$(TAB)$(QUIET)$(MKDIR) -p $(dir $(outbase))/ar.tmp.dir/ \
216 $(NL)$(TAB)$(QUIET)(cd $(dir $(outbase))ar.tmp.dir/ \
217 && $(TOOL_GXX3PLAIN_AR) x $(abspath $(lib)) \
218 && $(TOOL_GXX3PLAIN_AR) $(flags) $(out) *) \
219 $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))/ar.tmp.dir/* \
220 $(NL)$(TAB)$(QUIET)$(RMDIR) $(dir $(outbase))ar.tmp.dir/)
221 $(QUIET)$(TOOL_GXX3PLAIN_RANLIB) $(out)
222endef
223
224
225## Link program
226# @param $(target) Normalized main target name.
227# @param $(out) Program name.
228# @param $(objs) Object files to link together.
229# @param $(libs) Libraries to search.
230# @param $(libpath) Library search paths.
231# @param $(flags) Flags.
232# @param $(dirdep) Directory creation dependency.
233# @param $(deps) Other dependencies.
234# @param $(othersrc) Unhandled sources.
235# @param $(custom_pre) Custom step invoked before linking.
236# @param $(custom_post) Custom step invoked after linking.
237# @param $(outbase) Output basename (full). Use this for list files and such.
238TOOL_GXX3PLAIN_LINK_PROGRAM_OUTPUT =
239TOOL_GXX3PLAIN_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map
240TOOL_GXX3PLAIN_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
241 $(filter %.def, $(othersrc))
242TOOL_GXX3PLAIN_LINK_PROGRAM_DEPORD =
243define TOOL_GXX3PLAIN_LINK_PROGRAM_CMDS
244 $(QUIET)$(TOOL_GXX3PLAIN_LD) $(flags) -o $(out) $(objs)\
245 $(filter %.def, $(othersrc))\
246 $(foreach p,$(libpath), -L$(p))\
247 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
248endef
249
250
251## Link DLL
252# @param $(target) Normalized main target name.
253# @param $(out) Program name.
254# @param $(objs) Object files to link together.
255# @param $(libs) Libraries to search.
256# @param $(libpath) Library search paths.
257# @param $(flags) Flags.
258# @param $(dirdep) Directory creation dependency.
259# @param $(deps) Other dependencies.
260# @param $(othersrc) Unhandled sources.
261# @param $(custom_pre) Custom step invoked before linking.
262# @param $(custom_post) Custom step invoked after linking.
263# @param $(outbase) Output basename (full). Use this for list files and such.
264TOOL_GXX3PLAIN_LINK_DLL_OUTPUT =
265TOOL_GXX3PLAIN_LINK_DLL_OUTPUT_MAYBE = $(outbase).map
266TOOL_GXX3PLAIN_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
267 $(filter %.def, $(othersrc))
268TOOL_GXX3PLAIN_LINK_DLL_DEPORD =
269define TOOL_GXX3PLAIN_LINK_DLL_CMDS
270 $(QUIET)$(TOOL_GXX3PLAIN_LD) $(TOOL_GXX3PLAIN_LDFLAGS.dll) $(flags) -o $(out)\
271 $(if $(filter-out win32 os2, $(BUILD_TARGET)),$(call TOOL_GXX3PLAIN_LD_SONAME,$(target),$(out)))\
272 $(objs)\
273 $(filter %.def, $(othersrc))\
274 $(foreach p,$(libpath), -L$(p))\
275 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
276endef
277
278
279## Link system module (windows aka driver, linux aka kernel module)
280# This tool target might not work everywhere, but is provided for the
281# platforms where it works (Solaris, etc).
282#
283# @param $(target) Normalized main target name.
284# @param $(out) System module name.
285# @param $(objs) Object files to link together.
286# @param $(libs) Libraries to search.
287# @param $(libpath) Library search paths.
288# @param $(flags) Flags.
289# @param $(dirdep) Directory creation dependency.
290# @param $(deps) Other dependencies.
291# @param $(othersrc) Unhandled sources.
292# @param $(custom_pre) Custom step invoked before linking.
293# @param $(custom_post) Custom step invoked after linking.
294# @param $(outbase) Output basename (full). Use this for list files and such.
295TOOL_GXX3PLAIN_LINK_SYSMOD_OUTPUT =
296TOOL_GXX3PLAIN_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map
297TOOL_GXX3PLAIN_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
298 $(filter %.def, $(othersrc))
299TOOL_GXX3PLAIN_LINK_SYSMOD_DEPORD =
300define TOOL_GXX3PLAIN_LINK_SYSMOD_CMDS
301 $(QUIET)$(if $(TOOL_GXX3PLAIN_LD_SYSMOD.$(bld_trg)),$(TOOL_GXX3PLAIN_LD_SYSMOD.$(bld_trg)),$(TOOL_GXX3PLAIN_LD_SYSMOD))\
302 $(TOOL_GXX3PLAIN_LDFLAGS_SYSMOD.$(bld_trg)) $(flags) -o $(out) \
303 $(objs)\
304 $(filter %.def, $(othersrc))\
305 $(foreach p,$(libpath), -L$(p))\
306 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
307 $(call TOOL_GXX3PLAIN_LD_SYSMOD_MAP.$(bld_trg),$(outbase).map)
308endef
309
Note: See TracBrowser for help on using the repository browser.