source: trunk/kBuild/tools/GCC3.kmk@ 1027

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

kObjCache.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 12.1 KB
Line 
1# $Id: GCC3.kmk 1015 2007-06-02 18:57:50Z bird $
2## @file
3#
4# kBuild Tool Config - Generic GCC v3.2.x or later Using The System GCC and Binutils.
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_GCC3 := Generic GCC v3.2.x or later Using The System GCC and Binutils.
28
29# Tool Specific Properties
30TOOL_GCC3_CC ?= gcc$(HOSTSUFF_EXE)
31TOOL_GCC3_CXX ?= g++$(HOSTSUFF_EXE)
32TOOL_GCC3_AS ?= gcc$(HOSTSUFF_EXE)
33ifeq ($(BUILD_TARGET),solaris) ## @todo drop the MRI script!
34 TOOL_GCC3_AR ?= gar$(HOSTSUFF_EXE)
35else
36 TOOL_GCC3_AR ?= ar$(HOSTSUFF_EXE)
37endif
38ifeq ($(BUILD_TARGET),os2)
39 TOOL_GCC3_AR_IMP ?= emximp$(HOSTSTUFF_EXE)
40else
41 TOOL_GCC3_AR_IMP ?= $(ECHO) not supported!
42endif
43TOOL_GCC3_LD ?= gcc$(HOSTSUFF_EXE)
44TOOL_GCC3_LD_SYSMOD ?= ld$(HOSTSUFF_EXE)
45ifndef TOOL_GCC3_LDFLAGS.$(BUILD_TARGET)
46 TOOL_GCC3_LDFLAGS.dll ?= -shared
47else
48 TOOL_GCC3_LDFLAGS.dll ?= $(TOOL_GCC3_LDFLAGS.$(BUILD_TARGET))
49endif
50TOOL_GCC3_LDFLAGS.sysmod ?= -r
51TOOL_GCC3_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_GCC3_LD_MAP ?= -Zmap=$(1)
54 TOOL_GCC3_LD_SYSMOD_MAP ?= -Zmap=$(1)
55endif
56ifdef SLKRUNS
57 TOOL_GCC3_CC += -fmessage-length=0
58 TOOL_GCC3_CXX += -fmessage-length=0
59endif
60
61# General Properties used by kBuild
62TOOL_GCC3_COBJSUFF ?= .o
63TOOL_GCC3_CFLAGS ?=
64TOOL_GCC3_CFLAGS.debug ?= -g
65TOOL_GCC3_CFLAGS.profile ?= -g -O2 #-pg
66TOOL_GCC3_CFLAGS.release ?= -O2
67TOOL_GCC3_CINCS ?=
68TOOL_GCC3_CDEFS ?=
69
70TOOL_GCC3_CXXOBJSUFF ?= .o
71TOOL_GCC3_CXXOBJSUFF ?= .o
72TOOL_GCC3_CXXFLAGS ?=
73TOOL_GCC3_CXXFLAGS.debug ?= -g
74TOOL_GCC3_CXXFLAGS.profile ?= -g -O2 #-pg
75TOOL_GCC3_CXXFLAGS.release ?= -O2
76TOOL_GCC3_CXXINCS ?=
77TOOL_GCC3_CXXDEFS ?=
78
79TOOL_GCC3_ASFLAGS ?= -x assembler-with-cpp
80TOOL_GCC3_ASFLAGS.debug ?= -g
81TOOL_GCC3_ASFLAGS.profile ?= -g
82TOOL_GCC3_ASOBJSUFF ?= .o
83
84TOOL_GCC3_ARFLAGS ?= cr
85TOOL_GCC3_ARLIBSUFF ?= .a
86
87TOOL_GCC3_LDFLAGS ?=
88TOOL_GCC3_LDFLAGS.debug ?= -g
89TOOL_GCC3_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_GCC3_COMPILE_C_DEPEND =
106TOOL_GCC3_COMPILE_C_DEPORD =
107ifdef USE_KOBJCACHE
108TOOL_GCC3_COMPILE_C_USES_KOBJCACHE = 1
109TOOL_GCC3_COMPILE_C_OUTPUT = $(outbase).i
110define TOOL_GCC3_COMPILE_C_CMDS
111 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -r --kObjCache-cpp $(outbase).i \
112 $(TOOL_GCC3_CC) -E -o -\
113 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
114 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
115 $(abspath $(source)) \
116 --kObjCache-cc $(obj) \
117 $(TOOL_GCC3_CC) -c\
118 $(flags)\
119 -o $(obj)\
120 $(outbase).i
121endef
122else # !USE_KOBJCACHE
123TOOL_GCC3_COMPILE_C_OUTPUT =
124define TOOL_GCC3_COMPILE_C_CMDS
125 $(QUIET)$(TOOL_GCC3_CC) -c\
126 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
127 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
128 -o $(obj)\
129 $(abspath $(source))
130endef
131endif # !USE_KOBJCACHE
132
133
134## Compile C++ source.
135# @param $(target) Normalized main target name.
136# @param $(source) Source filename (relative).
137# @param $(obj) Object file name. This shall be (re)created by the compilation.
138# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
139# @param $(flags) Flags.
140# @param $(defs) Definitions. No -D or something.
141# @param $(incs) Includes. No -I or something.
142# @param $(dirdep) Directory creation dependency.
143# @param $(deps) Other dependencies.
144# @param $(outbase) Output basename (full). Use this for list files and such.
145# @param $(objsuff) Object suffix.
146TOOL_GCC3_COMPILE_CXX_DEPEND =
147TOOL_GCC3_COMPILE_CXX_DEPORD =
148ifdef USE_KOBJCACHE
149TOOL_GCC3_COMPILE_CXX_USES_KOBJCACHE = 1
150TOOL_GCC3_COMPILE_CXX_OUTPUT = $(outbase).ii
151define TOOL_GCC3_COMPILE_CXX_CMDS
152 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -r --kObjCache-cpp $(outbase).ii \
153 $(TOOL_GCC3_CXX) -E -o -\
154 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
155 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
156 $(abspath $(source)) \
157 --kObjCache-cc $(obj) \
158 $(TOOL_GCC3_CXX) -c\
159 $(flags)\
160 -o $(obj)\
161 $(outbase).ii
162endef
163else # !USE_KOBJCACHE
164TOOL_GCC3_COMPILE_CXX_OUTPUT =
165define TOOL_GCC3_COMPILE_CXX_CMDS
166 $(QUIET)$(TOOL_GCC3_CXX) -c\
167 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
168 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
169 -o $(obj)\
170 $(abspath $(source))
171endef
172endif # !USE_KOBJCACHE
173
174
175## Compile Assembly source.
176# @param $(target) Normalized main target name.
177# @param $(source) Source filename (relative).
178# @param $(obj) Object file name. This shall be (re)created by the compilation.
179# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
180# @param $(flags) Flags.
181# @param $(defs) Definitions. No -D or something.
182# @param $(incs) Includes. No -I or something.
183# @param $(dirdep) Directory creation dependency.
184# @param $(deps) Other dependencies.
185# @param $(outbase) Output basename (full). Use this for list files and such.
186# @param $(objsuff) Object suffix.
187#
188TOOL_GCC3_COMPILE_AS_OUTPUT =
189TOOL_GCC3_COMPILE_AS_DEPEND =
190TOOL_GCC3_COMPILE_AS_DEPORD =
191define TOOL_GCC3_COMPILE_AS_CMDS
192 $(QUIET)$(TOOL_GCC3_AS) -c\
193 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
194 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
195 -o $(obj)\
196 $(abspath $(source))
197endef
198
199
200## Link library
201# @param $(target) Normalized main target name.
202# @param $(out) Library name.
203# @param $(objs) Object files to put in the library.
204# @param $(flags) Flags.
205# @param $(dirdep) Directory creation dependency.
206# @param $(deps) Other dependencies.
207# @param $(othersrc) Unhandled sources.
208# @param $(outbase) Output basename (full). Use this for list files and such.
209TOOL_GCC3_LINK_LIBRARY_OUTPUT = $(out).ar-script $(outbase).imp.a
210TOOL_GCC3_LINK_LIBRARY_DEPEND = $(othersrc)
211TOOL_GCC3_LINK_LIBRARY_DEPORD =
212ifeq ($(filter append-dash-n,$(KMK_FEATURES)),append-dash-n)
213define TOOL_GCC3_LINK_LIBRARY_CMDS
214 $(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)'
215 $(QUIET)$(APPEND) -n $(out).ar-script \
216 $(foreach o,$(objs), 'ADDMOD $(o)') \
217 $(foreach o,$(filter-out %.def %.imp,$(othersrc)), 'ADDLIB $(o)')
218 $(if $(filter %.def %.imp,$(othersrc))\
219 ,$(TOOL_GCC3_AR_IMP) -o $(outbase).imp.a $(filter %.def %.imp,$(othersrc))\
220 $(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script 'ADDLIB $(outbase).imp.a')
221 $(QUIET)$(APPEND) $(out).ar-script 'SAVE'
222 $(QUIET)$(APPEND) $(out).ar-script 'END'
223 $(QUIET)$(TOOL_GCC3_AR) -M < $(out).ar-script
224endef
225else
226define TOOL_GCC3_LINK_LIBRARY_CMDS
227 $(QUIET)$(APPEND) $(out).ar-script "CREATE $(out)"
228 $(foreach o, $(objs)\
229 ,$(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script "ADDMOD $(o)")
230 $(foreach srclib, $(filter-out %.def %.imp,$(othersrc))\
231 ,$(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script "ADDLIB $(srclib)")
232 $(if $(filter %.def %.imp,$(othersrc))\
233 ,$(TOOL_GCC3_AR_IMP) -o $(outbase).imp.a $(filter %.def %.imp,$(othersrc))\
234 $(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script "ADDLIB $(outbase).imp.a")
235 $(QUIET)$(APPEND) $(out).ar-script "SAVE"
236 $(QUIET)$(APPEND) $(out).ar-script "END"
237 $(QUIET)$(TOOL_GCC3_AR) -M < $(out).ar-script
238endef
239endif
240
241
242## Link program
243# @param $(target) Normalized main target name.
244# @param $(out) Program name.
245# @param $(objs) Object files to link together.
246# @param $(libs) Libraries to search.
247# @param $(libpath) Library search paths.
248# @param $(flags) Flags.
249# @param $(dirdep) Directory creation dependency.
250# @param $(deps) Other dependencies.
251# @param $(othersrc) Unhandled sources.
252# @param $(custom_pre) Custom step invoked before linking.
253# @param $(custom_post) Custom step invoked after linking.
254# @param $(outbase) Output basename (full). Use this for list files and such.
255TOOL_GCC3_LINK_PROGRAM_OUTPUT = $(outbase).map
256TOOL_GCC3_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
257 $(filter %.def, $(othersrc))
258TOOL_GCC3_LINK_PROGRAM_DEPORD =
259define TOOL_GCC3_LINK_PROGRAM_CMDS
260 $(QUIET)$(TOOL_GCC3_LD) $(flags) -o $(out) $(objs)\
261 $(filter %.def, $(othersrc))\
262 $(foreach p,$(libpath), -L$(p))\
263 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
264 $(call TOOL_GCC3_LD_MAP,$(outbase).map)
265endef
266
267
268## Link DLL
269# @param $(target) Normalized main target name.
270# @param $(out) Program name.
271# @param $(objs) Object files to link together.
272# @param $(libs) Libraries to search.
273# @param $(libpath) Library search paths.
274# @param $(flags) Flags.
275# @param $(dirdep) Directory creation dependency.
276# @param $(deps) Other dependencies.
277# @param $(othersrc) Unhandled sources.
278# @param $(custom_pre) Custom step invoked before linking.
279# @param $(custom_post) Custom step invoked after linking.
280# @param $(outbase) Output basename (full). Use this for list files and such.
281TOOL_GCC3_LINK_DLL_OUTPUT = $(outbase).map
282TOOL_GCC3_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
283 $(filter %.def, $(othersrc))
284TOOL_GCC3_LINK_DLL_DEPORD =
285define TOOL_GCC3_LINK_DLL_CMDS
286 $(QUIET)$(TOOL_GCC3_LD) $(TOOL_GCC3_LDFLAGS.dll) $(flags) -o $(out)\
287 $(if $(filter-out win32 os2, $(BUILD_TARGET)),$(call TOOL_GCC3_LD_SONAME,$(target),$(out)))\
288 $(objs)\
289 $(filter %.def, $(othersrc))\
290 $(foreach p,$(libpath), -L$(p))\
291 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
292 $(call TOOL_GCC3_LD_MAP,$(outbase).map)
293endef
294
295
296## Link system module (windows aka driver, linux aka kernel module)
297# @param $(target) Normalized main target name.
298# @param $(out) System module name.
299# @param $(objs) Object files to link together.
300# @param $(libs) Libraries to search.
301# @param $(libpath) Library search paths.
302# @param $(flags) Flags.
303# @param $(dirdep) Directory creation dependency.
304# @param $(deps) Other dependencies.
305# @param $(othersrc) Unhandled sources.
306# @param $(custom_pre) Custom step invoked before linking.
307# @param $(custom_post) Custom step invoked after linking.
308# @param $(outbase) Output basename (full). Use this for list files and such.
309TOOL_GCC3_LINK_SYSMOD_OUTPUT = $(outbase).map
310TOOL_GCC3_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
311 $(filter %.def, $(othersrc))
312TOOL_GCC3_LINK_SYSMOD_DEPORD =
313define TOOL_GCC3_LINK_SYSMOD_CMDS
314 $(QUIET)$(TOOL_GCC3_LD_SYSMOD) $(TOOL_GCC3_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
315 $(filter %.def, $(othersrc))\
316 $(foreach p,$(libpath), -L$(p))\
317 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
318 $(call TOOL_GCC3_LD_SYSMOD_MAP,$(outbase).map)
319endef
320
Note: See TracBrowser for help on using the repository browser.