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

Last change on this file since 1013 was 971, checked in by bird, 18 years ago

GCC -> GXX. (the GCC is going to do plain C linking using gcc instead of g++ to fix these incorrect dependencies on the C++ RT when linking C progs.)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 11.1 KB
Line 
1# $Id: GXX3.kmk 971 2007-05-27 16:45:22Z bird $
2## @file
3#
4# kBuild Tool Config - Generic GCC v3.2.x using the system GCC and Binutils, for building C++ code.
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_GXX3 := Generic GCC v3.2.x or later using the system GCC and Binutils, for building C++ code.
28
29# Tool Specific Properties
30TOOL_GXX3_CC ?= gcc$(HOSTSUFF_EXE)
31TOOL_GXX3_CXX ?= g++$(HOSTSUFF_EXE)
32TOOL_GXX3_AS ?= gcc$(HOSTSUFF_EXE)
33ifeq ($(BUILD_TARGET),solaris)
34 TOOL_GXX3_AR ?= gar$(HOSTSUFF_EXE)
35else
36 TOOL_GXX3_AR ?= ar$(HOSTSUFF_EXE)
37endif
38ifeq ($(BUILD_TARGET),os2)
39 TOOL_GXX3_AR_IMP ?= emximp$(HOSTSTUFF_EXE)
40else
41 TOOL_GXX3_AR_IMP ?= $(ECHO) not supported!
42endif
43TOOL_GXX3_LD ?= g++$(HOSTSUFF_EXE)
44TOOL_GXX3_LD_SYSMOD ?= ld$(HOSTSUFF_EXE)
45ifndef TOOL_GXX3_LDFLAGS.$(BUILD_TARGET)
46 TOOL_GXX3_LDFLAGS.dll ?= -shared
47else
48 TOOL_GXX3_LDFLAGS.dll ?= $(TOOL_GXX3_LDFLAGS.$(BUILD_TARGET))
49endif
50TOOL_GXX3_LDFLAGS.sysmod ?= -r
51TOOL_GXX3_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_GXX3_LD_MAP ?= -Zmap=$(1)
54 TOOL_GXX3_LD_SYSMOD_MAP ?= -Zmap=$(1)
55endif
56ifdef SLKRUNS
57 TOOL_GXX3_CC += -fmessage-length=0
58 TOOL_GXX3_CXX += -fmessage-length=0
59endif
60
61# General Properties used by kBuild
62TOOL_GXX3_COBJSUFF ?= .o
63TOOL_GXX3_CFLAGS ?=
64TOOL_GXX3_CFLAGS.debug ?= -g
65TOOL_GXX3_CFLAGS.profile ?= -g -O2 #-pg
66TOOL_GXX3_CFLAGS.release ?= -O2
67TOOL_GXX3_CINCS ?=
68TOOL_GXX3_CDEFS ?=
69
70TOOL_GXX3_CXXOBJSUFF ?= .o
71TOOL_GXX3_CXXOBJSUFF ?= .o
72TOOL_GXX3_CXXFLAGS ?=
73TOOL_GXX3_CXXFLAGS.debug ?= -g
74TOOL_GXX3_CXXFLAGS.profile ?= -g -O2 #-pg
75TOOL_GXX3_CXXFLAGS.release ?= -O2
76TOOL_GXX3_CXXINCS ?=
77TOOL_GXX3_CXXDEFS ?=
78
79TOOL_GXX3_ASFLAGS ?= -x assembler-with-cpp
80TOOL_GXX3_ASFLAGS.debug ?= -g
81TOOL_GXX3_ASFLAGS.profile ?= -g
82TOOL_GXX3_ASOBJSUFF ?= .o
83
84TOOL_GXX3_ARFLAGS ?= cr
85TOOL_GXX3_ARLIBSUFF ?= .a
86
87TOOL_GXX3_LDFLAGS ?=
88TOOL_GXX3_LDFLAGS.debug ?= -g
89TOOL_GXX3_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_GXX3_COMPILE_C_OUTPUT =
106TOOL_GXX3_COMPILE_C_DEPEND =
107TOOL_GXX3_COMPILE_C_DEPORD =
108define TOOL_GXX3_COMPILE_C_CMDS
109 $(QUIET)$(TOOL_GXX3_CC) -c\
110 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
111 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
112 -o $(obj)\
113 $(abspath $(source))
114endef
115
116
117## Compile C++ source.
118# @param $(target) Normalized main target name.
119# @param $(source) Source filename (relative).
120# @param $(obj) Object file name. This shall be (re)created by the compilation.
121# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
122# @param $(flags) Flags.
123# @param $(defs) Definitions. No -D or something.
124# @param $(incs) Includes. No -I or something.
125# @param $(dirdep) Directory creation dependency.
126# @param $(deps) Other dependencies.
127# @param $(outbase) Output basename (full). Use this for list files and such.
128# @param $(objsuff) Object suffix.
129TOOL_GXX3_COMPILE_CXX_OUTPUT =
130TOOL_GXX3_COMPILE_CXX_DEPEND =
131TOOL_GXX3_COMPILE_CXX_DEPORD =
132define TOOL_GXX3_COMPILE_CXX_CMDS
133 $(QUIET)$(TOOL_GXX3_CXX) -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
139
140
141## Compile Assembly source.
142# @param $(target) Normalized main target name.
143# @param $(source) Source filename (relative).
144# @param $(obj) Object file name. This shall be (re)created by the compilation.
145# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
146# @param $(flags) Flags.
147# @param $(defs) Definitions. No -D or something.
148# @param $(incs) Includes. No -I or something.
149# @param $(dirdep) Directory creation dependency.
150# @param $(deps) Other dependencies.
151# @param $(outbase) Output basename (full). Use this for list files and such.
152# @param $(objsuff) Object suffix.
153#
154TOOL_GXX3_COMPILE_AS_OUTPUT =
155TOOL_GXX3_COMPILE_AS_DEPEND =
156TOOL_GXX3_COMPILE_AS_DEPORD =
157define TOOL_GXX3_COMPILE_AS_CMDS
158 $(QUIET)$(TOOL_GXX3_AS) -c\
159 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
160 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
161 -o $(obj)\
162 $(abspath $(source))
163endef
164
165
166## Link library
167# @param $(target) Normalized main target name.
168# @param $(out) Library name.
169# @param $(objs) Object files to put in the library.
170# @param $(flags) Flags.
171# @param $(dirdep) Directory creation dependency.
172# @param $(deps) Other dependencies.
173# @param $(othersrc) Unhandled sources.
174# @param $(outbase) Output basename (full). Use this for list files and such.
175TOOL_GXX3_LINK_LIBRARY_OUTPUT = $(out).ar-script $(outbase).imp.a
176TOOL_GXX3_LINK_LIBRARY_DEPEND = $(othersrc)
177TOOL_GXX3_LINK_LIBRARY_DEPORD =
178ifeq ($(filter append-dash-n,$(KMK_FEATURES)),append-dash-n)
179define TOOL_GXX3_LINK_LIBRARY_CMDS
180 $(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)'
181 $(QUIET)$(APPEND) -n $(out).ar-script \
182 $(foreach o,$(objs), 'ADDMOD $(o)') \
183 $(foreach o,$(filter-out %.def %.imp,$(othersrc)), 'ADDLIB $(o)')
184 $(if $(filter %.def %.imp,$(othersrc))\
185 ,$(TOOL_GXX3_AR_IMP) -o $(outbase).imp.a $(filter %.def %.imp,$(othersrc))\
186 $(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script 'ADDLIB $(outbase).imp.a')
187 $(QUIET)$(APPEND) $(out).ar-script 'SAVE'
188 $(QUIET)$(APPEND) $(out).ar-script 'END'
189 $(QUIET)$(TOOL_GXX3_AR) -M < $(out).ar-script
190endef
191else
192define TOOL_GXX3_LINK_LIBRARY_CMDS
193 $(QUIET)$(APPEND) $(out).ar-script "CREATE $(out)"
194 $(foreach o, $(objs)\
195 ,$(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script "ADDMOD $(o)")
196 $(foreach srclib, $(filter-out %.def %.imp,$(othersrc))\
197 ,$(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script "ADDLIB $(srclib)")
198 $(if $(filter %.def %.imp,$(othersrc))\
199 ,$(TOOL_GXX3_AR_IMP) -o $(outbase).imp.a $(filter %.def %.imp,$(othersrc))\
200 $(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script "ADDLIB $(outbase).imp.a")
201 $(QUIET)$(APPEND) $(out).ar-script "SAVE"
202 $(QUIET)$(APPEND) $(out).ar-script "END"
203 $(QUIET)$(TOOL_GXX3_AR) -M < $(out).ar-script
204endef
205endif
206
207
208## Link program
209# @param $(target) Normalized main target name.
210# @param $(out) Program name.
211# @param $(objs) Object files to link together.
212# @param $(libs) Libraries to search.
213# @param $(libpath) Library search paths.
214# @param $(flags) Flags.
215# @param $(dirdep) Directory creation dependency.
216# @param $(deps) Other dependencies.
217# @param $(othersrc) Unhandled sources.
218# @param $(custom_pre) Custom step invoked before linking.
219# @param $(custom_post) Custom step invoked after linking.
220# @param $(outbase) Output basename (full). Use this for list files and such.
221TOOL_GXX3_LINK_PROGRAM_OUTPUT = $(outbase).map
222TOOL_GXX3_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
223 $(filter %.def, $(othersrc))
224TOOL_GXX3_LINK_PROGRAM_DEPORD =
225define TOOL_GXX3_LINK_PROGRAM_CMDS
226 $(QUIET)$(TOOL_GXX3_LD) $(flags) -o $(out) $(objs)\
227 $(filter %.def, $(othersrc))\
228 $(foreach p,$(libpath), -L$(p))\
229 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
230 $(call TOOL_GXX3_LD_MAP,$(outbase).map)
231endef
232
233
234## Link DLL
235# @param $(target) Normalized main target name.
236# @param $(out) Program name.
237# @param $(objs) Object files to link together.
238# @param $(libs) Libraries to search.
239# @param $(libpath) Library search paths.
240# @param $(flags) Flags.
241# @param $(dirdep) Directory creation dependency.
242# @param $(deps) Other dependencies.
243# @param $(othersrc) Unhandled sources.
244# @param $(custom_pre) Custom step invoked before linking.
245# @param $(custom_post) Custom step invoked after linking.
246# @param $(outbase) Output basename (full). Use this for list files and such.
247TOOL_GXX3_LINK_DLL_OUTPUT = $(outbase).map
248TOOL_GXX3_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
249 $(filter %.def, $(othersrc))
250TOOL_GXX3_LINK_DLL_DEPORD =
251define TOOL_GXX3_LINK_DLL_CMDS
252 $(QUIET)$(TOOL_GXX3_LD) $(TOOL_GXX3_LDFLAGS.dll) $(flags) -o $(out)\
253 $(if $(filter-out win32 os2, $(BUILD_TARGET)),$(call TOOL_GXX3_LD_SONAME,$(target),$(out)))\
254 $(objs)\
255 $(filter %.def, $(othersrc))\
256 $(foreach p,$(libpath), -L$(p))\
257 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
258 $(call TOOL_GXX3_LD_MAP,$(outbase).map)
259endef
260
261
262## Link system module (windows aka driver, linux aka kernel module)
263# @param $(target) Normalized main target name.
264# @param $(out) System module name.
265# @param $(objs) Object files to link together.
266# @param $(libs) Libraries to search.
267# @param $(libpath) Library search paths.
268# @param $(flags) Flags.
269# @param $(dirdep) Directory creation dependency.
270# @param $(deps) Other dependencies.
271# @param $(othersrc) Unhandled sources.
272# @param $(custom_pre) Custom step invoked before linking.
273# @param $(custom_post) Custom step invoked after linking.
274# @param $(outbase) Output basename (full). Use this for list files and such.
275TOOL_GXX3_LINK_SYSMOD_OUTPUT = $(outbase).map
276TOOL_GXX3_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
277 $(filter %.def, $(othersrc))
278TOOL_GXX3_LINK_SYSMOD_DEPORD =
279define TOOL_GXX3_LINK_SYSMOD_CMDS
280 $(QUIET)$(TOOL_GXX3_LD_SYSMOD) $(TOOL_GXX3_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
281 $(filter %.def, $(othersrc))\
282 $(foreach p,$(libpath), -L$(p))\
283 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
284 $(call TOOL_GXX3_LD_SYSMOD_MAP,$(outbase).map)
285endef
286
Note: See TracBrowser for help on using the repository browser.