3 # kBuild Tool Config - Generic GCC v3.2.x or later using the system GCC, any Unix linker and Unix archiver to build C++ code.
7 # Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net>
9 # This file is part of kBuild.
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.
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.
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
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.
34 TOOL_GXX3PLAIN
:= Generic GCC v3.2.x or later using the system GCC
, any Unix linker and Unix archiver to build C
++ code.
36 # Tool Specific Properties
37 TOOL_GXX3PLAIN_CC ?
= gcc
$(HOSTSUFF_EXE
)
38 TOOL_GXX3PLAIN_CXX ?
= g
++$(HOSTSUFF_EXE
)
39 TOOL_GXX3PLAIN_AS ?
= gcc
$(HOSTSUFF_EXE
)
40 TOOL_GXX3PLAIN_AR ?
= ar$(HOSTSUFF_EXE
)
41 TOOL_GXX3PLAIN_RANLIB ?
= ranlib
$(HOSTSUFF_EXE
)
42 TOOL_GXX3PLAIN_LD ?
= g
++$(HOSTSUFF_EXE
)
43 TOOL_GXX3PLAIN_LD_SYSMOD ?
= ld$(HOSTSUFF_EXE
)
44 TOOL_GXX3PLAIN_LD_SYSMOD.os2 ?
= g
++$(HOSTSUFF_EXE
)
45 TOOL_GXX3PLAIN_LDFLAGS.dll.os2 ?
= -Zdll
46 TOOL_GXX3PLAIN_LDFLAGS.dll.darwin ?
= -dynamiclib
47 ifndef TOOL_GXX3PLAIN_LDFLAGS.
$(KBUILD_TARGET
)
48 TOOL_GXX3PLAIN_LDFLAGS.dll ?
= -shared
50 TOOL_GXX3PLAIN_LDFLAGS.dll ?
= $(TOOL_GXX3PLAIN_LDFLAGS.
$(KBUILD_TARGET
))
52 TOOL_GXX3PLAIN_LD_SONAME.darwin ?
= $(NO_SUCH_VARIABLE
)
53 TOOL_GXX3PLAIN_LD_SONAME.os2 ?
= $(NO_SUCH_VARIABLE
)
54 TOOL_GXX3PLAIN_LD_SONAME.solaris ?
= -Wl
,-h
,$(firstword $($(1)_SONAME.
$(KBUILD_TARGET
).
$(KBUILD_TYPE
)) $($(1)_SONAME.
$(KBUILD_TARGET
)) $($(1)_SONAME.
$(KBUILD_TYPE
)) $($(1)_SONAME
) $(notdir $(2)))
55 TOOL_GXX3PLAIN_LD_SONAME.win ?
= $(NO_SUCH_VARIABLE
)
56 ifndef TOOL_GXX3PLAIN_LD_SONAME.
$(KBUILD_TARGET
)
57 TOOL_GXX3PLAIN_LD_SONAME ?
= -Wl
,-soname
=$(firstword $($(1)_SONAME.
$(KBUILD_TARGET
).
$(KBUILD_TYPE
)) $($(1)_SONAME.
$(KBUILD_TARGET
)) $($(1)_SONAME.
$(KBUILD_TYPE
)) $($(1)_SONAME
) $(notdir $(2)))
59 TOOL_GXX3PLAIN_LD_SONAME ?
= $(TOOL_GXX3PLAIN_LD_SONAME.
$(KBUILD_TARGET
))
62 TOOL_GXX3PLAIN_CC
+= -fmessage-length
=0
63 TOOL_GXX3PLAIN_CXX
+= -fmessage-length
=0
66 # General Properties used by kBuild
67 TOOL_GXX3PLAIN_COBJSUFF ?
= .o
68 TOOL_GXX3PLAIN_CFLAGS ?
=
69 TOOL_GXX3PLAIN_CFLAGS.debug ?
= -g
70 TOOL_GXX3PLAIN_CFLAGS.profile ?
= -O2
#-g -pg
71 TOOL_GXX3PLAIN_CFLAGS.release ?
= -O2
72 TOOL_GXX3PLAIN_CINCS ?
=
73 TOOL_GXX3PLAIN_CDEFS ?
=
75 TOOL_GXX3PLAIN_CXXOBJSUFF ?
= .o
76 TOOL_GXX3PLAIN_CXXOBJSUFF ?
= .o
77 TOOL_GXX3PLAIN_CXXFLAGS ?
=
78 TOOL_GXX3PLAIN_CXXFLAGS.debug ?
= -g
79 TOOL_GXX3PLAIN_CXXFLAGS.profile ?
= -O2
#-g -pg
80 TOOL_GXX3PLAIN_CXXFLAGS.release ?
= -O2
81 TOOL_GXX3PLAIN_CXXINCS ?
=
82 TOOL_GXX3PLAIN_CXXDEFS ?
=
84 TOOL_GXX3PLAIN_ASFLAGS ?
= -x assembler-with-cpp
85 TOOL_GXX3PLAIN_ASFLAGS.debug ?
= -g
86 TOOL_GXX3PLAIN_ASFLAGS.profile ?
= -g
87 TOOL_GXX3PLAIN_ASOBJSUFF ?
= .o
89 TOOL_GXX3PLAIN_ARFLAGS ?
= cr
90 TOOL_GXX3PLAIN_ARLIBSUFF ?
= .a
92 TOOL_GXX3PLAIN_LDFLAGS ?
=
96 # @param $(target) Normalized main target name.
97 # @param $(source) Source filename (relative).
98 # @param $(obj) Object file name. This shall be (re)created by the compilation.
99 # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
100 # @param $(flags) Flags.
101 # @param $(defs) Definitions. No -D or something.
102 # @param $(incs) Includes. No -I or something.
103 # @param $(dirdep) Directory creation dependency.
104 # @param $(deps) Other dependencies.
106 # @param $(outbase) Output basename (full). Use this for list files and such.
107 # @param $(objsuff) Object suffix.
108 TOOL_GXX3PLAIN_COMPILE_C_DEPEND
=
109 TOOL_GXX3PLAIN_COMPILE_C_DEPORD
=
110 ifdef KBUILD_USE_KOBJCACHE
111 TOOL_GXX3PLAIN_COMPILE_C_USES_KOBJCACHE
= 1
112 TOOL_GXX3PLAIN_COMPILE_C_OUTPUT
= $(outbase
).i
113 define TOOL_GXX3PLAIN_COMPILE_C_CMDS
114 $(QUIET
)$(KOBJCACHE
) -f
$(outbase
).koc
-d
$(PATH_OBJCACHE
) -t
$(bld_trg
).
$(bld_trg_arch
) -p\
115 --kObjCache-cpp
$(outbase
).i\
116 $(TOOL_GXX3PLAIN_CC
) -E
-o
-\
117 $(flags
) $(addprefix -I
, $(incs
)) $(addprefix -D
, $(defs
))\
118 -Wp
,-MD
,$(dep
) -Wp
,-MT
,$(obj
) -Wp
,-MP\
119 $(abspath
$(source
))\
120 --kObjCache-cc
$(obj
)\
121 $(TOOL_GXX3PLAIN_CC
) -c\
122 $(flags
) -fpreprocessed
-x c\
126 else # !KBUILD_USE_KOBJCACHE
127 TOOL_GXX3PLAIN_COMPILE_C_OUTPUT
=
128 define TOOL_GXX3PLAIN_COMPILE_C_CMDS
129 $(QUIET
)$(TOOL_GXX3PLAIN_CC
) -c\
130 $(flags
) $(addprefix -I
, $(incs
)) $(addprefix -D
, $(defs
))\
131 -Wp
,-MD
,$(dep
) -Wp
,-MT
,$(obj
) -Wp
,-MP\
135 endif # !KBUILD_USE_KOBJCACHE
138 ## Compile C++ source.
139 # @param $(target) Normalized main target name.
140 # @param $(source) Source filename (relative).
141 # @param $(obj) Object file name. This shall be (re)created by the compilation.
142 # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
143 # @param $(flags) Flags.
144 # @param $(defs) Definitions. No -D or something.
145 # @param $(incs) Includes. No -I or something.
146 # @param $(dirdep) Directory creation dependency.
147 # @param $(deps) Other dependencies.
148 # @param $(outbase) Output basename (full). Use this for list files and such.
149 # @param $(objsuff) Object suffix.
150 TOOL_GXX3PLAIN_COMPILE_CXX_DEPEND
=
151 TOOL_GXX3PLAIN_COMPILE_CXX_DEPORD
=
152 ifdef KBUILD_USE_KOBJCACHE
153 TOOL_GXX3PLAIN_COMPILE_CXX_USES_KOBJCACHE
= 1
154 TOOL_GXX3PLAIN_COMPILE_CXX_OUTPUT
= $(outbase
).ii
155 define TOOL_GXX3PLAIN_COMPILE_CXX_CMDS
156 $(QUIET
)$(KOBJCACHE
) -f
$(outbase
).koc
-d
$(PATH_OBJCACHE
) -t
$(bld_trg
).
$(bld_trg_arch
) -p\
157 --kObjCache-cpp
$(outbase
).ii\
158 $(TOOL_GXX3PLAIN_CXX
) -E
-o
-\
159 $(flags
) $(addprefix -I
, $(incs
)) $(addprefix -D
, $(defs
))\
160 -Wp
,-MD
,$(dep
) -Wp
,-MT
,$(obj
) -Wp
,-MP\
161 $(abspath
$(source
))\
162 --kObjCache-cc
$(obj
)\
163 $(TOOL_GXX3PLAIN_CXX
) -c\
164 $(flags
) -fpreprocessed
-x c
++\
168 else # !KBUILD_USE_KOBJCACHE
169 TOOL_GXX3PLAIN_COMPILE_CXX_OUTPUT
=
170 define TOOL_GXX3PLAIN_COMPILE_CXX_CMDS
171 $(QUIET
)$(TOOL_GXX3PLAIN_CXX
) -c\
172 $(flags
) $(addprefix -I
, $(incs
)) $(addprefix -D
, $(defs
))\
173 -Wp
,-MD
,$(dep
) -Wp
,-MT
,$(obj
) -Wp
,-MP\
177 endif # !KBUILD_USE_KOBJCACHE
180 ## Compile Assembly source.
181 # @param $(target) Normalized main target name.
182 # @param $(source) Source filename (relative).
183 # @param $(obj) Object file name. This shall be (re)created by the compilation.
184 # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
185 # @param $(flags) Flags.
186 # @param $(defs) Definitions. No -D or something.
187 # @param $(incs) Includes. No -I or something.
188 # @param $(dirdep) Directory creation dependency.
189 # @param $(deps) Other dependencies.
190 # @param $(outbase) Output basename (full). Use this for list files and such.
191 # @param $(objsuff) Object suffix.
193 TOOL_GXX3PLAIN_COMPILE_AS_OUTPUT
=
194 TOOL_GXX3PLAIN_COMPILE_AS_DEPEND
=
195 TOOL_GXX3PLAIN_COMPILE_AS_DEPORD
=
196 define TOOL_GXX3PLAIN_COMPILE_AS_CMDS
197 $(QUIET
)$(TOOL_GXX3PLAIN_AS
) -c\
198 $(flags
) $(addprefix -I
, $(incs
)) $(addprefix -D
, $(defs
))\
199 -Wp
,-MD
,$(dep
) -Wp
,-MT
,$(obj
) -Wp
,-MP\
206 # @param $(target) Normalized main target name.
207 # @param $(out) Library name.
208 # @param $(objs) Object files to put in the library.
209 # @param $(flags) Flags.
210 # @param $(dirdep) Directory creation dependency.
211 # @param $(deps) Other dependencies.
212 # @param $(othersrc) Unhandled sources.
213 # @param $(outbase) Output basename (full). Use this for list files and such.
214 TOOL_GXX3PLAIN_LINK_LIBRARY_OUTPUT
=
215 TOOL_GXX3PLAIN_LINK_LIBRARY_DEPEND
= $(othersrc
)
216 TOOL_GXX3PLAIN_LINK_LIBRARY_DEPORD
=
217 define TOOL_GXX3PLAIN_LINK_LIBRARY_CMDS
218 $(call xargs
,$(QUIET
)$(TOOL_GXX3PLAIN_AR
) $(flags
) $(out
),$(objs
))
219 $(foreach lib
,$(othersrc
)\
220 ,$(NL
)$(TAB
)$(call MSG_AR_MERGE
,$(target
),$(out
),$(lib
)) \
221 $(NL
)$(TAB
)$(QUIET
)$(RM_EXT
) -f
$(dir $(outbase
))ar.tmp.
dir/* \
222 $(NL
)$(TAB
)$(QUIET
)$(MKDIR
) -p
$(dir $(outbase
))/ar.tmp.
dir/ \
223 $(NL
)$(TAB
)$(QUIET
)(cd
$(dir $(outbase
))ar.tmp.
dir/ \
224 && $(TOOL_GXX3PLAIN_AR
) x
$(abspath
$(lib
)) \
225 && $(TOOL_GXX3PLAIN_AR
) $(flags
) $(out
) *) \
226 $(NL
)$(TAB
)$(QUIET
)$(RM_EXT
) -f
$(dir $(outbase
))/ar.tmp.
dir/* \
227 $(NL
)$(TAB
)$(QUIET
)$(RMDIR
) $(dir $(outbase
))ar.tmp.
dir/)
228 $(QUIET
)$(TOOL_GXX3PLAIN_RANLIB
) $(out
)
233 # @param $(target) Normalized main target name.
234 # @param $(out) Program name.
235 # @param $(objs) Object files to link together.
236 # @param $(libs) Libraries to search.
237 # @param $(libpath) Library search paths.
238 # @param $(flags) Flags.
239 # @param $(dirdep) Directory creation dependency.
240 # @param $(deps) Other dependencies.
241 # @param $(othersrc) Unhandled sources.
242 # @param $(custom_pre) Custom step invoked before linking.
243 # @param $(custom_post) Custom step invoked after linking.
244 # @param $(outbase) Output basename (full). Use this for list files and such.
245 TOOL_GXX3PLAIN_LINK_PROGRAM_OUTPUT
=
246 TOOL_GXX3PLAIN_LINK_PROGRAM_OUTPUT_MAYBE
= $(outbase
).map
247 TOOL_GXX3PLAIN_LINK_PROGRAM_DEPEND
= $(foreach lib
,$(libs
),$(if
$(findstring $(lib
),$(subst /,x
,$(lib
))),, $(lib
)))\
248 $(filter %.def
, $(othersrc
))
249 TOOL_GXX3PLAIN_LINK_PROGRAM_DEPORD
=
250 define TOOL_GXX3PLAIN_LINK_PROGRAM_CMDS
251 $(QUIET
)$(TOOL_GXX3PLAIN_LD
) $(flags
) -o
$(out
) $(objs
)\
252 $(filter %.def
, $(othersrc
))\
253 $(foreach p
,$(libpath
), -L
$(p
))\
254 $(foreach lib
,$(libs
), $(if
$(findstring $(lib
),$(subst /,x
,$(lib
))), -l
$(patsubst lib
%,%,$(lib
)), $(lib
)))
259 # @param $(target) Normalized main target name.
260 # @param $(out) Program name.
261 # @param $(objs) Object files to link together.
262 # @param $(libs) Libraries to search.
263 # @param $(libpath) Library search paths.
264 # @param $(flags) Flags.
265 # @param $(dirdep) Directory creation dependency.
266 # @param $(deps) Other dependencies.
267 # @param $(othersrc) Unhandled sources.
268 # @param $(custom_pre) Custom step invoked before linking.
269 # @param $(custom_post) Custom step invoked after linking.
270 # @param $(outbase) Output basename (full). Use this for list files and such.
271 TOOL_GXX3PLAIN_LINK_DLL_OUTPUT
=
272 TOOL_GXX3PLAIN_LINK_DLL_OUTPUT_MAYBE
= $(outbase
).map
273 TOOL_GXX3PLAIN_LINK_DLL_DEPEND
= $(foreach lib
,$(libs
),$(if
$(findstring $(lib
),$(subst /,x
,$(lib
))),, $(lib
)))\
274 $(filter %.def
, $(othersrc
))
275 TOOL_GXX3PLAIN_LINK_DLL_DEPORD
=
276 define TOOL_GXX3PLAIN_LINK_DLL_CMDS
277 $(QUIET
)$(TOOL_GXX3PLAIN_LD
) $(TOOL_GXX3PLAIN_LDFLAGS.dll
) $(flags
) -o
$(out
)\
278 $(if
$(filter-out win32 os2
, $(KBUILD_TARGET
)),$(call TOOL_GXX3PLAIN_LD_SONAME
,$(target
),$(out
)))\
280 $(filter %.def
, $(othersrc
))\
281 $(foreach p
,$(libpath
), -L
$(p
))\
282 $(foreach lib
,$(libs
), $(if
$(findstring $(lib
),$(subst /,x
,$(lib
))), -l
$(patsubst lib
%,%,$(lib
)), $(lib
)))
286 ## Link system module (windows aka driver, linux aka kernel module)
287 # This tool target might not work everywhere, but is provided for the
288 # platforms where it works (Solaris, etc).
290 # @param $(target) Normalized main target name.
291 # @param $(out) System module name.
292 # @param $(objs) Object files to link together.
293 # @param $(libs) Libraries to search.
294 # @param $(libpath) Library search paths.
295 # @param $(flags) Flags.
296 # @param $(dirdep) Directory creation dependency.
297 # @param $(deps) Other dependencies.
298 # @param $(othersrc) Unhandled sources.
299 # @param $(custom_pre) Custom step invoked before linking.
300 # @param $(custom_post) Custom step invoked after linking.
301 # @param $(outbase) Output basename (full). Use this for list files and such.
302 TOOL_GXX3PLAIN_LINK_SYSMOD_OUTPUT
=
303 TOOL_GXX3PLAIN_LINK_SYSMOD_OUTPUT_MAYBE
= $(outbase
).map
304 TOOL_GXX3PLAIN_LINK_SYSMOD_DEPEND
= $(foreach lib
,$(libs
),$(if
$(findstring $(lib
),$(subst /,x
,$(lib
))),, $(lib
)))\
305 $(filter %.def
, $(othersrc
))
306 TOOL_GXX3PLAIN_LINK_SYSMOD_DEPORD
=
307 define TOOL_GXX3PLAIN_LINK_SYSMOD_CMDS
308 $(QUIET
)$(if
$(TOOL_GXX3PLAIN_LD_SYSMOD.
$(bld_trg
)),$(TOOL_GXX3PLAIN_LD_SYSMOD.
$(bld_trg
)),$(TOOL_GXX3PLAIN_LD_SYSMOD
))\
309 $(TOOL_GXX3PLAIN_LDFLAGS_SYSMOD.
$(bld_trg
)) $(flags
) -o
$(out
) \
311 $(filter %.def
, $(othersrc
))\
312 $(foreach p
,$(libpath
), -L
$(p
))\
313 $(foreach lib
,$(libs
), $(if
$(findstring $(lib
),$(subst /,x
,$(lib
))), -l
$(patsubst lib
%,%,$(lib
)), $(lib
)))