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

Last change on this file since 1058 was 1058, checked in by bird, 18 years ago

Updated to new cache code. Also dropped -g from the profile cflags and cxxflags to improve cache hits.

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