source: trunk/kBuild/tools/GXX3.kmk@ 2578

Last change on this file since 2578 was 2541, checked in by bird, 14 years ago

tools/G*: debug splitting.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.5 KB
Line 
1# $Id: GXX3.kmk 2541 2011-08-03 09:51:30Z bird $
2## @file
3# kBuild Tool Config - Generic GCC v3.2.x using the system GCC and Binutils, for building C++ code.
4#
5
6#
7# Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
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# As a special exception you are granted permission to include this file, via
27# the kmk include directive, as you wish without this in itself causing the
28# resulting makefile, program or whatever to be covered by the GPL license.
29# This exception does not however invalidate any other reasons why the makefile,
30# program, whatever should not be covered the GPL.
31#
32#
33
34TOOL_GXX3 := Generic GCC v3.2.x or later using the system GCC and Binutils, for building C++ code.
35
36# Tool Specific Properties
37TOOL_GXX3_CC ?= gcc$(HOSTSUFF_EXE)
38TOOL_GXX3_CXX ?= g++$(HOSTSUFF_EXE)
39TOOL_GXX3_AS ?= gcc$(HOSTSUFF_EXE)
40ifeq ($(KBUILD_TARGET),solaris)
41 TOOL_GXX3_AR ?= gar$(HOSTSUFF_EXE)
42else
43 TOOL_GXX3_AR ?= ar$(HOSTSUFF_EXE)
44endif
45ifeq ($(KBUILD_TARGET),os2)
46 TOOL_GXX3_AR_IMP ?= emximp$(HOSTSTUFF_EXE)
47else
48 TOOL_GXX3_AR_IMP ?= $(ECHO) not supported!
49endif
50TOOL_GXX3_LD ?= g++$(HOSTSUFF_EXE)
51TOOL_GXX3_LD_SYSMOD ?= ld$(HOSTSUFF_EXE)
52ifndef TOOL_GXX3_LDFLAGS.$(KBUILD_TARGET)
53 TOOL_GXX3_LDFLAGS.dll ?= -shared
54else
55 TOOL_GXX3_LDFLAGS.dll ?= $(TOOL_GXX3_LDFLAGS.$(KBUILD_TARGET))
56endif
57TOOL_GXX3_LDFLAGS.sysmod ?= -r
58TOOL_GXX3_LD_SONAME ?= -Wl,-soname=$(firstword $($(1)_SONAME.$(KBUILD_TARGET).$(KBUILD_TYPE)) $($(1)_SONAME.$(KBUILD_TARGET)) $($(1)_SONAME.$(KBUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
59ifeq ($(KBUILD_TARGET),os2)
60 TOOL_GXX3_LD_MAP ?= -Zmap=$(1)
61 TOOL_GXX3_LD_SYSMOD_MAP ?= -Zmap=$(1)
62else
63 TOOL_GXX3_LD_MAP ?=
64 TOOL_GXX3_LD_SYSMOD_MAP ?=
65endif
66if1of ($(KBUILD_HOST), solaris)
67 TOOL_GXX3_OBJCOPY ?= gobjcopy$(HOSTSUFF_EXE)
68else
69 TOOL_GXX3_OBJCOPY ?= objcopy$(HOSTSUFF_EXE)
70endif
71
72ifdef SLKRUNS
73 TOOL_GXX3_CC += -fmessage-length=0
74 TOOL_GXX3_CXX += -fmessage-length=0
75endif
76
77# General Properties used by kBuild
78TOOL_GXX3_COBJSUFF ?= .o
79TOOL_GXX3_CFLAGS ?=
80TOOL_GXX3_CFLAGS.debug ?= -g
81TOOL_GXX3_CFLAGS.profile ?= -O2 #-g -pg
82TOOL_GXX3_CFLAGS.release ?= -O2
83TOOL_GXX3_CINCS ?=
84TOOL_GXX3_CDEFS ?=
85
86TOOL_GXX3_CXXOBJSUFF ?= .o
87TOOL_GXX3_CXXOBJSUFF ?= .o
88TOOL_GXX3_CXXFLAGS ?=
89TOOL_GXX3_CXXFLAGS.debug ?= -g
90TOOL_GXX3_CXXFLAGS.profile ?= -O2 #-g -pg
91TOOL_GXX3_CXXFLAGS.release ?= -O2
92TOOL_GXX3_CXXINCS ?=
93TOOL_GXX3_CXXDEFS ?=
94
95TOOL_GXX3_ASFLAGS ?= -x assembler-with-cpp
96TOOL_GXX3_ASFLAGS.debug ?= -g
97TOOL_GXX3_ASFLAGS.profile ?= -g
98TOOL_GXX3_ASOBJSUFF ?= .o
99
100TOOL_GXX3_ARFLAGS ?= cr
101TOOL_GXX3_ARLIBSUFF ?= .a
102
103TOOL_GXX3_LDFLAGS ?=
104TOOL_GXX3_LDFLAGS.debug ?= -g
105TOOL_GXX3_LDFLAGS.profile ?= -g
106
107
108## Compile C source.
109# @param $(target) Normalized main target name.
110# @param $(source) Source filename (relative).
111# @param $(obj) Object file name. This shall be (re)created by the compilation.
112# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
113# @param $(flags) Flags.
114# @param $(defs) Definitions. No -D or something.
115# @param $(incs) Includes. No -I or something.
116# @param $(dirdep) Directory creation dependency.
117# @param $(deps) Other dependencies.
118#
119# @param $(outbase) Output basename (full). Use this for list files and such.
120# @param $(objsuff) Object suffix.
121TOOL_GXX3_COMPILE_C_DEPEND =
122TOOL_GXX3_COMPILE_C_DEPORD =
123ifdef KBUILD_USE_KOBJCACHE
124TOOL_GXX3_COMPILE_C_USES_KOBJCACHE = 1
125TOOL_GXX3_COMPILE_C_OUTPUT = $(outbase).i
126define TOOL_GXX3_COMPILE_C_CMDS
127 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
128 --kObjCache-cpp $(outbase).i\
129 $(TOOL_GXX3_CC) -E -o -\
130 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
131 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
132 $(abspath $(source))\
133 --kObjCache-cc $(obj)\
134 $(TOOL_GXX3_CC) -c\
135 $(flags) -fpreprocessed -x c\
136 -o $(obj)\
137 -
138 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
139endef
140else # !KBUILD_USE_KOBJCACHE
141TOOL_GXX3_COMPILE_C_OUTPUT =
142define TOOL_GXX3_COMPILE_C_CMDS
143 $(QUIET)$(TOOL_GXX3_CC) -c\
144 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
145 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
146 -o $(obj)\
147 $(abspath $(source))
148 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
149endef
150endif # !KBUILD_USE_KOBJCACHE
151
152
153## Compile C++ source.
154# @param $(target) Normalized main target name.
155# @param $(source) Source filename (relative).
156# @param $(obj) Object file name. This shall be (re)created by the compilation.
157# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
158# @param $(flags) Flags.
159# @param $(defs) Definitions. No -D or something.
160# @param $(incs) Includes. No -I or something.
161# @param $(dirdep) Directory creation dependency.
162# @param $(deps) Other dependencies.
163# @param $(outbase) Output basename (full). Use this for list files and such.
164# @param $(objsuff) Object suffix.
165TOOL_GXX3_COMPILE_CXX_DEPEND =
166TOOL_GXX3_COMPILE_CXX_DEPORD =
167ifdef KBUILD_USE_KOBJCACHE
168TOOL_GXX3_COMPILE_CXX_USES_KOBJCACHE = 1
169TOOL_GXX3_COMPILE_CXX_OUTPUT = $(outbase).ii
170define TOOL_GXX3_COMPILE_CXX_CMDS
171 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
172 --kObjCache-cpp $(outbase).ii\
173 $(TOOL_GXX3_CXX) -E -o -\
174 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
175 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
176 $(abspath $(source))\
177 --kObjCache-cc $(obj)\
178 $(TOOL_GXX3_CXX) -c\
179 $(flags) -fpreprocessed -x c++\
180 -o $(obj)\
181 -
182 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
183endef
184else # !KBUILD_USE_KOBJCACHE
185TOOL_GXX3_COMPILE_CXX_OUTPUT =
186define TOOL_GXX3_COMPILE_CXX_CMDS
187 $(QUIET)$(TOOL_GXX3_CXX) -c\
188 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
189 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
190 -o $(obj)\
191 $(abspath $(source))
192 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
193endef
194endif # !KBUILD_USE_KOBJCACHE
195
196
197## Compile Assembly source.
198# @param $(target) Normalized main target name.
199# @param $(source) Source filename (relative).
200# @param $(obj) Object file name. This shall be (re)created by the compilation.
201# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
202# @param $(flags) Flags.
203# @param $(defs) Definitions. No -D or something.
204# @param $(incs) Includes. No -I or something.
205# @param $(dirdep) Directory creation dependency.
206# @param $(deps) Other dependencies.
207# @param $(outbase) Output basename (full). Use this for list files and such.
208# @param $(objsuff) Object suffix.
209#
210TOOL_GXX3_COMPILE_AS_OUTPUT =
211TOOL_GXX3_COMPILE_AS_DEPEND =
212TOOL_GXX3_COMPILE_AS_DEPORD =
213define TOOL_GXX3_COMPILE_AS_CMDS
214 $(QUIET)$(TOOL_GXX3_AS) -c\
215 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
216 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
217 -o $(obj)\
218 $(abspath $(source))
219 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
220endef
221
222
223## Link library
224# @param $(target) Normalized main target name.
225# @param $(out) Library name.
226# @param $(objs) Object files to put in the library.
227# @param $(flags) Flags.
228# @param $(dirdep) Directory creation dependency.
229# @param $(deps) Other dependencies.
230# @param $(othersrc) Unhandled sources.
231# @param $(outbase) Output basename (full). Use this for list files and such.
232TOOL_GXX3_LINK_LIBRARY_OUTPUT = $(out).ar-script
233TOOL_GXX3_LINK_LIBRARY_OUTPUT_MAYBE = $(outbase).imp.a
234TOOL_GXX3_LINK_LIBRARY_DEPEND = $(othersrc)
235TOOL_GXX3_LINK_LIBRARY_DEPORD =
236define TOOL_GXX3_LINK_LIBRARY_CMDS
237 $(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)'
238 $(QUIET)$(APPEND) -n $(out).ar-script \
239 $(foreach o,$(objs), 'ADDMOD $(o)') \
240 $(foreach o,$(filter-out %.def %.imp,$(othersrc)), 'ADDLIB $(o)')
241 $(if $(filter %.def %.imp,$(othersrc))\
242 ,$(TOOL_GXX3_AR_IMP) -o $(outbase).imp.a $(filter %.def %.imp,$(othersrc))\
243 $(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script 'ADDLIB $(outbase).imp.a')
244 $(QUIET)$(APPEND) $(out).ar-script 'SAVE'
245 $(QUIET)$(APPEND) $(out).ar-script 'END'
246 $(QUIET)$(REDIRECT) -rti $(out).ar-script -- $(TOOL_GXX3_AR) -M
247endef
248
249
250## Link program
251# @param $(target) Normalized main target name.
252# @param $(out) Program name.
253# @param $(objs) Object files to link together.
254# @param $(libs) Libraries to search.
255# @param $(libpath) Library search paths.
256# @param $(flags) Flags.
257# @param $(dirdep) Directory creation dependency.
258# @param $(deps) Other dependencies.
259# @param $(othersrc) Unhandled sources.
260# @param $(custom_pre) Custom step invoked before linking.
261# @param $(custom_post) Custom step invoked after linking.
262# @param $(outbase) Output basename (full). Use this for list files and such.
263TOOL_GXX3_LINK_PROGRAM_OUTPUT =
264TOOL_GXX3_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map
265TOOL_GXX3_LINK_PROGRAM_OUTPUT_DEBUG = $(outbase).debug
266TOOL_GXX3_LINK_PROGRAM_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug
267TOOL_GXX3_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
268 $(filter %.def, $(othersrc))
269TOOL_GXX3_LINK_PROGRAM_DEPORD =
270define TOOL_GXX3_LINK_PROGRAM_CMDS
271 $(QUIET)$(TOOL_GXX3_LD) $(flags) -o $(out) $(objs)\
272 $(filter %.def, $(othersrc))\
273 $(foreach p,$(libpath), -L$(p))\
274 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
275 $(call TOOL_GXX3_LD_MAP,$(outbase).map)
276 ifeq ($(ld_debug),split)
277 $(TOOL_GXX3_OBJCOPY) --only-keep-debug $(out) $(outbase).debug
278 $(CHMOD) a-x $(outbase).debug
279 $(TOOL_GXX3_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out)
280 endif
281endef
282
283
284## Link DLL
285# @param $(target) Normalized main target name.
286# @param $(out) Program name.
287# @param $(objs) Object files to link together.
288# @param $(libs) Libraries to search.
289# @param $(libpath) Library search paths.
290# @param $(flags) Flags.
291# @param $(dirdep) Directory creation dependency.
292# @param $(deps) Other dependencies.
293# @param $(othersrc) Unhandled sources.
294# @param $(custom_pre) Custom step invoked before linking.
295# @param $(custom_post) Custom step invoked after linking.
296# @param $(outbase) Output basename (full). Use this for list files and such.
297TOOL_GXX3_LINK_DLL_OUTPUT =
298TOOL_GXX3_LINK_DLL_OUTPUT_MAYBE = $(outbase).map
299TOOL_GXX3_LINK_DLL_OUTPUT_DEBUG = $(outbase).debug
300TOOL_GXX3_LINK_DLL_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug
301TOOL_GXX3_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
302 $(filter %.def, $(othersrc))
303TOOL_GXX3_LINK_DLL_DEPORD =
304define TOOL_GXX3_LINK_DLL_CMDS
305 $(QUIET)$(TOOL_GXX3_LD) $(TOOL_GXX3_LDFLAGS.dll) $(flags) -o $(out)\
306 $(if $(filter-out win os2, $(KBUILD_TARGET)),$(call TOOL_GXX3_LD_SONAME,$(target),$(out)))\
307 $(objs)\
308 $(filter %.def, $(othersrc))\
309 $(foreach p,$(libpath), -L$(p))\
310 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
311 $(call TOOL_GXX3_LD_MAP,$(outbase).map)
312 ifeq ($(ld_debug),split)
313 $(TOOL_GXX3_OBJCOPY) --only-keep-debug $(out) $(outbase).debug
314 $(CHMOD) a-x $(outbase).debug
315 $(TOOL_GXX3_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out)
316 endif
317endef
318
319
320## Link system module (windows aka driver, linux aka kernel module)
321# @param $(target) Normalized main target name.
322# @param $(out) System module name.
323# @param $(objs) Object files to link together.
324# @param $(libs) Libraries to search.
325# @param $(libpath) Library search paths.
326# @param $(flags) Flags.
327# @param $(dirdep) Directory creation dependency.
328# @param $(deps) Other dependencies.
329# @param $(othersrc) Unhandled sources.
330# @param $(custom_pre) Custom step invoked before linking.
331# @param $(custom_post) Custom step invoked after linking.
332# @param $(outbase) Output basename (full). Use this for list files and such.
333TOOL_GXX3_LINK_SYSMOD_OUTPUT =
334TOOL_GXX3_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map
335TOOL_GXX3_LINK_SYSMOD_OUTPUT_DEBUG = $(outbase).debug
336TOOL_GXX3_LINK_SYSMOD_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug
337TOOL_GXX3_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
338 $(filter %.def, $(othersrc))
339TOOL_GXX3_LINK_SYSMOD_DEPORD =
340define TOOL_GXX3_LINK_SYSMOD_CMDS
341 $(QUIET)$(TOOL_GXX3_LD_SYSMOD) $(TOOL_GXX3_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
342 $(filter %.def, $(othersrc))\
343 $(foreach p,$(libpath), -L$(p))\
344 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
345 $(call TOOL_GXX3_LD_SYSMOD_MAP,$(outbase).map)
346 ifeq ($(ld_debug),split)
347 $(TOOL_GXX3_OBJCOPY) --only-keep-debug $(out) $(outbase).debug
348 $(CHMOD) a-x $(outbase).debug
349 $(TOOL_GXX3_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out)
350 endif
351endef
352
Note: See TracBrowser for help on using the repository browser.