source: trunk/kBuild/tools/GXX3PLAIN.kmk@ 3391

Last change on this file since 3391 was 3391, checked in by bird, 5 years ago

tools/GXX*: Added _PREFIX/_SUFFIX properties to all g++ tools. Some minor fixes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 15.4 KB
Line 
1# $Id: GXX3PLAIN.kmk 3391 2020-06-30 08:08:15Z bird $
2## @file
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.
4#
5
6#
7# Copyright (c) 2004-2017 knut st. osmundsen <bird-kBuild-spam-xviiv@anduin.net>
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# 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.
31#
32#
33
34TOOL_GXX3PLAIN := Generic GCC v3.2.x or later using the system GCC, any Unix linker and Unix archiver to build C++ code.
35
36# Tool Specific Properties
37ifndef TOOL_GXX3PLAIN_PREFIX
38 TOOL_GXX3PLAIN_PREFIX :=
39endif
40ifndef TOOL_GXX3PLAIN_SUFFIX
41 TOOL_GXX3PLAIN_SUFFIX := $(HOSTSUFF_EXE)
42endif
43TOOL_GXX3PLAIN_CC ?= $(TOOL_GXX3PLAIN_PREFIX)gcc$(TOOL_GXX3PLAIN_SUFFIX)
44TOOL_GXX3PLAIN_CXX ?= $(TOOL_GXX3PLAIN_PREFIX)g++$(TOOL_GXX3PLAIN_SUFFIX)
45TOOL_GXX3PLAIN_PCH ?= $(TOOL_GXX3PLAIN_CXX)
46TOOL_GXX3PLAIN_AS ?= $(TOOL_GXX3PLAIN_PREFIX)gcc$(TOOL_GXX3PLAIN_SUFFIX)
47TOOL_GXX3PLAIN_AR ?= $(TOOL_GXX3PLAIN_PREFIX)ar$(TOOL_GXX3PLAIN_SUFFIX)
48TOOL_GXX3PLAIN_RANLIB ?= $(TOOL_GXX3PLAIN_PREFIX)ranlib$(TOOL_GXX3PLAIN_SUFFIX)
49TOOL_GXX3PLAIN_LD ?= $(TOOL_GXX3PLAIN_PREFIX)g++$(TOOL_GXX3PLAIN_SUFFIX)
50TOOL_GXX3PLAIN_LD_SYSMOD ?= $(TOOL_GXX3PLAIN_PREFIX)ld$(TOOL_GXX3PLAIN_SUFFIX)
51TOOL_GXX3PLAIN_LD_SYSMOD.os2 ?= $(TOOL_GXX3PLAIN_PREFIX)g++$(TOOL_GXX3PLAIN_SUFFIX)
52TOOL_GXX3PLAIN_LDFLAGS.dll.os2 ?= -Zdll
53TOOL_GXX3PLAIN_LDFLAGS.dll.darwin ?= -dynamiclib
54ifndef TOOL_GXX3PLAIN_LDFLAGS.$(KBUILD_TARGET)
55 TOOL_GXX3PLAIN_LDFLAGS.dll ?= -shared
56else
57 TOOL_GXX3PLAIN_LDFLAGS.dll ?= $(TOOL_GXX3PLAIN_LDFLAGS.$(KBUILD_TARGET))
58endif
59TOOL_GXX3PLAIN_LD_SONAME.darwin ?= $(NO_SUCH_VARIABLE)
60TOOL_GXX3PLAIN_LD_SONAME.os2 ?= $(NO_SUCH_VARIABLE)
61TOOL_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)))
62TOOL_GXX3PLAIN_LD_SONAME.win ?= $(NO_SUCH_VARIABLE)
63ifndef TOOL_GXX3PLAIN_LD_SONAME.$(KBUILD_TARGET)
64 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)))
65else
66 TOOL_GXX3PLAIN_LD_SONAME ?= $(TOOL_GXX3PLAIN_LD_SONAME.$(KBUILD_TARGET))
67endif
68ifdef SLKRUNS
69 TOOL_GXX3PLAIN_CC += -fmessage-length=0
70 TOOL_GXX3PLAIN_CXX += -fmessage-length=0
71endif
72
73# General Properties used by kBuild
74TOOL_GXX3PLAIN_COBJSUFF ?= .o
75TOOL_GXX3PLAIN_CFLAGS ?=
76TOOL_GXX3PLAIN_CFLAGS.debug ?= -g
77TOOL_GXX3PLAIN_CFLAGS.profile ?= -O2 #-g -pg
78TOOL_GXX3PLAIN_CFLAGS.release ?= -O2
79TOOL_GXX3PLAIN_CINCS ?=
80TOOL_GXX3PLAIN_CDEFS ?=
81
82TOOL_GXX3PLAIN_CXXOBJSUFF ?= .o
83TOOL_GXX3PLAIN_CXXFLAGS ?=
84TOOL_GXX3PLAIN_CXXFLAGS.debug ?= -g
85TOOL_GXX3PLAIN_CXXFLAGS.profile ?= -O2 #-g -pg
86TOOL_GXX3PLAIN_CXXFLAGS.release ?= -O2
87TOOL_GXX3PLAIN_CXXINCS ?=
88TOOL_GXX3PLAIN_CXXDEFS ?=
89
90TOOL_GXX3PLAIN_PCHOBJSUFF ?= .h.gch
91TOOL_GXX3PLAIN_PCHFLAGS ?= $(TOOL_GXX3PLAIN_CXXFLAGS)
92TOOL_GXX3PLAIN_PCHFLAGS.debug ?= $(TOOL_GXX3PLAIN_CXXFLAGS.debug)
93TOOL_GXX3PLAIN_PCHFLAGS.profile ?= $(TOOL_GXX3PLAIN_CXXFLAGS.profile)
94TOOL_GXX3PLAIN_PCHFLAGS.release ?= $(TOOL_GXX3PLAIN_CXXFLAGS.release)
95TOOL_GXX3PLAIN_PCHINCS ?= $(TOOL_GXX3PLAIN_CXXINCS)
96TOOL_GXX3PLAIN_PCHDEFS ?= $(TOOL_GXX3PLAIN_CXXDEFS)
97
98TOOL_GXX3PLAIN_ASFLAGS ?= -x assembler-with-cpp
99TOOL_GXX3PLAIN_ASFLAGS.debug ?= -g
100TOOL_GXX3PLAIN_ASFLAGS.profile ?= -g
101TOOL_GXX3PLAIN_ASOBJSUFF ?= .o
102
103TOOL_GXX3PLAIN_ARFLAGS ?= cr
104TOOL_GXX3PLAIN_ARLIBSUFF ?= .a
105
106TOOL_GXX3PLAIN_LDFLAGS ?=
107
108
109## Compile C source.
110# @param $(target) Normalized main target name.
111# @param $(source) Source filename (relative).
112# @param $(obj) Object file name. This shall be (re)created by the compilation.
113# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
114# @param $(flags) Flags.
115# @param $(defs) Definitions. No -D or something.
116# @param $(incs) Includes. No -I or something.
117# @param $(dirdep) Directory creation dependency.
118# @param $(deps) Other dependencies.
119#
120# @param $(outbase) Output basename (full). Use this for list files and such.
121# @param $(objsuff) Object suffix.
122TOOL_GXX3PLAIN_COMPILE_C_DEPEND =
123TOOL_GXX3PLAIN_COMPILE_C_DEPORD =
124TOOL_GXX3PLAIN_COMPILE_C_OUTPUT = $(if-expr "$(use_objcache)" != "",$(outbase).i,)
125TOOL_GXX3PLAIN_COMPILE_C_USES_KOBJCACHE = $(if-expr "$(use_objcache)" != "",1,)
126define TOOL_GXX3PLAIN_COMPILE_C_CMDS
127if "$(use_objcache)" != ""
128 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
129 --kObjCache-cpp $(outbase).i\
130 $(TOOL_GXX3PLAIN_CC) -E -o -\
131 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
132 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
133 $(abspath $(source))\
134 --kObjCache-cc $(obj)\
135 $(TOOL_GXX3PLAIN_CC) -c\
136 $(flags) -fpreprocessed -x c\
137 -o $(obj)\
138 -
139else
140 $(QUIET)$(TOOL_GXX3PLAIN_CC) -c\
141 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
142 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
143 -o $(obj)\
144 $(abspath $(source))
145endif
146 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
147endef
148
149
150## Compile C++ source.
151# @param $(target) Normalized main target name.
152# @param $(source) Source filename (relative).
153# @param $(obj) Object file name. This shall be (re)created by the compilation.
154# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
155# @param $(flags) Flags.
156# @param $(defs) Definitions. No -D or something.
157# @param $(incs) Includes. No -I or something.
158# @param $(dirdep) Directory creation dependency.
159# @param $(deps) Other dependencies.
160# @param $(outbase) Output basename (full). Use this for list files and such.
161# @param $(objsuff) Object suffix.
162TOOL_GXX3PLAIN_COMPILE_CXX_OUTPUT = $(if-expr "$(use_objcache)" != "",$(outbase).ii,)
163TOOL_GXX3PLAIN_COMPILE_CXX_DEPEND = $($(target)_1_GCC_PCH_FILE)
164TOOL_GXX3PLAIN_COMPILE_CXX_DEPORD =
165TOOL_GXX3PLAIN_COMPILE_CXX_USES_KOBJCACHE = $(if-expr "$(use_objcache)" != "",1,)
166define TOOL_GXX3PLAIN_COMPILE_CXX_CMDS
167if "$(use_objcache)" != ""
168 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
169 --kObjCache-cpp $(outbase).ii\
170 $(TOOL_GXX3PLAIN_CXX) -E -o - $(if-expr defined($(target)_PCH_HDR)\
171 ,-fpch-preprocess -Winvalid-pch -I$($(target)_1_GCC_PCH_DIR) -include $(basename $($(target)_1_GCC_PCH_FILE)),)\
172 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
173 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
174 $(abspath $(source))\
175 --kObjCache-cc $(obj)\
176 $(TOOL_GXX3PLAIN_CXX) -c\
177 $(flags) -fpreprocessed $(if-expr defined($(target)_PCH_HDR),-fpch-preprocess,) -x c++\
178 -o $(obj)\
179 -
180else
181 $(QUIET)$(TOOL_GXX3PLAIN_CXX) -c\
182 $(flags) $(addprefix -I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(addprefix -D, $(defs))\
183 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
184 -o $(obj) $(if-expr defined($(target)_PCH_HDR) \
185 ,-Winvalid-pch -include $(basename $($(target)_1_GCC_PCH_FILE)),) \
186 $(abspath $(source))
187endif
188 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
189endef
190
191
192## Precompile C++ header.
193# @param $(target) Normalized main target name.
194# @param $(source) Source filename (relative).
195# @param $(obj) Object file name. This shall be (re)created by the compilation.
196# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
197# @param $(flags) Flags.
198# @param $(defs) Definitions. No -D or something.
199# @param $(incs) Includes. No -I or something.
200# @param $(dirdep) Directory creation dependency.
201# @param $(deps) Other dependencies.
202# @param $(outbase) Output basename (full). Use this for list files and such.
203# @param $(objsuff) Object suffix.
204TOOL_GXX3PLAIN_COMPILE_PCH_OUTPUT = $($(target)_1_GCC_PCH_FILE)
205TOOL_GXX3PLAIN_COMPILE_PCH_DEPEND =
206TOOL_GXX3PLAIN_COMPILE_PCH_DEPORD = $($(target)_1_GCC_PCH_DIR)
207define TOOL_GXX3PLAIN_COMPILE_PCH_CMDS
208 $(QUIET)$(TOOL_GXX3PLAIN_PCH) -c\
209 $(flags) $(addprefix -I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(addprefix -D, $(defs))\
210 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
211 -o $(obj)\
212 $(abspath $(source))
213 $(INSTALL) --hard-link-files-when-possible -m 0644 -- "$(obj)" "$($(target)_1_GCC_PCH_FILE)"
214 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
215endef
216
217
218## Compile Assembly source.
219# @param $(target) Normalized main target name.
220# @param $(source) Source filename (relative).
221# @param $(obj) Object file name. This shall be (re)created by the compilation.
222# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
223# @param $(flags) Flags.
224# @param $(defs) Definitions. No -D or something.
225# @param $(incs) Includes. No -I or something.
226# @param $(dirdep) Directory creation dependency.
227# @param $(deps) Other dependencies.
228# @param $(outbase) Output basename (full). Use this for list files and such.
229# @param $(objsuff) Object suffix.
230#
231TOOL_GXX3PLAIN_COMPILE_AS_OUTPUT =
232TOOL_GXX3PLAIN_COMPILE_AS_DEPEND =
233TOOL_GXX3PLAIN_COMPILE_AS_DEPORD =
234define TOOL_GXX3PLAIN_COMPILE_AS_CMDS
235 $(QUIET)$(TOOL_GXX3PLAIN_AS) -c\
236 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
237 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
238 -o $(obj)\
239 $(abspath $(source))
240 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
241endef
242
243
244## Link library
245# @param $(target) Normalized main target name.
246# @param $(out) Library name.
247# @param $(objs) Object files to put in the library.
248# @param $(flags) Flags.
249# @param $(dirdep) Directory creation dependency.
250# @param $(deps) Other dependencies.
251# @param $(othersrc) Unhandled sources.
252# @param $(outbase) Output basename (full). Use this for list files and such.
253TOOL_GXX3PLAIN_LINK_LIBRARY_OUTPUT =
254TOOL_GXX3PLAIN_LINK_LIBRARY_DEPEND = $(othersrc)
255TOOL_GXX3PLAIN_LINK_LIBRARY_DEPORD =
256define TOOL_GXX3PLAIN_LINK_LIBRARY_CMDS
257 $(call xargs,$(QUIET)$(TOOL_GXX3PLAIN_AR) $(flags) $(out),$(filter-out %.h.gch,$(objs)))
258 $(foreach lib,$(othersrc)\
259 ,$(NL)$(TAB)$(call MSG_AR_MERGE,$(target),$(out),$(lib)) \
260 $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))ar.tmp.dir/* \
261 $(NL)$(TAB)$(QUIET)$(MKDIR) -p $(dir $(outbase))/ar.tmp.dir/ \
262 $(NL)$(TAB)$(QUIET)(cd $(dir $(outbase))ar.tmp.dir/ \
263 && $(TOOL_GXX3PLAIN_AR) x $(abspath $(lib)) \
264 && $(TOOL_GXX3PLAIN_AR) $(flags) $(out) *) \
265 $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))/ar.tmp.dir/* \
266 $(NL)$(TAB)$(QUIET)$(RMDIR) $(dir $(outbase))ar.tmp.dir/)
267 $(QUIET)$(TOOL_GXX3PLAIN_RANLIB) $(out)
268endef
269
270
271## Link program
272# @param $(target) Normalized main target name.
273# @param $(out) Program name.
274# @param $(objs) Object files to link together.
275# @param $(libs) Libraries to search.
276# @param $(libpath) Library search paths.
277# @param $(flags) Flags.
278# @param $(dirdep) Directory creation dependency.
279# @param $(deps) Other dependencies.
280# @param $(othersrc) Unhandled sources.
281# @param $(custom_pre) Custom step invoked before linking.
282# @param $(custom_post) Custom step invoked after linking.
283# @param $(outbase) Output basename (full). Use this for list files and such.
284TOOL_GXX3PLAIN_LINK_PROGRAM_OUTPUT =
285TOOL_GXX3PLAIN_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map
286TOOL_GXX3PLAIN_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
287 $(filter %.def, $(othersrc))
288TOOL_GXX3PLAIN_LINK_PROGRAM_DEPORD =
289define TOOL_GXX3PLAIN_LINK_PROGRAM_CMDS
290 $(QUIET)$(TOOL_GXX3PLAIN_LD) $(flags) -o $(out) $(filter-out %.h.gch,$(objs))\
291 $(filter %.def, $(othersrc))\
292 $(foreach p,$(libpath), -L$(p))\
293 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
294endef
295
296
297## Link DLL
298# @param $(target) Normalized main target name.
299# @param $(out) Program name.
300# @param $(objs) Object files to link together.
301# @param $(libs) Libraries to search.
302# @param $(libpath) Library search paths.
303# @param $(flags) Flags.
304# @param $(dirdep) Directory creation dependency.
305# @param $(deps) Other dependencies.
306# @param $(othersrc) Unhandled sources.
307# @param $(custom_pre) Custom step invoked before linking.
308# @param $(custom_post) Custom step invoked after linking.
309# @param $(outbase) Output basename (full). Use this for list files and such.
310TOOL_GXX3PLAIN_LINK_DLL_OUTPUT =
311TOOL_GXX3PLAIN_LINK_DLL_OUTPUT_MAYBE = $(outbase).map
312TOOL_GXX3PLAIN_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
313 $(filter %.def, $(othersrc))
314TOOL_GXX3PLAIN_LINK_DLL_DEPORD =
315define TOOL_GXX3PLAIN_LINK_DLL_CMDS
316 $(QUIET)$(TOOL_GXX3PLAIN_LD) $(TOOL_GXX3PLAIN_LDFLAGS.dll) $(flags) -o $(out)\
317 $(if $(filter-out win32 os2, $(KBUILD_TARGET)),$(call TOOL_GXX3PLAIN_LD_SONAME,$(target),$(out)))\
318 $(filter-out %.h.gch,$(objs))\
319 $(filter %.def, $(othersrc))\
320 $(foreach p,$(libpath), -L$(p))\
321 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
322endef
323
324
325## Link system module (windows aka driver, linux aka kernel module)
326# This tool target might not work everywhere, but is provided for the
327# platforms where it works (Solaris, etc).
328#
329# @param $(target) Normalized main target name.
330# @param $(out) System module name.
331# @param $(objs) Object files to link together.
332# @param $(libs) Libraries to search.
333# @param $(libpath) Library search paths.
334# @param $(flags) Flags.
335# @param $(dirdep) Directory creation dependency.
336# @param $(deps) Other dependencies.
337# @param $(othersrc) Unhandled sources.
338# @param $(custom_pre) Custom step invoked before linking.
339# @param $(custom_post) Custom step invoked after linking.
340# @param $(outbase) Output basename (full). Use this for list files and such.
341TOOL_GXX3PLAIN_LINK_SYSMOD_OUTPUT =
342TOOL_GXX3PLAIN_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map
343TOOL_GXX3PLAIN_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
344 $(filter %.def, $(othersrc))
345TOOL_GXX3PLAIN_LINK_SYSMOD_DEPORD =
346define TOOL_GXX3PLAIN_LINK_SYSMOD_CMDS
347 $(QUIET)$(if $(TOOL_GXX3PLAIN_LD_SYSMOD.$(bld_trg)),$(TOOL_GXX3PLAIN_LD_SYSMOD.$(bld_trg)),$(TOOL_GXX3PLAIN_LD_SYSMOD))\
348 $(TOOL_GXX3PLAIN_LDFLAGS_SYSMOD.$(bld_trg)) $(flags) -o $(out) \
349 $(filter-out %.h.gch,$(objs))\
350 $(filter %.def, $(othersrc))\
351 $(foreach p,$(libpath), -L$(p))\
352 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
353endef
354
Note: See TracBrowser for help on using the repository browser.