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

Last change on this file since 3258 was 3258, checked in by bird, 7 years ago

tools/*GXX*: Precompiled header and some kObjCache updates.

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