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