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

Last change on this file since 2487 was 2431, checked in by bird, 15 years ago

tools/G*.kmk: Add dummy source rule/dep to the gcc generated dependency files to make it less painful to move a source file without changing the target names. Fixes #101.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.3 KB
Line 
1# $Id: GXX3.kmk 2431 2010-11-19 11:06:42Z 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
66ifdef SLKRUNS
67 TOOL_GXX3_CC += -fmessage-length=0
68 TOOL_GXX3_CXX += -fmessage-length=0
69endif
70
71# General Properties used by kBuild
72TOOL_GXX3_COBJSUFF ?= .o
73TOOL_GXX3_CFLAGS ?=
74TOOL_GXX3_CFLAGS.debug ?= -g
75TOOL_GXX3_CFLAGS.profile ?= -O2 #-g -pg
76TOOL_GXX3_CFLAGS.release ?= -O2
77TOOL_GXX3_CINCS ?=
78TOOL_GXX3_CDEFS ?=
79
80TOOL_GXX3_CXXOBJSUFF ?= .o
81TOOL_GXX3_CXXOBJSUFF ?= .o
82TOOL_GXX3_CXXFLAGS ?=
83TOOL_GXX3_CXXFLAGS.debug ?= -g
84TOOL_GXX3_CXXFLAGS.profile ?= -O2 #-g -pg
85TOOL_GXX3_CXXFLAGS.release ?= -O2
86TOOL_GXX3_CXXINCS ?=
87TOOL_GXX3_CXXDEFS ?=
88
89TOOL_GXX3_ASFLAGS ?= -x assembler-with-cpp
90TOOL_GXX3_ASFLAGS.debug ?= -g
91TOOL_GXX3_ASFLAGS.profile ?= -g
92TOOL_GXX3_ASOBJSUFF ?= .o
93
94TOOL_GXX3_ARFLAGS ?= cr
95TOOL_GXX3_ARLIBSUFF ?= .a
96
97TOOL_GXX3_LDFLAGS ?=
98TOOL_GXX3_LDFLAGS.debug ?= -g
99TOOL_GXX3_LDFLAGS.profile ?= -g
100
101
102## Compile C source.
103# @param $(target) Normalized main target name.
104# @param $(source) Source filename (relative).
105# @param $(obj) Object file name. This shall be (re)created by the compilation.
106# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
107# @param $(flags) Flags.
108# @param $(defs) Definitions. No -D or something.
109# @param $(incs) Includes. No -I or something.
110# @param $(dirdep) Directory creation dependency.
111# @param $(deps) Other dependencies.
112#
113# @param $(outbase) Output basename (full). Use this for list files and such.
114# @param $(objsuff) Object suffix.
115TOOL_GXX3_COMPILE_C_DEPEND =
116TOOL_GXX3_COMPILE_C_DEPORD =
117ifdef KBUILD_USE_KOBJCACHE
118TOOL_GXX3_COMPILE_C_USES_KOBJCACHE = 1
119TOOL_GXX3_COMPILE_C_OUTPUT = $(outbase).i
120define TOOL_GXX3_COMPILE_C_CMDS
121 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
122 --kObjCache-cpp $(outbase).i\
123 $(TOOL_GXX3_CC) -E -o -\
124 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
125 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
126 $(abspath $(source))\
127 --kObjCache-cc $(obj)\
128 $(TOOL_GXX3_CC) -c\
129 $(flags) -fpreprocessed -x c\
130 -o $(obj)\
131 -
132 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
133endef
134else # !KBUILD_USE_KOBJCACHE
135TOOL_GXX3_COMPILE_C_OUTPUT =
136define TOOL_GXX3_COMPILE_C_CMDS
137 $(QUIET)$(TOOL_GXX3_CC) -c\
138 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
139 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
140 -o $(obj)\
141 $(abspath $(source))
142 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
143endef
144endif # !KBUILD_USE_KOBJCACHE
145
146
147## Compile C++ source.
148# @param $(target) Normalized main target name.
149# @param $(source) Source filename (relative).
150# @param $(obj) Object file name. This shall be (re)created by the compilation.
151# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
152# @param $(flags) Flags.
153# @param $(defs) Definitions. No -D or something.
154# @param $(incs) Includes. No -I or something.
155# @param $(dirdep) Directory creation dependency.
156# @param $(deps) Other dependencies.
157# @param $(outbase) Output basename (full). Use this for list files and such.
158# @param $(objsuff) Object suffix.
159TOOL_GXX3_COMPILE_CXX_DEPEND =
160TOOL_GXX3_COMPILE_CXX_DEPORD =
161ifdef KBUILD_USE_KOBJCACHE
162TOOL_GXX3_COMPILE_CXX_USES_KOBJCACHE = 1
163TOOL_GXX3_COMPILE_CXX_OUTPUT = $(outbase).ii
164define TOOL_GXX3_COMPILE_CXX_CMDS
165 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
166 --kObjCache-cpp $(outbase).ii\
167 $(TOOL_GXX3_CXX) -E -o -\
168 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
169 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
170 $(abspath $(source))\
171 --kObjCache-cc $(obj)\
172 $(TOOL_GXX3_CXX) -c\
173 $(flags) -fpreprocessed -x c++\
174 -o $(obj)\
175 -
176 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
177endef
178else # !KBUILD_USE_KOBJCACHE
179TOOL_GXX3_COMPILE_CXX_OUTPUT =
180define TOOL_GXX3_COMPILE_CXX_CMDS
181 $(QUIET)$(TOOL_GXX3_CXX) -c\
182 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
183 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
184 -o $(obj)\
185 $(abspath $(source))
186 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
187endef
188endif # !KBUILD_USE_KOBJCACHE
189
190
191## Compile Assembly source.
192# @param $(target) Normalized main target name.
193# @param $(source) Source filename (relative).
194# @param $(obj) Object file name. This shall be (re)created by the compilation.
195# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
196# @param $(flags) Flags.
197# @param $(defs) Definitions. No -D or something.
198# @param $(incs) Includes. No -I or something.
199# @param $(dirdep) Directory creation dependency.
200# @param $(deps) Other dependencies.
201# @param $(outbase) Output basename (full). Use this for list files and such.
202# @param $(objsuff) Object suffix.
203#
204TOOL_GXX3_COMPILE_AS_OUTPUT =
205TOOL_GXX3_COMPILE_AS_DEPEND =
206TOOL_GXX3_COMPILE_AS_DEPORD =
207define TOOL_GXX3_COMPILE_AS_CMDS
208 $(QUIET)$(TOOL_GXX3_AS) -c\
209 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
210 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
211 -o $(obj)\
212 $(abspath $(source))
213 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
214endef
215
216
217## Link library
218# @param $(target) Normalized main target name.
219# @param $(out) Library name.
220# @param $(objs) Object files to put in the library.
221# @param $(flags) Flags.
222# @param $(dirdep) Directory creation dependency.
223# @param $(deps) Other dependencies.
224# @param $(othersrc) Unhandled sources.
225# @param $(outbase) Output basename (full). Use this for list files and such.
226TOOL_GXX3_LINK_LIBRARY_OUTPUT = $(out).ar-script
227TOOL_GXX3_LINK_LIBRARY_OUTPUT_MAYBE = $(outbase).imp.a
228TOOL_GXX3_LINK_LIBRARY_DEPEND = $(othersrc)
229TOOL_GXX3_LINK_LIBRARY_DEPORD =
230define TOOL_GXX3_LINK_LIBRARY_CMDS
231 $(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)'
232 $(QUIET)$(APPEND) -n $(out).ar-script \
233 $(foreach o,$(objs), 'ADDMOD $(o)') \
234 $(foreach o,$(filter-out %.def %.imp,$(othersrc)), 'ADDLIB $(o)')
235 $(if $(filter %.def %.imp,$(othersrc))\
236 ,$(TOOL_GXX3_AR_IMP) -o $(outbase).imp.a $(filter %.def %.imp,$(othersrc))\
237 $(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script 'ADDLIB $(outbase).imp.a')
238 $(QUIET)$(APPEND) $(out).ar-script 'SAVE'
239 $(QUIET)$(APPEND) $(out).ar-script 'END'
240 $(QUIET)$(REDIRECT) -rti $(out).ar-script -- $(TOOL_GXX3_AR) -M
241endef
242
243
244## Link program
245# @param $(target) Normalized main target name.
246# @param $(out) Program name.
247# @param $(objs) Object files to link together.
248# @param $(libs) Libraries to search.
249# @param $(libpath) Library search paths.
250# @param $(flags) Flags.
251# @param $(dirdep) Directory creation dependency.
252# @param $(deps) Other dependencies.
253# @param $(othersrc) Unhandled sources.
254# @param $(custom_pre) Custom step invoked before linking.
255# @param $(custom_post) Custom step invoked after linking.
256# @param $(outbase) Output basename (full). Use this for list files and such.
257TOOL_GXX3_LINK_PROGRAM_OUTPUT =
258TOOL_GXX3_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map
259TOOL_GXX3_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
260 $(filter %.def, $(othersrc))
261TOOL_GXX3_LINK_PROGRAM_DEPORD =
262define TOOL_GXX3_LINK_PROGRAM_CMDS
263 $(QUIET)$(TOOL_GXX3_LD) $(flags) -o $(out) $(objs)\
264 $(filter %.def, $(othersrc))\
265 $(foreach p,$(libpath), -L$(p))\
266 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
267 $(call TOOL_GXX3_LD_MAP,$(outbase).map)
268endef
269
270
271## Link DLL
272# @param $(target) Normalized main target name.
273# @param $(out) Program name.
274# @param $(objs) Object files to link together.
275# @param $(libs) Libraries to search.
276# @param $(libpath) Library search paths.
277# @param $(flags) Flags.
278# @param $(dirdep) Directory creation dependency.
279# @param $(deps) Other dependencies.
280# @param $(othersrc) Unhandled sources.
281# @param $(custom_pre) Custom step invoked before linking.
282# @param $(custom_post) Custom step invoked after linking.
283# @param $(outbase) Output basename (full). Use this for list files and such.
284TOOL_GXX3_LINK_DLL_OUTPUT =
285TOOL_GXX3_LINK_DLL_OUTPUT_MAYBE = $(outbase).map
286TOOL_GXX3_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
287 $(filter %.def, $(othersrc))
288TOOL_GXX3_LINK_DLL_DEPORD =
289define TOOL_GXX3_LINK_DLL_CMDS
290 $(QUIET)$(TOOL_GXX3_LD) $(TOOL_GXX3_LDFLAGS.dll) $(flags) -o $(out)\
291 $(if $(filter-out win32 os2, $(KBUILD_TARGET)),$(call TOOL_GXX3_LD_SONAME,$(target),$(out)))\
292 $(objs)\
293 $(filter %.def, $(othersrc))\
294 $(foreach p,$(libpath), -L$(p))\
295 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
296 $(call TOOL_GXX3_LD_MAP,$(outbase).map)
297endef
298
299
300## Link system module (windows aka driver, linux aka kernel module)
301# @param $(target) Normalized main target name.
302# @param $(out) System module name.
303# @param $(objs) Object files to link together.
304# @param $(libs) Libraries to search.
305# @param $(libpath) Library search paths.
306# @param $(flags) Flags.
307# @param $(dirdep) Directory creation dependency.
308# @param $(deps) Other dependencies.
309# @param $(othersrc) Unhandled sources.
310# @param $(custom_pre) Custom step invoked before linking.
311# @param $(custom_post) Custom step invoked after linking.
312# @param $(outbase) Output basename (full). Use this for list files and such.
313TOOL_GXX3_LINK_SYSMOD_OUTPUT =
314TOOL_GXX3_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map
315TOOL_GXX3_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
316 $(filter %.def, $(othersrc))
317TOOL_GXX3_LINK_SYSMOD_DEPORD =
318define TOOL_GXX3_LINK_SYSMOD_CMDS
319 $(QUIET)$(TOOL_GXX3_LD_SYSMOD) $(TOOL_GXX3_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
320 $(filter %.def, $(othersrc))\
321 $(foreach p,$(libpath), -L$(p))\
322 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
323 $(call TOOL_GXX3_LD_SYSMOD_MAP,$(outbase).map)
324endef
325
Note: See TracBrowser for help on using the repository browser.