source: trunk/kBuild/tools/GXX3.kmk@ 3567

Last change on this file since 3567 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.9 KB
Line 
1# $Id: GXX3.kmk 3567 2022-06-26 20:00:02Z bird $
2## @file
3# kBuild Tool Config - Generic GCC v3.2+ using the system GCC and Binutils, for building 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_GXX3 := Generic GCC v3.2.x or later using the system GCC and Binutils, for building C++ code.
35
36# Tool Specific Properties
37ifndef TOOL_GXX3_PREFIX
38 TOOL_GXX3_PREFIX :=
39endif
40ifndef TOOL_GXX3_SUFFIX
41 TOOL_GXX3_SUFFIX := $(HOSTSUFF_EXE)
42endif
43if1of ($(KBUILD_HOST), solaris)
44 TOOL_GXX3_PREFIX2 ?= g
45else
46 TOOL_GXX3_PREFIX2 ?=
47endif
48TOOL_GXX3_SUFFIX2 ?= $(HOSTSUFF_EXE)
49TOOL_GXX3_PREFIX3 ?=
50TOOL_GXX3_SUFFIX3 ?= $(HOSTSUFF_EXE)
51
52TOOL_GXX3_CC ?= $(TOOL_GXX3_PREFIX)gcc$(TOOL_GXX3_SUFFIX)
53TOOL_GXX3_CXX ?= $(TOOL_GXX3_PREFIX)g++$(TOOL_GXX3_SUFFIX)
54TOOL_GXX3_PCH ?= $(TOOL_GXX3_CXX)
55TOOL_GXX3_AS ?= $(TOOL_GXX3_PREFIX)gcc$(TOOL_GXX3_SUFFIX)
56TOOL_GXX3_AR ?= $(TOOL_GXX3_PREFIX2)ar$(TOOL_GXX3_SUFFIX2)
57ifeq ($(KBUILD_TARGET),os2)
58 TOOL_GXX3_AR_IMP ?= $(TOOL_GXX3_PREFIX3)emximp$(TOOL_GXX3_SUFFIX3)
59else
60 TOOL_GXX3_AR_IMP ?= $(ECHO) not supported!
61endif
62TOOL_GXX3_LD ?= $(TOOL_GXX3_PREFIX)g++$(TOOL_GXX3_SUFFIX)
63if1of ($(KBUILD_HOST), solaris)
64 TOOL_GXX3_LD_SYSMOD ?= $(TOOL_GXX3_PREFIX3)ld$(TOOL_GXX3_SUFFIX3)
65else
66 TOOL_GXX3_LD_SYSMOD ?= $(TOOL_GXX3_PREFIX2)ld$(TOOL_GXX3_SUFFIX2)
67endif
68ifndef TOOL_GXX3_LDFLAGS.$(KBUILD_TARGET)
69 TOOL_GXX3_LDFLAGS.dll ?= -shared
70else
71 TOOL_GXX3_LDFLAGS.dll ?= $(TOOL_GXX3_LDFLAGS.$(KBUILD_TARGET))
72endif
73TOOL_GXX3_LDFLAGS.sysmod ?= -r
74TOOL_GXX3_LD_SONAME ?= -Wl,-soname=$(firstword $($(1)_SONAME.$(KBUILD_TARGET).$(KBUILD_TYPE)) $($(1)_SONAME.$(KBUILD_TARGET)) $($(1)_SONAME.$(KBUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
75ifeq ($(KBUILD_TARGET),os2)
76 TOOL_GXX3_LD_MAP ?= -Zmap=$(1)
77 TOOL_GXX3_LD_SYSMOD_MAP ?= -Zmap=$(1)
78else
79 TOOL_GXX3_LD_MAP ?=
80 TOOL_GXX3_LD_SYSMOD_MAP ?=
81endif
82TOOL_GXX3_OBJCOPY ?= $(TOOL_GXX3_PREFIX)objcopy$(TOOL_GXX3_SUFFIX)
83
84# General Properties used by kBuild
85TOOL_GXX3_COBJSUFF ?= .o
86TOOL_GXX3_CFLAGS ?=
87TOOL_GXX3_CFLAGS.debug ?= -g
88TOOL_GXX3_CFLAGS.profile ?= -O2 #-g -pg
89TOOL_GXX3_CFLAGS.release ?= -O2
90TOOL_GXX3_CINCS ?=
91TOOL_GXX3_CDEFS ?=
92
93TOOL_GXX3_CXXOBJSUFF ?= .o
94TOOL_GXX3_CXXFLAGS ?=
95TOOL_GXX3_CXXFLAGS.debug ?= -g
96TOOL_GXX3_CXXFLAGS.profile ?= -O2 #-g -pg
97TOOL_GXX3_CXXFLAGS.release ?= -O2
98TOOL_GXX3_CXXINCS ?=
99TOOL_GXX3_CXXDEFS ?=
100
101TOOL_GXX3_PCHOBJSUFF ?= .h.gch
102TOOL_GXX3_PCHFLAGS ?= $(TOOL_GXX3_CXXFLAGS)
103TOOL_GXX3_PCHFLAGS.debug ?= $(TOOL_GXX3_CXXFLAGS.debug)
104TOOL_GXX3_PCHFLAGS.profile ?= $(TOOL_GXX3_CXXFLAGS.profile)
105TOOL_GXX3_PCHFLAGS.release ?= $(TOOL_GXX3_CXXFLAGS.release)
106TOOL_GXX3_PCHINCS ?= $(TOOL_GXX3_CXXINCS)
107TOOL_GXX3_PCHDEFS ?= $(TOOL_GXX3_CXXDEFS)
108
109TOOL_GXX3_ASFLAGS ?= -x assembler-with-cpp
110TOOL_GXX3_ASFLAGS.debug ?= -g
111TOOL_GXX3_ASFLAGS.profile ?= -g
112TOOL_GXX3_ASOBJSUFF ?= .o
113
114TOOL_GXX3_ARFLAGS ?= cr
115TOOL_GXX3_ARLIBSUFF ?= .a
116
117TOOL_GXX3_LDFLAGS ?=
118TOOL_GXX3_LDFLAGS.debug ?= -g
119TOOL_GXX3_LDFLAGS.profile ?= -g
120
121
122## Compile C source.
123# @param $(target) Normalized main target name.
124# @param $(source) Source filename (relative).
125# @param $(obj) Object file name. This shall be (re)created by the compilation.
126# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
127# @param $(flags) Flags.
128# @param $(defs) Definitions. No -D or something.
129# @param $(incs) Includes. No -I or something.
130# @param $(dirdep) Directory creation dependency.
131# @param $(deps) Other dependencies.
132#
133# @param $(outbase) Output basename (full). Use this for list files and such.
134# @param $(objsuff) Object suffix.
135TOOL_GXX3_COMPILE_C_DEPEND =
136TOOL_GXX3_COMPILE_C_DEPORD =
137TOOL_GXX3_COMPILE_C_OUTPUT = $(if-expr "$(use_objcache)" != "",$(outbase).i,)
138TOOL_GXX3_COMPILE_C_USES_KOBJCACHE = $(if-expr "$(use_objcache)" != "",1,)
139define TOOL_GXX3_COMPILE_C_CMDS
140if "$(use_objcache)" != ""
141 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
142 --kObjCache-cpp $(outbase).i\
143 $(TOOL_GXX3_CC) -E -o -\
144 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
145 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
146 $(abspath $(source))\
147 --kObjCache-cc $(obj)\
148 $(TOOL_GXX3_CC) -c\
149 $(flags) -fpreprocessed -x c\
150 -o $(obj)\
151 -
152else
153 $(QUIET)$(TOOL_GXX3_CC) -c\
154 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
155 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
156 -o $(obj)\
157 $(abspath $(source))
158endif
159 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
160endef
161
162
163## Compile C++ source.
164# @param $(target) Normalized main target name.
165# @param $(source) Source filename (relative).
166# @param $(obj) Object file name. This shall be (re)created by the compilation.
167# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
168# @param $(flags) Flags.
169# @param $(defs) Definitions. No -D or something.
170# @param $(incs) Includes. No -I or something.
171# @param $(dirdep) Directory creation dependency.
172# @param $(deps) Other dependencies.
173# @param $(outbase) Output basename (full). Use this for list files and such.
174# @param $(objsuff) Object suffix.
175TOOL_GXX3_COMPILE_CXX_OUTPUT = $(if-expr "$(use_objcache)" != "",$(outbase).ii,)
176TOOL_GXX3_COMPILE_CXX_DEPEND = $($(target)_1_GCC_PCH_FILE)
177TOOL_GXX3_COMPILE_CXX_DEPORD =
178TOOL_GXX3_COMPILE_CXX_USES_KOBJCACHE = $(if-expr "$(use_objcache)" != "",1,)
179define TOOL_GXX3_COMPILE_CXX_CMDS
180if "$(use_objcache)" != ""
181 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
182 --kObjCache-cpp $(outbase).ii\
183 $(TOOL_GXX3_CXX) -E -o - $(if-expr defined($(target)_PCH_HDR)\
184 ,-fpch-preprocess -Winvalid-pch -I$($(target)_1_GCC_PCH_DIR) -include $(basename $($(target)_1_GCC_PCH_FILE)),)\
185 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
186 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
187 $(abspath $(source))\
188 --kObjCache-cc $(obj)\
189 $(TOOL_GXX3_CXX) -c\
190 $(flags) -fpreprocessed $(if-expr defined($(target)_PCH_HDR),-fpch-preprocess,) -x c++\
191 -o $(obj)\
192 -
193else
194 $(QUIET)$(TOOL_GXX3_CXX) -c\
195 $(flags) $(qaddprefix sh,-I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(qaddprefix sh,-D, $(defs))\
196 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
197 -o $(obj) $(if-expr defined($(target)_PCH_HDR) \
198 ,-Winvalid-pch -include $(basename $($(target)_1_GCC_PCH_FILE)),) \
199 $(abspath $(source))
200endif
201 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
202endef
203
204
205## Precompile C++ header.
206# @param $(target) Normalized main target name.
207# @param $(source) Source filename (relative).
208# @param $(obj) Object file name. This shall be (re)created by the compilation.
209# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
210# @param $(flags) Flags.
211# @param $(defs) Definitions. No -D or something.
212# @param $(incs) Includes. No -I or something.
213# @param $(dirdep) Directory creation dependency.
214# @param $(deps) Other dependencies.
215# @param $(outbase) Output basename (full). Use this for list files and such.
216# @param $(objsuff) Object suffix.
217TOOL_GXX3_COMPILE_PCH_OUTPUT = $($(target)_1_GCC_PCH_FILE)
218TOOL_GXX3_COMPILE_PCH_DEPEND =
219TOOL_GXX3_COMPILE_PCH_DEPORD = $($(target)_1_GCC_PCH_DIR)
220define TOOL_GXX3_COMPILE_PCH_CMDS
221 $(QUIET)$(TOOL_GXX3_PCH) -c\
222 $(flags) $(qaddprefix sh,-I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(qaddprefix sh,-D, $(defs))\
223 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
224 -o $(obj)\
225 $(abspath $(source))
226 $(INSTALL) --hard-link-files-when-possible -m 0644 -- "$(obj)" "$($(target)_1_GCC_PCH_FILE)"
227 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
228endef
229
230
231## Compile Assembly source.
232# @param $(target) Normalized main target name.
233# @param $(source) Source filename (relative).
234# @param $(obj) Object file name. This shall be (re)created by the compilation.
235# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
236# @param $(flags) Flags.
237# @param $(defs) Definitions. No -D or something.
238# @param $(incs) Includes. No -I or something.
239# @param $(dirdep) Directory creation dependency.
240# @param $(deps) Other dependencies.
241# @param $(outbase) Output basename (full). Use this for list files and such.
242# @param $(objsuff) Object suffix.
243#
244TOOL_GXX3_COMPILE_AS_OUTPUT =
245TOOL_GXX3_COMPILE_AS_DEPEND =
246TOOL_GXX3_COMPILE_AS_DEPORD =
247define TOOL_GXX3_COMPILE_AS_CMDS
248 $(QUIET)$(TOOL_GXX3_AS) -c\
249 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
250 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
251 -o $(obj)\
252 $(abspath $(source))
253 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
254endef
255
256
257## Link library
258# @param $(target) Normalized main target name.
259# @param $(out) Library name.
260# @param $(objs) Object files to put in the library.
261# @param $(flags) Flags.
262# @param $(dirdep) Directory creation dependency.
263# @param $(deps) Other dependencies.
264# @param $(othersrc) Unhandled sources.
265# @param $(outbase) Output basename (full). Use this for list files and such.
266TOOL_GXX3_LINK_LIBRARY_OUTPUT = $(out).ar-script
267TOOL_GXX3_LINK_LIBRARY_OUTPUT_MAYBE = $(outbase).imp.a
268TOOL_GXX3_LINK_LIBRARY_DEPEND = $(othersrc)
269TOOL_GXX3_LINK_LIBRARY_DEPORD =
270define TOOL_GXX3_LINK_LIBRARY_CMDS
271 $(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)'
272 $(QUIET)$(APPEND) -n $(out).ar-script \
273 $(foreach o,$(filter-out %.h.gch,$(objs)), 'ADDMOD $(o)') \
274 $(foreach o,$(filter-out %.def %.imp %.dll,$(othersrc)), 'ADDLIB $(o)')
275 $(if $(filter %.def %.imp %.dll,$(othersrc))\
276 ,$(TOOL_GXX3_AR_IMP) -o $(outbase).imp.a $(filter %.def %.imp %.dll,$(othersrc))\
277 $(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script 'ADDLIB $(outbase).imp.a')
278 $(QUIET)$(APPEND) $(out).ar-script 'SAVE'
279 $(QUIET)$(APPEND) $(out).ar-script 'END'
280 $(QUIET)$(REDIRECT) -rti $(out).ar-script -- $(TOOL_GXX3_AR) -M
281endef
282
283
284## Link program
285# @param $(target) Normalized main target name.
286# @param $(out) Program name.
287# @param $(objs) Object files to link together.
288# @param $(libs) Libraries to search.
289# @param $(libpath) Library search paths.
290# @param $(flags) Flags.
291# @param $(dirdep) Directory creation dependency.
292# @param $(deps) Other dependencies.
293# @param $(othersrc) Unhandled sources.
294# @param $(custom_pre) Custom step invoked before linking.
295# @param $(custom_post) Custom step invoked after linking.
296# @param $(outbase) Output basename (full). Use this for list files and such.
297TOOL_GXX3_LINK_PROGRAM_OUTPUT =
298TOOL_GXX3_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map
299TOOL_GXX3_LINK_PROGRAM_OUTPUT_DEBUG = $(outbase).debug
300TOOL_GXX3_LINK_PROGRAM_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug
301TOOL_GXX3_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
302 $(filter %.def, $(othersrc))
303TOOL_GXX3_LINK_PROGRAM_DEPORD =
304define TOOL_GXX3_LINK_PROGRAM_CMDS
305 $(QUIET)$(TOOL_GXX3_LD) $(flags) -o $(out) $(filter-out %.h.gch,$(objs))\
306 $(filter %.def, $(othersrc))\
307 $(foreach p,$(libpath), -L$(p))\
308 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
309 $(call TOOL_GXX3_LD_MAP,$(outbase).map)
310 ifeq ($(ld_debug),split)
311 $(QUIET)$(TOOL_GXX3_OBJCOPY) --only-keep-debug $(out) $(outbase).debug
312 $(QUIET)$(CHMOD) a-x $(outbase).debug
313 $(QUIET)$(TOOL_GXX3_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out)
314 endif
315endef
316
317
318## Link DLL
319# @param $(target) Normalized main target name.
320# @param $(out) Program name.
321# @param $(objs) Object files to link together.
322# @param $(libs) Libraries to search.
323# @param $(libpath) Library search paths.
324# @param $(flags) Flags.
325# @param $(dirdep) Directory creation dependency.
326# @param $(deps) Other dependencies.
327# @param $(othersrc) Unhandled sources.
328# @param $(custom_pre) Custom step invoked before linking.
329# @param $(custom_post) Custom step invoked after linking.
330# @param $(outbase) Output basename (full). Use this for list files and such.
331TOOL_GXX3_LINK_DLL_OUTPUT =
332TOOL_GXX3_LINK_DLL_OUTPUT_MAYBE = $(outbase).map
333TOOL_GXX3_LINK_DLL_OUTPUT_DEBUG = $(outbase).debug
334TOOL_GXX3_LINK_DLL_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug
335TOOL_GXX3_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
336 $(filter %.def, $(othersrc))
337TOOL_GXX3_LINK_DLL_DEPORD =
338define TOOL_GXX3_LINK_DLL_CMDS
339 $(QUIET)$(TOOL_GXX3_LD) $(TOOL_GXX3_LDFLAGS.dll) $(flags) -o $(out)\
340 $(if $(filter-out win os2, $(KBUILD_TARGET)),$(call TOOL_GXX3_LD_SONAME,$(target),$(out)))\
341 $(filter-out %.h.gch,$(objs))\
342 $(filter %.def, $(othersrc))\
343 $(foreach p,$(libpath), -L$(p))\
344 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
345 $(call TOOL_GXX3_LD_MAP,$(outbase).map)
346 ifeq ($(ld_debug),split)
347 $(QUIET)$(TOOL_GXX3_OBJCOPY) --only-keep-debug $(out) $(outbase).debug
348 $(QUIET)$(CHMOD) a-x $(outbase).debug
349 $(QUIET)$(TOOL_GXX3_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out)
350 endif
351endef
352
353
354## Link system module (windows aka driver, linux aka kernel module)
355# @param $(target) Normalized main target name.
356# @param $(out) System module name.
357# @param $(objs) Object files to link together.
358# @param $(libs) Libraries to search.
359# @param $(libpath) Library search paths.
360# @param $(flags) Flags.
361# @param $(dirdep) Directory creation dependency.
362# @param $(deps) Other dependencies.
363# @param $(othersrc) Unhandled sources.
364# @param $(custom_pre) Custom step invoked before linking.
365# @param $(custom_post) Custom step invoked after linking.
366# @param $(outbase) Output basename (full). Use this for list files and such.
367TOOL_GXX3_LINK_SYSMOD_OUTPUT =
368TOOL_GXX3_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map
369TOOL_GXX3_LINK_SYSMOD_OUTPUT_DEBUG = $(outbase).debug
370TOOL_GXX3_LINK_SYSMOD_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug
371TOOL_GXX3_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
372 $(filter %.def, $(othersrc))
373TOOL_GXX3_LINK_SYSMOD_DEPORD =
374define TOOL_GXX3_LINK_SYSMOD_CMDS
375 $(QUIET)$(TOOL_GXX3_LD_SYSMOD) $(TOOL_GXX3_LDFLAGS.sysmod) $(flags) -o $(out) $(filter-out %.h.gch,$(objs))\
376 $(filter %.def, $(othersrc))\
377 $(foreach p,$(libpath), -L$(p))\
378 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
379 $(call TOOL_GXX3_LD_SYSMOD_MAP,$(outbase).map)
380 ifeq ($(ld_debug),split)
381 $(QUIET)$(TOOL_GXX3_OBJCOPY) --only-keep-debug $(out) $(outbase).debug
382 $(QUIET)$(CHMOD) a-x $(outbase).debug
383 $(QUIET)$(TOOL_GXX3_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out)
384 endif
385endef
386
Note: See TracBrowser for help on using the repository browser.