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

Last change on this file since 1570 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: GXX3.kmk 1547 2008-04-22 02:02:09Z 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-2008 knut st. osmundsen <bird-kBuild-spam@anduin.net>
8#
9#
10# This file is part of kBuild.
11#
12# kBuild is free software; you can redistribute it and/or modify
13# it under the terms of the GNU General Public License as published by
14# the Free Software Foundation; either version 2 of the License, or
15# (at your option) any later version.
16#
17# kBuild is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20# GNU General Public License for more details.
21#
22# You should have received a copy of the GNU General Public License
23# along with kBuild; if not, write to the Free Software
24# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25#
26#
27# As a special exception you are granted permission to include this file, via
28# the kmk include directive, as you wish without this in itself causing the
29# resulting makefile, program or whatever to be covered by the GPL license.
30# This exception does not however invalidate any other reasons why the makefile,
31# program, whatever should not be covered the GPL.
32#
33#
34
35TOOL_GXX3 := Generic GCC v3.2.x or later using the system GCC and Binutils, for building C++ code.
36
37# Tool Specific Properties
38TOOL_GXX3_CC ?= gcc$(HOSTSUFF_EXE)
39TOOL_GXX3_CXX ?= g++$(HOSTSUFF_EXE)
40TOOL_GXX3_AS ?= gcc$(HOSTSUFF_EXE)
41ifeq ($(KBUILD_TARGET),solaris)
42 TOOL_GXX3_AR ?= gar$(HOSTSUFF_EXE)
43else
44 TOOL_GXX3_AR ?= ar$(HOSTSUFF_EXE)
45endif
46ifeq ($(KBUILD_TARGET),os2)
47 TOOL_GXX3_AR_IMP ?= emximp$(HOSTSTUFF_EXE)
48else
49 TOOL_GXX3_AR_IMP ?= $(ECHO) not supported!
50endif
51TOOL_GXX3_LD ?= g++$(HOSTSUFF_EXE)
52TOOL_GXX3_LD_SYSMOD ?= ld$(HOSTSUFF_EXE)
53ifndef TOOL_GXX3_LDFLAGS.$(KBUILD_TARGET)
54 TOOL_GXX3_LDFLAGS.dll ?= -shared
55else
56 TOOL_GXX3_LDFLAGS.dll ?= $(TOOL_GXX3_LDFLAGS.$(KBUILD_TARGET))
57endif
58TOOL_GXX3_LDFLAGS.sysmod ?= -r
59TOOL_GXX3_LD_SONAME ?= -Wl,-soname=$(firstword $($(1)_SONAME.$(KBUILD_TARGET).$(KBUILD_TYPE)) $($(1)_SONAME.$(KBUILD_TARGET)) $($(1)_SONAME.$(KBUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
60ifeq ($(KBUILD_TARGET),os2)
61 TOOL_GXX3_LD_MAP ?= -Zmap=$(1)
62 TOOL_GXX3_LD_SYSMOD_MAP ?= -Zmap=$(1)
63endif
64ifdef SLKRUNS
65 TOOL_GXX3_CC += -fmessage-length=0
66 TOOL_GXX3_CXX += -fmessage-length=0
67endif
68
69# General Properties used by kBuild
70TOOL_GXX3_COBJSUFF ?= .o
71TOOL_GXX3_CFLAGS ?=
72TOOL_GXX3_CFLAGS.debug ?= -g
73TOOL_GXX3_CFLAGS.profile ?= -O2 #-g -pg
74TOOL_GXX3_CFLAGS.release ?= -O2
75TOOL_GXX3_CINCS ?=
76TOOL_GXX3_CDEFS ?=
77
78TOOL_GXX3_CXXOBJSUFF ?= .o
79TOOL_GXX3_CXXOBJSUFF ?= .o
80TOOL_GXX3_CXXFLAGS ?=
81TOOL_GXX3_CXXFLAGS.debug ?= -g
82TOOL_GXX3_CXXFLAGS.profile ?= -O2 #-g -pg
83TOOL_GXX3_CXXFLAGS.release ?= -O2
84TOOL_GXX3_CXXINCS ?=
85TOOL_GXX3_CXXDEFS ?=
86
87TOOL_GXX3_ASFLAGS ?= -x assembler-with-cpp
88TOOL_GXX3_ASFLAGS.debug ?= -g
89TOOL_GXX3_ASFLAGS.profile ?= -g
90TOOL_GXX3_ASOBJSUFF ?= .o
91
92TOOL_GXX3_ARFLAGS ?= cr
93TOOL_GXX3_ARLIBSUFF ?= .a
94
95TOOL_GXX3_LDFLAGS ?=
96TOOL_GXX3_LDFLAGS.debug ?= -g
97TOOL_GXX3_LDFLAGS.profile ?= -g
98
99
100## Compile C source.
101# @param $(target) Normalized main target name.
102# @param $(source) Source filename (relative).
103# @param $(obj) Object file name. This shall be (re)created by the compilation.
104# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
105# @param $(flags) Flags.
106# @param $(defs) Definitions. No -D or something.
107# @param $(incs) Includes. No -I or something.
108# @param $(dirdep) Directory creation dependency.
109# @param $(deps) Other dependencies.
110#
111# @param $(outbase) Output basename (full). Use this for list files and such.
112# @param $(objsuff) Object suffix.
113TOOL_GXX3_COMPILE_C_DEPEND =
114TOOL_GXX3_COMPILE_C_DEPORD =
115ifdef KBUILD_USE_KOBJCACHE
116TOOL_GXX3_COMPILE_C_USES_KOBJCACHE = 1
117TOOL_GXX3_COMPILE_C_OUTPUT = $(outbase).i
118define TOOL_GXX3_COMPILE_C_CMDS
119 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
120 --kObjCache-cpp $(outbase).i\
121 $(TOOL_GXX3_CC) -E -o -\
122 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
123 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
124 $(abspath $(source))\
125 --kObjCache-cc $(obj)\
126 $(TOOL_GXX3_CC) -c\
127 $(flags) -fpreprocessed -x c\
128 -o $(obj)\
129 -
130endef
131else # !KBUILD_USE_KOBJCACHE
132TOOL_GXX3_COMPILE_C_OUTPUT =
133define TOOL_GXX3_COMPILE_C_CMDS
134 $(QUIET)$(TOOL_GXX3_CC) -c\
135 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
136 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
137 -o $(obj)\
138 $(abspath $(source))
139endef
140endif # !KBUILD_USE_KOBJCACHE
141
142
143## Compile C++ source.
144# @param $(target) Normalized main target name.
145# @param $(source) Source filename (relative).
146# @param $(obj) Object file name. This shall be (re)created by the compilation.
147# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
148# @param $(flags) Flags.
149# @param $(defs) Definitions. No -D or something.
150# @param $(incs) Includes. No -I or something.
151# @param $(dirdep) Directory creation dependency.
152# @param $(deps) Other dependencies.
153# @param $(outbase) Output basename (full). Use this for list files and such.
154# @param $(objsuff) Object suffix.
155TOOL_GXX3_COMPILE_CXX_DEPEND =
156TOOL_GXX3_COMPILE_CXX_DEPORD =
157ifdef KBUILD_USE_KOBJCACHE
158TOOL_GXX3_COMPILE_CXX_USES_KOBJCACHE = 1
159TOOL_GXX3_COMPILE_CXX_OUTPUT = $(outbase).ii
160define TOOL_GXX3_COMPILE_CXX_CMDS
161 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
162 --kObjCache-cpp $(outbase).ii\
163 $(TOOL_GXX3_CXX) -E -o -\
164 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
165 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
166 $(abspath $(source))\
167 --kObjCache-cc $(obj)\
168 $(TOOL_GXX3_CXX) -c\
169 $(flags) -fpreprocessed -x c++\
170 -o $(obj)\
171 -
172endef
173else # !KBUILD_USE_KOBJCACHE
174TOOL_GXX3_COMPILE_CXX_OUTPUT =
175define TOOL_GXX3_COMPILE_CXX_CMDS
176 $(QUIET)$(TOOL_GXX3_CXX) -c\
177 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
178 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
179 -o $(obj)\
180 $(abspath $(source))
181endef
182endif # !KBUILD_USE_KOBJCACHE
183
184
185## Compile Assembly source.
186# @param $(target) Normalized main target name.
187# @param $(source) Source filename (relative).
188# @param $(obj) Object file name. This shall be (re)created by the compilation.
189# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
190# @param $(flags) Flags.
191# @param $(defs) Definitions. No -D or something.
192# @param $(incs) Includes. No -I or something.
193# @param $(dirdep) Directory creation dependency.
194# @param $(deps) Other dependencies.
195# @param $(outbase) Output basename (full). Use this for list files and such.
196# @param $(objsuff) Object suffix.
197#
198TOOL_GXX3_COMPILE_AS_OUTPUT =
199TOOL_GXX3_COMPILE_AS_DEPEND =
200TOOL_GXX3_COMPILE_AS_DEPORD =
201define TOOL_GXX3_COMPILE_AS_CMDS
202 $(QUIET)$(TOOL_GXX3_AS) -c\
203 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
204 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
205 -o $(obj)\
206 $(abspath $(source))
207endef
208
209
210## Link library
211# @param $(target) Normalized main target name.
212# @param $(out) Library name.
213# @param $(objs) Object files to put in the library.
214# @param $(flags) Flags.
215# @param $(dirdep) Directory creation dependency.
216# @param $(deps) Other dependencies.
217# @param $(othersrc) Unhandled sources.
218# @param $(outbase) Output basename (full). Use this for list files and such.
219TOOL_GXX3_LINK_LIBRARY_OUTPUT = $(out).ar-script
220TOOL_GXX3_LINK_LIBRARY_OUTPUT_MAYBE = $(outbase).imp.a
221TOOL_GXX3_LINK_LIBRARY_DEPEND = $(othersrc)
222TOOL_GXX3_LINK_LIBRARY_DEPORD =
223define TOOL_GXX3_LINK_LIBRARY_CMDS
224 $(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)'
225 $(QUIET)$(APPEND) -n $(out).ar-script \
226 $(foreach o,$(objs), 'ADDMOD $(o)') \
227 $(foreach o,$(filter-out %.def %.imp,$(othersrc)), 'ADDLIB $(o)')
228 $(if $(filter %.def %.imp,$(othersrc))\
229 ,$(TOOL_GXX3_AR_IMP) -o $(outbase).imp.a $(filter %.def %.imp,$(othersrc))\
230 $(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script 'ADDLIB $(outbase).imp.a')
231 $(QUIET)$(APPEND) $(out).ar-script 'SAVE'
232 $(QUIET)$(APPEND) $(out).ar-script 'END'
233 $(QUIET)$(REDIRECT) -rti $(out).ar-script -- $(TOOL_GXX3_AR) -M
234endef
235
236
237## Link program
238# @param $(target) Normalized main target name.
239# @param $(out) Program name.
240# @param $(objs) Object files to link together.
241# @param $(libs) Libraries to search.
242# @param $(libpath) Library search paths.
243# @param $(flags) Flags.
244# @param $(dirdep) Directory creation dependency.
245# @param $(deps) Other dependencies.
246# @param $(othersrc) Unhandled sources.
247# @param $(custom_pre) Custom step invoked before linking.
248# @param $(custom_post) Custom step invoked after linking.
249# @param $(outbase) Output basename (full). Use this for list files and such.
250TOOL_GXX3_LINK_PROGRAM_OUTPUT =
251TOOL_GXX3_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map
252TOOL_GXX3_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
253 $(filter %.def, $(othersrc))
254TOOL_GXX3_LINK_PROGRAM_DEPORD =
255define TOOL_GXX3_LINK_PROGRAM_CMDS
256 $(QUIET)$(TOOL_GXX3_LD) $(flags) -o $(out) $(objs)\
257 $(filter %.def, $(othersrc))\
258 $(foreach p,$(libpath), -L$(p))\
259 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
260 $(call TOOL_GXX3_LD_MAP,$(outbase).map)
261endef
262
263
264## Link DLL
265# @param $(target) Normalized main target name.
266# @param $(out) Program name.
267# @param $(objs) Object files to link together.
268# @param $(libs) Libraries to search.
269# @param $(libpath) Library search paths.
270# @param $(flags) Flags.
271# @param $(dirdep) Directory creation dependency.
272# @param $(deps) Other dependencies.
273# @param $(othersrc) Unhandled sources.
274# @param $(custom_pre) Custom step invoked before linking.
275# @param $(custom_post) Custom step invoked after linking.
276# @param $(outbase) Output basename (full). Use this for list files and such.
277TOOL_GXX3_LINK_DLL_OUTPUT =
278TOOL_GXX3_LINK_DLL_OUTPUT_MAYBE = $(outbase).map
279TOOL_GXX3_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
280 $(filter %.def, $(othersrc))
281TOOL_GXX3_LINK_DLL_DEPORD =
282define TOOL_GXX3_LINK_DLL_CMDS
283 $(QUIET)$(TOOL_GXX3_LD) $(TOOL_GXX3_LDFLAGS.dll) $(flags) -o $(out)\
284 $(if $(filter-out win32 os2, $(KBUILD_TARGET)),$(call TOOL_GXX3_LD_SONAME,$(target),$(out)))\
285 $(objs)\
286 $(filter %.def, $(othersrc))\
287 $(foreach p,$(libpath), -L$(p))\
288 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
289 $(call TOOL_GXX3_LD_MAP,$(outbase).map)
290endef
291
292
293## Link system module (windows aka driver, linux aka kernel module)
294# @param $(target) Normalized main target name.
295# @param $(out) System module name.
296# @param $(objs) Object files to link together.
297# @param $(libs) Libraries to search.
298# @param $(libpath) Library search paths.
299# @param $(flags) Flags.
300# @param $(dirdep) Directory creation dependency.
301# @param $(deps) Other dependencies.
302# @param $(othersrc) Unhandled sources.
303# @param $(custom_pre) Custom step invoked before linking.
304# @param $(custom_post) Custom step invoked after linking.
305# @param $(outbase) Output basename (full). Use this for list files and such.
306TOOL_GXX3_LINK_SYSMOD_OUTPUT =
307TOOL_GXX3_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map
308TOOL_GXX3_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
309 $(filter %.def, $(othersrc))
310TOOL_GXX3_LINK_SYSMOD_DEPORD =
311define TOOL_GXX3_LINK_SYSMOD_CMDS
312 $(QUIET)$(TOOL_GXX3_LD_SYSMOD) $(TOOL_GXX3_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
313 $(filter %.def, $(othersrc))\
314 $(foreach p,$(libpath), -L$(p))\
315 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
316 $(call TOOL_GXX3_LD_SYSMOD_MAP,$(outbase).map)
317endef
318
Note: See TracBrowser for help on using the repository browser.