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

Last change on this file since 1566 was 1547, checked in by bird, 17 years ago

License clearification.

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