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

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

Drop the .map files when using gcc, except of course, for OS/2.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 12.1 KB
Line 
1# $Id: GXX3.kmk 1612 2008-05-12 15:42: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)
63else
64 TOOL_GXX3_LD_MAP ?=
65 TOOL_GXX3_LD_SYSMOD_MAP ?=
66endif
67ifdef SLKRUNS
68 TOOL_GXX3_CC += -fmessage-length=0
69 TOOL_GXX3_CXX += -fmessage-length=0
70endif
71
72# General Properties used by kBuild
73TOOL_GXX3_COBJSUFF ?= .o
74TOOL_GXX3_CFLAGS ?=
75TOOL_GXX3_CFLAGS.debug ?= -g
76TOOL_GXX3_CFLAGS.profile ?= -O2 #-g -pg
77TOOL_GXX3_CFLAGS.release ?= -O2
78TOOL_GXX3_CINCS ?=
79TOOL_GXX3_CDEFS ?=
80
81TOOL_GXX3_CXXOBJSUFF ?= .o
82TOOL_GXX3_CXXOBJSUFF ?= .o
83TOOL_GXX3_CXXFLAGS ?=
84TOOL_GXX3_CXXFLAGS.debug ?= -g
85TOOL_GXX3_CXXFLAGS.profile ?= -O2 #-g -pg
86TOOL_GXX3_CXXFLAGS.release ?= -O2
87TOOL_GXX3_CXXINCS ?=
88TOOL_GXX3_CXXDEFS ?=
89
90TOOL_GXX3_ASFLAGS ?= -x assembler-with-cpp
91TOOL_GXX3_ASFLAGS.debug ?= -g
92TOOL_GXX3_ASFLAGS.profile ?= -g
93TOOL_GXX3_ASOBJSUFF ?= .o
94
95TOOL_GXX3_ARFLAGS ?= cr
96TOOL_GXX3_ARLIBSUFF ?= .a
97
98TOOL_GXX3_LDFLAGS ?=
99TOOL_GXX3_LDFLAGS.debug ?= -g
100TOOL_GXX3_LDFLAGS.profile ?= -g
101
102
103## Compile C source.
104# @param $(target) Normalized main target name.
105# @param $(source) Source filename (relative).
106# @param $(obj) Object file name. This shall be (re)created by the compilation.
107# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
108# @param $(flags) Flags.
109# @param $(defs) Definitions. No -D or something.
110# @param $(incs) Includes. No -I or something.
111# @param $(dirdep) Directory creation dependency.
112# @param $(deps) Other dependencies.
113#
114# @param $(outbase) Output basename (full). Use this for list files and such.
115# @param $(objsuff) Object suffix.
116TOOL_GXX3_COMPILE_C_DEPEND =
117TOOL_GXX3_COMPILE_C_DEPORD =
118ifdef KBUILD_USE_KOBJCACHE
119TOOL_GXX3_COMPILE_C_USES_KOBJCACHE = 1
120TOOL_GXX3_COMPILE_C_OUTPUT = $(outbase).i
121define TOOL_GXX3_COMPILE_C_CMDS
122 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
123 --kObjCache-cpp $(outbase).i\
124 $(TOOL_GXX3_CC) -E -o -\
125 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
126 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
127 $(abspath $(source))\
128 --kObjCache-cc $(obj)\
129 $(TOOL_GXX3_CC) -c\
130 $(flags) -fpreprocessed -x c\
131 -o $(obj)\
132 -
133endef
134else # !KBUILD_USE_KOBJCACHE
135TOOL_GXX3_COMPILE_C_OUTPUT =
136define TOOL_GXX3_COMPILE_C_CMDS
137 $(QUIET)$(TOOL_GXX3_CC) -c\
138 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
139 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
140 -o $(obj)\
141 $(abspath $(source))
142endef
143endif # !KBUILD_USE_KOBJCACHE
144
145
146## Compile C++ source.
147# @param $(target) Normalized main target name.
148# @param $(source) Source filename (relative).
149# @param $(obj) Object file name. This shall be (re)created by the compilation.
150# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
151# @param $(flags) Flags.
152# @param $(defs) Definitions. No -D or something.
153# @param $(incs) Includes. No -I or something.
154# @param $(dirdep) Directory creation dependency.
155# @param $(deps) Other dependencies.
156# @param $(outbase) Output basename (full). Use this for list files and such.
157# @param $(objsuff) Object suffix.
158TOOL_GXX3_COMPILE_CXX_DEPEND =
159TOOL_GXX3_COMPILE_CXX_DEPORD =
160ifdef KBUILD_USE_KOBJCACHE
161TOOL_GXX3_COMPILE_CXX_USES_KOBJCACHE = 1
162TOOL_GXX3_COMPILE_CXX_OUTPUT = $(outbase).ii
163define TOOL_GXX3_COMPILE_CXX_CMDS
164 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
165 --kObjCache-cpp $(outbase).ii\
166 $(TOOL_GXX3_CXX) -E -o -\
167 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
168 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
169 $(abspath $(source))\
170 --kObjCache-cc $(obj)\
171 $(TOOL_GXX3_CXX) -c\
172 $(flags) -fpreprocessed -x c++\
173 -o $(obj)\
174 -
175endef
176else # !KBUILD_USE_KOBJCACHE
177TOOL_GXX3_COMPILE_CXX_OUTPUT =
178define TOOL_GXX3_COMPILE_CXX_CMDS
179 $(QUIET)$(TOOL_GXX3_CXX) -c\
180 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
181 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
182 -o $(obj)\
183 $(abspath $(source))
184endef
185endif # !KBUILD_USE_KOBJCACHE
186
187
188## Compile Assembly source.
189# @param $(target) Normalized main target name.
190# @param $(source) Source filename (relative).
191# @param $(obj) Object file name. This shall be (re)created by the compilation.
192# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
193# @param $(flags) Flags.
194# @param $(defs) Definitions. No -D or something.
195# @param $(incs) Includes. No -I or something.
196# @param $(dirdep) Directory creation dependency.
197# @param $(deps) Other dependencies.
198# @param $(outbase) Output basename (full). Use this for list files and such.
199# @param $(objsuff) Object suffix.
200#
201TOOL_GXX3_COMPILE_AS_OUTPUT =
202TOOL_GXX3_COMPILE_AS_DEPEND =
203TOOL_GXX3_COMPILE_AS_DEPORD =
204define TOOL_GXX3_COMPILE_AS_CMDS
205 $(QUIET)$(TOOL_GXX3_AS) -c\
206 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
207 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
208 -o $(obj)\
209 $(abspath $(source))
210endef
211
212
213## Link library
214# @param $(target) Normalized main target name.
215# @param $(out) Library name.
216# @param $(objs) Object files to put in the library.
217# @param $(flags) Flags.
218# @param $(dirdep) Directory creation dependency.
219# @param $(deps) Other dependencies.
220# @param $(othersrc) Unhandled sources.
221# @param $(outbase) Output basename (full). Use this for list files and such.
222TOOL_GXX3_LINK_LIBRARY_OUTPUT = $(out).ar-script
223TOOL_GXX3_LINK_LIBRARY_OUTPUT_MAYBE = $(outbase).imp.a
224TOOL_GXX3_LINK_LIBRARY_DEPEND = $(othersrc)
225TOOL_GXX3_LINK_LIBRARY_DEPORD =
226define TOOL_GXX3_LINK_LIBRARY_CMDS
227 $(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)'
228 $(QUIET)$(APPEND) -n $(out).ar-script \
229 $(foreach o,$(objs), 'ADDMOD $(o)') \
230 $(foreach o,$(filter-out %.def %.imp,$(othersrc)), 'ADDLIB $(o)')
231 $(if $(filter %.def %.imp,$(othersrc))\
232 ,$(TOOL_GXX3_AR_IMP) -o $(outbase).imp.a $(filter %.def %.imp,$(othersrc))\
233 $(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script 'ADDLIB $(outbase).imp.a')
234 $(QUIET)$(APPEND) $(out).ar-script 'SAVE'
235 $(QUIET)$(APPEND) $(out).ar-script 'END'
236 $(QUIET)$(REDIRECT) -rti $(out).ar-script -- $(TOOL_GXX3_AR) -M
237endef
238
239
240## Link program
241# @param $(target) Normalized main target name.
242# @param $(out) Program name.
243# @param $(objs) Object files to link together.
244# @param $(libs) Libraries to search.
245# @param $(libpath) Library search paths.
246# @param $(flags) Flags.
247# @param $(dirdep) Directory creation dependency.
248# @param $(deps) Other dependencies.
249# @param $(othersrc) Unhandled sources.
250# @param $(custom_pre) Custom step invoked before linking.
251# @param $(custom_post) Custom step invoked after linking.
252# @param $(outbase) Output basename (full). Use this for list files and such.
253TOOL_GXX3_LINK_PROGRAM_OUTPUT =
254TOOL_GXX3_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map
255TOOL_GXX3_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
256 $(filter %.def, $(othersrc))
257TOOL_GXX3_LINK_PROGRAM_DEPORD =
258define TOOL_GXX3_LINK_PROGRAM_CMDS
259 $(QUIET)$(TOOL_GXX3_LD) $(flags) -o $(out) $(objs)\
260 $(filter %.def, $(othersrc))\
261 $(foreach p,$(libpath), -L$(p))\
262 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
263 $(call TOOL_GXX3_LD_MAP,$(outbase).map)
264endef
265
266
267## Link DLL
268# @param $(target) Normalized main target name.
269# @param $(out) Program name.
270# @param $(objs) Object files to link together.
271# @param $(libs) Libraries to search.
272# @param $(libpath) Library search paths.
273# @param $(flags) Flags.
274# @param $(dirdep) Directory creation dependency.
275# @param $(deps) Other dependencies.
276# @param $(othersrc) Unhandled sources.
277# @param $(custom_pre) Custom step invoked before linking.
278# @param $(custom_post) Custom step invoked after linking.
279# @param $(outbase) Output basename (full). Use this for list files and such.
280TOOL_GXX3_LINK_DLL_OUTPUT =
281TOOL_GXX3_LINK_DLL_OUTPUT_MAYBE = $(outbase).map
282TOOL_GXX3_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
283 $(filter %.def, $(othersrc))
284TOOL_GXX3_LINK_DLL_DEPORD =
285define TOOL_GXX3_LINK_DLL_CMDS
286 $(QUIET)$(TOOL_GXX3_LD) $(TOOL_GXX3_LDFLAGS.dll) $(flags) -o $(out)\
287 $(if $(filter-out win32 os2, $(KBUILD_TARGET)),$(call TOOL_GXX3_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%,%,$(lib)), $(lib)))\
292 $(call TOOL_GXX3_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_GXX3_LINK_SYSMOD_OUTPUT =
310TOOL_GXX3_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map
311TOOL_GXX3_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
312 $(filter %.def, $(othersrc))
313TOOL_GXX3_LINK_SYSMOD_DEPORD =
314define TOOL_GXX3_LINK_SYSMOD_CMDS
315 $(QUIET)$(TOOL_GXX3_LD_SYSMOD) $(TOOL_GXX3_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
316 $(filter %.def, $(othersrc))\
317 $(foreach p,$(libpath), -L$(p))\
318 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
319 $(call TOOL_GXX3_LD_SYSMOD_MAP,$(outbase).map)
320endef
321
Note: See TracBrowser for help on using the repository browser.