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

Last change on this file since 3566 was 3566, checked in by bird, 3 years ago

tools/G*.kmk,header.kmk: Use qaddprefix in sh-mode for -D and -I processing, just like VCC14*.kmk does. Forced update of header.kmk so KMK_REVISION can be used to detect the changes.

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