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

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

tools/*GCC*,tools/*GXX*: Removed the SLKRUNS/-fmessage-length=0 stuff as it triggers rebuilds when switching between SlickEdit and the command line. If really needed, it belongs in the project's Config.kmk.

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