*: Updated copyright to 2009 and normalized name & email.
[kbuild-mirror.git] / kBuild / tools / GCC3.kmk
blob0c41a36ee94cb9cac1c1fb48bff00ae183bbccd6
1 # $Id$
2 ## @file
3 # kBuild Tool Config - Generic GCC v3.2.x or later Using The System GCC and Binutils.
7 # Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net>
9 # This file is part of kBuild.
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.
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.
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
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.
34 TOOL_GCC3 := Generic GCC v3.2.x or later Using The System GCC and Binutils.
36 # Tool Specific Properties
37 TOOL_GCC3_CC ?= gcc$(HOSTSUFF_EXE)
38 TOOL_GCC3_CXX ?= g++$(HOSTSUFF_EXE)
39 TOOL_GCC3_AS ?= gcc$(HOSTSUFF_EXE)
40 ifeq ($(KBUILD_TARGET),solaris) ## @todo drop the MRI script!
41 TOOL_GCC3_AR ?= gar$(HOSTSUFF_EXE)
42 else
43 TOOL_GCC3_AR ?= ar$(HOSTSUFF_EXE)
44 endif
45 ifeq ($(KBUILD_TARGET),os2)
46 TOOL_GCC3_AR_IMP ?= emximp$(HOSTSTUFF_EXE)
47 else
48 TOOL_GCC3_AR_IMP ?= $(ECHO) not supported!
49 endif
50 TOOL_GCC3_LD ?= gcc$(HOSTSUFF_EXE)
51 TOOL_GCC3_LD_SYSMOD ?= ld$(HOSTSUFF_EXE)
52 ifndef TOOL_GCC3_LDFLAGS.$(KBUILD_TARGET)
53 TOOL_GCC3_LDFLAGS.dll ?= -shared
54 else
55 TOOL_GCC3_LDFLAGS.dll ?= $(TOOL_GCC3_LDFLAGS.$(KBUILD_TARGET))
56 endif
57 TOOL_GCC3_LDFLAGS.sysmod ?= -r
58 TOOL_GCC3_LD_SONAME ?= -Wl,-soname=$(firstword $($(1)_SONAME.$(KBUILD_TARGET).$(KBUILD_TYPE)) $($(1)_SONAME.$(KBUILD_TARGET)) $($(1)_SONAME.$(KBUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
59 ifeq ($(KBUILD_TARGET),os2)
60 TOOL_GCC3_LD_MAP ?= -Zmap=$(1)
61 TOOL_GCC3_LD_SYSMOD_MAP ?= -Zmap=$(1)
62 else
63 TOOL_GCC3_LD_MAP ?=
64 TOOL_GCC3_LD_SYSMOD_MAP ?=
65 endif
66 ifdef SLKRUNS
67 TOOL_GCC3_CC += -fmessage-length=0
68 TOOL_GCC3_CXX += -fmessage-length=0
69 endif
71 # General Properties used by kBuild
72 TOOL_GCC3_COBJSUFF ?= .o
73 TOOL_GCC3_CFLAGS ?=
74 TOOL_GCC3_CFLAGS.debug ?= -g
75 TOOL_GCC3_CFLAGS.profile ?= -O2 #-g -pg
76 TOOL_GCC3_CFLAGS.release ?= -O2
77 TOOL_GCC3_CINCS ?=
78 TOOL_GCC3_CDEFS ?=
80 TOOL_GCC3_CXXOBJSUFF ?= .o
81 TOOL_GCC3_CXXOBJSUFF ?= .o
82 TOOL_GCC3_CXXFLAGS ?=
83 TOOL_GCC3_CXXFLAGS.debug ?= -g
84 TOOL_GCC3_CXXFLAGS.profile ?= -O2 #-g -pg
85 TOOL_GCC3_CXXFLAGS.release ?= -O2
86 TOOL_GCC3_CXXINCS ?=
87 TOOL_GCC3_CXXDEFS ?=
89 TOOL_GCC3_ASFLAGS ?= -x assembler-with-cpp
90 TOOL_GCC3_ASFLAGS.debug ?= -g
91 TOOL_GCC3_ASFLAGS.profile ?= -g
92 TOOL_GCC3_ASOBJSUFF ?= .o
94 TOOL_GCC3_ARFLAGS ?= cr
95 TOOL_GCC3_ARLIBSUFF ?= .a
97 TOOL_GCC3_LDFLAGS ?=
98 TOOL_GCC3_LDFLAGS.debug ?= -g
99 TOOL_GCC3_LDFLAGS.profile ?= -g
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.
113 # @param $(outbase) Output basename (full). Use this for list files and such.
114 # @param $(objsuff) Object suffix.
115 TOOL_GCC3_COMPILE_C_DEPEND =
116 TOOL_GCC3_COMPILE_C_DEPORD =
117 ifdef KBUILD_USE_KOBJCACHE
118 TOOL_GCC3_COMPILE_C_USES_KOBJCACHE = 1
119 TOOL_GCC3_COMPILE_C_OUTPUT = $(outbase).i
120 define TOOL_GCC3_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_GCC3_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_GCC3_CC) -c\
129 $(flags) -fpreprocessed -x c\
130 -o $(obj)\
132 endef
133 else # !KBUILD_USE_KOBJCACHE
134 TOOL_GCC3_COMPILE_C_OUTPUT =
135 define TOOL_GCC3_COMPILE_C_CMDS
136 $(QUIET)$(TOOL_GCC3_CC) -c\
137 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
138 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
139 -o $(obj)\
140 $(abspath $(source))
141 endef
142 endif # !KBUILD_USE_KOBJCACHE
145 ## Compile C++ source.
146 # @param $(target) Normalized main target name.
147 # @param $(source) Source filename (relative).
148 # @param $(obj) Object file name. This shall be (re)created by the compilation.
149 # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
150 # @param $(flags) Flags.
151 # @param $(defs) Definitions. No -D or something.
152 # @param $(incs) Includes. No -I or something.
153 # @param $(dirdep) Directory creation dependency.
154 # @param $(deps) Other dependencies.
155 # @param $(outbase) Output basename (full). Use this for list files and such.
156 # @param $(objsuff) Object suffix.
157 TOOL_GCC3_COMPILE_CXX_DEPEND =
158 TOOL_GCC3_COMPILE_CXX_DEPORD =
159 ifdef KBUILD_USE_KOBJCACHE
160 TOOL_GCC3_COMPILE_CXX_USES_KOBJCACHE = 1
161 TOOL_GCC3_COMPILE_CXX_OUTPUT = $(outbase).ii
162 define TOOL_GCC3_COMPILE_CXX_CMDS
163 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
164 --kObjCache-cpp $(outbase).ii\
165 $(TOOL_GCC3_CXX) -E -o -\
166 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
167 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
168 $(abspath $(source))\
169 --kObjCache-cc $(obj)\
170 $(TOOL_GCC3_CXX) -c\
171 $(flags) -fpreprocessed -x c++\
172 -o $(obj)\
174 endef
175 else # !KBUILD_USE_KOBJCACHE
176 TOOL_GCC3_COMPILE_CXX_OUTPUT =
177 define TOOL_GCC3_COMPILE_CXX_CMDS
178 $(QUIET)$(TOOL_GCC3_CXX) -c\
179 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
180 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
181 -o $(obj)\
182 $(abspath $(source))
183 endef
184 endif # !KBUILD_USE_KOBJCACHE
187 ## Compile Assembly source.
188 # @param $(target) Normalized main target name.
189 # @param $(source) Source filename (relative).
190 # @param $(obj) Object file name. This shall be (re)created by the compilation.
191 # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
192 # @param $(flags) Flags.
193 # @param $(defs) Definitions. No -D or something.
194 # @param $(incs) Includes. No -I or something.
195 # @param $(dirdep) Directory creation dependency.
196 # @param $(deps) Other dependencies.
197 # @param $(outbase) Output basename (full). Use this for list files and such.
198 # @param $(objsuff) Object suffix.
200 TOOL_GCC3_COMPILE_AS_OUTPUT =
201 TOOL_GCC3_COMPILE_AS_DEPEND =
202 TOOL_GCC3_COMPILE_AS_DEPORD =
203 define TOOL_GCC3_COMPILE_AS_CMDS
204 $(QUIET)$(TOOL_GCC3_AS) -c\
205 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
206 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
207 -o $(obj)\
208 $(abspath $(source))
209 endef
212 ## Link library
213 # @param $(target) Normalized main target name.
214 # @param $(out) Library name.
215 # @param $(objs) Object files to put in the library.
216 # @param $(flags) Flags.
217 # @param $(dirdep) Directory creation dependency.
218 # @param $(deps) Other dependencies.
219 # @param $(othersrc) Unhandled sources.
220 # @param $(outbase) Output basename (full). Use this for list files and such.
221 TOOL_GCC3_LINK_LIBRARY_OUTPUT = $(out).ar-script
222 TOOL_GCC3_LINK_LIBRARY_OUTPUT_MAYBE = $(outbase).imp.a
223 TOOL_GCC3_LINK_LIBRARY_DEPEND = $(othersrc)
224 TOOL_GCC3_LINK_LIBRARY_DEPORD =
225 define TOOL_GCC3_LINK_LIBRARY_CMDS
226 $(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)'
227 $(QUIET)$(APPEND) -n $(out).ar-script \
228 $(foreach o,$(objs), 'ADDMOD $(o)') \
229 $(foreach o,$(filter-out %.def %.imp,$(othersrc)), 'ADDLIB $(o)')
230 $(if $(filter %.def %.imp,$(othersrc))\
231 ,$(TOOL_GCC3_AR_IMP) -o $(outbase).imp.a $(filter %.def %.imp,$(othersrc))\
232 $(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script 'ADDLIB $(outbase).imp.a')
233 $(QUIET)$(APPEND) $(out).ar-script 'SAVE'
234 $(QUIET)$(APPEND) $(out).ar-script 'END'
235 $(QUIET)$(REDIRECT) -rti $(out).ar-script -- $(TOOL_GCC3_AR) -M
236 endef
239 ## Link program
240 # @param $(target) Normalized main target name.
241 # @param $(out) Program name.
242 # @param $(objs) Object files to link together.
243 # @param $(libs) Libraries to search.
244 # @param $(libpath) Library search paths.
245 # @param $(flags) Flags.
246 # @param $(dirdep) Directory creation dependency.
247 # @param $(deps) Other dependencies.
248 # @param $(othersrc) Unhandled sources.
249 # @param $(custom_pre) Custom step invoked before linking.
250 # @param $(custom_post) Custom step invoked after linking.
251 # @param $(outbase) Output basename (full). Use this for list files and such.
252 TOOL_GCC3_LINK_PROGRAM_OUTPUT =
253 TOOL_GCC3_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map
254 TOOL_GCC3_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
255 $(filter %.def, $(othersrc))
256 TOOL_GCC3_LINK_PROGRAM_DEPORD =
257 define TOOL_GCC3_LINK_PROGRAM_CMDS
258 $(QUIET)$(TOOL_GCC3_LD) $(flags) -o $(out) $(objs)\
259 $(filter %.def, $(othersrc))\
260 $(foreach p,$(libpath), -L$(p))\
261 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
262 $(call TOOL_GCC3_LD_MAP,$(outbase).map)
263 endef
266 ## Link DLL
267 # @param $(target) Normalized main target name.
268 # @param $(out) Program name.
269 # @param $(objs) Object files to link together.
270 # @param $(libs) Libraries to search.
271 # @param $(libpath) Library search paths.
272 # @param $(flags) Flags.
273 # @param $(dirdep) Directory creation dependency.
274 # @param $(deps) Other dependencies.
275 # @param $(othersrc) Unhandled sources.
276 # @param $(custom_pre) Custom step invoked before linking.
277 # @param $(custom_post) Custom step invoked after linking.
278 # @param $(outbase) Output basename (full). Use this for list files and such.
279 TOOL_GCC3_LINK_DLL_OUTPUT =
280 TOOL_GCC3_LINK_DLL_OUTPUT_MAYBE = $(outbase).map
281 TOOL_GCC3_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
282 $(filter %.def, $(othersrc))
283 TOOL_GCC3_LINK_DLL_DEPORD =
284 define TOOL_GCC3_LINK_DLL_CMDS
285 $(QUIET)$(TOOL_GCC3_LD) $(TOOL_GCC3_LDFLAGS.dll) $(flags) -o $(out)\
286 $(if $(filter-out win32 os2, $(KBUILD_TARGET)),$(call TOOL_GCC3_LD_SONAME,$(target),$(out)))\
287 $(objs)\
288 $(filter %.def, $(othersrc))\
289 $(foreach p,$(libpath), -L$(p))\
290 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
291 $(call TOOL_GCC3_LD_MAP,$(outbase).map)
292 endef
295 ## Link system module (windows aka driver, linux aka kernel module)
296 # @param $(target) Normalized main target name.
297 # @param $(out) System module name.
298 # @param $(objs) Object files to link together.
299 # @param $(libs) Libraries to search.
300 # @param $(libpath) Library search paths.
301 # @param $(flags) Flags.
302 # @param $(dirdep) Directory creation dependency.
303 # @param $(deps) Other dependencies.
304 # @param $(othersrc) Unhandled sources.
305 # @param $(custom_pre) Custom step invoked before linking.
306 # @param $(custom_post) Custom step invoked after linking.
307 # @param $(outbase) Output basename (full). Use this for list files and such.
308 TOOL_GCC3_LINK_SYSMOD_OUTPUT =
309 TOOL_GCC3_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map
310 TOOL_GCC3_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
311 $(filter %.def, $(othersrc))
312 TOOL_GCC3_LINK_SYSMOD_DEPORD =
313 define 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%,%,$(lib)), $(lib)))\
318 $(call TOOL_GCC3_LD_SYSMOD_MAP,$(outbase).map)
319 endef