VirtualBox

source: kBuild/trunk/kBuild/tools/GXX.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: 10.7 KB
Line 
1# $Id: GXX.kmk 3391 2020-06-30 08:08:15Z bird $
2## @file
3# kBuild Tool Config - Generic GCC using the system GCC, for building C++ code.
4#
5
6#
7# Copyright (c) 2004-2017 knut st. osmundsen <[email protected]>
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_GXX := Generic GCC using the system GCC, for building C++ code.
35
36# Tool Specific Properties
37ifndef TOOL_GXX_PREFIX
38 TOOL_GXX_PREFIX :=
39endif
40ifndef TOOL_GXX_SUFFIX
41 TOOL_GXX_SUFFIX := $(HOSTSUFF_EXE)
42endif
43TOOL_GXX_CC ?= $(TOOL_GXX_PREFIX)gcc$(TOOL_GXX_SUFFIX)
44TOOL_GXX_CXX ?= $(TOOL_GXX_PREFIX)g++$(TOOL_GXX_SUFFIX)
45TOOL_GXX_PCH ?= $(TOOL_GXX_CXX)
46TOOL_GXX_AS ?= $(TOOL_GXX_PREFIX)gcc$(TOOL_GXX_SUFFIX)
47TOOL_GXX_AR ?= $(TOOL_GXX_PREFIX)ar$(TOOL_GXX_SUFFIX)
48TOOL_GXX_RANLIB ?= $(TOOL_GXX_PREFIX)ranlib$(TOOL_GXX_SUFFIX)
49TOOL_GXX_LD ?= $(TOOL_GXX_PREFIX)g++$(TOOL_GXX_SUFFIX)
50TOOL_GXX_LDFLAGS.dll.os2 ?= -Zdll
51TOOL_GXX_LDFLAGS.dll.darwin ?= -dynamiclib
52ifndef TOOL_GXX_LDFLAGS.$(KBUILD_TARGET)
53 TOOL_GXX_LDFLAGS.dll ?= -shared
54else
55 TOOL_GXX_LDFLAGS.dll ?= $(TOOL_GXX_LDFLAGS.$(KBUILD_TARGET))
56endif
57
58# General Properties used by kBuild
59TOOL_GXX_COBJSUFF ?= .o
60TOOL_GXX_CFLAGS ?=
61TOOL_GXX_CFLAGS.debug ?= -g
62TOOL_GXX_CFLAGS.profile ?= -g -O2 #-pg
63TOOL_GXX_CFLAGS.release ?= -O2
64TOOL_GXX_CINCS ?=
65TOOL_GXX_CDEFS ?=
66
67TOOL_GXX_CXXOBJSUFF ?= .o
68TOOL_GXX_CXXOBJSUFF ?= .o
69TOOL_GXX_CXXFLAGS ?=
70TOOL_GXX_CXXFLAGS.debug ?= -g -O0
71TOOL_GXX_CXXFLAGS.profile ?= -g -O2 #-pg
72TOOL_GXX_CXXFLAGS.release ?= -O2
73TOOL_GXX_CXXINCS ?=
74TOOL_GXX_CXXDEFS ?=
75
76TOOL_GXX_PCHOBJSUFF ?= .h.gch
77TOOL_GXX_PCHFLAGS ?= $(TOOL_GXX_CXXFLAGS)
78TOOL_GXX_PCHFLAGS.debug ?= $(TOOL_GXX_CXXFLAGS.debug)
79TOOL_GXX_PCHFLAGS.profile ?= $(TOOL_GXX_CXXFLAGS.profile)
80TOOL_GXX_PCHFLAGS.release ?= $(TOOL_GXX_CXXFLAGS.release)
81TOOL_GXX_PCHINCS ?= $(TOOL_GXX_CXXINCS)
82TOOL_GXX_PCHDEFS ?= $(TOOL_GXX_CXXDEFS)
83
84TOOL_GXX_ASFLAGS ?= -x assembler-with-cpp
85TOOL_GXX_ASFLAGS.debug ?= -g
86TOOL_GXX_ASFLAGS.profile ?= -g
87TOOL_GXX_ASOBJSUFF ?= .o
88
89TOOL_GXX_ARFLAGS ?= cr
90TOOL_GXX_ARLIBSUFF ?= .a
91
92TOOL_GXX_LDFLAGS ?=
93TOOL_GXX_LDFLAGS.debug ?= -g
94TOOL_GXX_LDFLAGS.profile ?= -g
95
96
97## Compile C source.
98# @param $(target) Normalized main target name.
99# @param $(source) Source filename (relative).
100# @param $(obj) Object file name. This shall be (re)created by the compilation.
101# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
102# @param $(flags) Flags.
103# @param $(defs) Definitions. No -D or something.
104# @param $(incs) Includes. No -I or something.
105# @param $(dirdep) Directory creation dependency.
106# @param $(deps) Other dependencies.
107# @param $(outbase) Output basename (full). Use this for list files and such.
108# @param $(objsuff) Object suffix.
109#
110TOOL_GXX_COMPILE_C_OUTPUT =
111TOOL_GXX_COMPILE_C_DEPEND =
112TOOL_GXX_COMPILE_C_DEPORD =
113define TOOL_GXX_COMPILE_C_CMDS
114 $(QUIET)$(TOOL_GXX_CC) -c\
115 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
116 -Wp,-MD,$(dep) -Wp,-MT,$(obj) \
117 -o $(obj)\
118 $(abspath $(source))
119 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
120endef
121
122
123## Compile C++ source.
124# @param $(target) Normalized main target name.
125# @param $(source) Source filename (relative).
126# @param $(obj) Object file name. This shall be (re)created by the compilation.
127# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
128# @param $(flags) Flags.
129# @param $(defs) Definitions. No -D or something.
130# @param $(incs) Includes. No -I or something.
131# @param $(dirdep) Directory creation dependency.
132# @param $(deps) Other dependencies.
133#
134# @param $(outbase) Output basename (full). Use this for list files and such.
135# @param $(objsuff) Object suffix.
136TOOL_GXX_COMPILE_CXX_OUTPUT =
137TOOL_GXX_COMPILE_CXX_DEPEND = $($(target)_1_GCC_PCH_FILE)
138TOOL_GXX_COMPILE_CXX_DEPORD =
139define TOOL_GXX_COMPILE_CXX_CMDS
140 $(QUIET)$(TOOL_GXX_CXX) -c\
141 $(flags) $(addprefix -I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(addprefix -D, $(defs))\
142 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
143 -o $(obj) $(if-expr defined($(target)_PCH_HDR) \
144 ,-Winvalid-pch -include $(basename $($(target)_1_GCC_PCH_FILE)),) \
145 $(abspath $(source))
146 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
147endef
148
149
150## Precompile C++ header.
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_GXX_COMPILE_PCH_OUTPUT = $($(target)_1_GCC_PCH_FILE)
163TOOL_GXX_COMPILE_PCH_DEPEND =
164TOOL_GXX_COMPILE_PCH_DEPORD = $($(target)_1_GCC_PCH_DIR)
165define TOOL_GXX_COMPILE_PCH_CMDS
166 $(QUIET)$(TOOL_GXX_PCH) -c\
167 $(flags) $(addprefix -I, $($(target)_1_GCC_PCH_DIR) $(incs)) $(addprefix -D, $(defs))\
168 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
169 -o $(obj)\
170 $(abspath $(source))
171 $(INSTALL) --hard-link-files-when-possible -m 0644 -- "$(obj)" "$($(target)_1_GCC_PCH_FILE)"
172 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
173endef
174
175
176## Compile Assembly source.
177# @param $(target) Normalized main target name.
178# @param $(source) Source filename (relative).
179# @param $(obj) Object file name. This shall be (re)created by the compilation.
180# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
181# @param $(flags) Flags.
182# @param $(defs) Definitions. No -D or something.
183# @param $(incs) Includes. No -I or something.
184# @param $(dirdep) Directory creation dependency.
185# @param $(deps) Other dependencies.
186# @param $(outbase) Output basename (full). Use this for list files and such.
187# @param $(objsuff) Object suffix.
188#
189TOOL_GXX_COMPILE_AS_OUTPUT =
190TOOL_GXX_COMPILE_AS_DEPEND =
191TOOL_GXX_COMPILE_AS_DEPORD =
192define TOOL_GXX_COMPILE_AS_CMDS
193 $(QUIET)$(TOOL_GXX_AS) -c\
194 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
195 -Wp,-MD,$(dep) -Wp,-MT,$(obj) \
196 -o $(obj)\
197 $(abspath $(source))
198 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
199endef
200
201
202## Link library
203# @param $(target) Normalized main target name.
204# @param $(out) Library name.
205# @param $(objs) Object files to put in the library.
206# @param $(flags) Flags.
207# @param $(dirdep) Directory creation dependency.
208# @param $(deps) Other dependencies.
209#
210# @param $(outbase) Output basename (full). Use this for list files and such.
211TOOL_GXX_LINK_LIBRARY_OUTPUT =
212TOOL_GXX_LINK_LIBRARY_DEPEND =
213TOOL_GXX_LINK_LIBRARY_DEPORD =
214define TOOL_GXX_LINK_LIBRARY_CMDS
215 $(QUIET)$(TOOL_GXX_AR) $(flags) $(out) $(filter-out %.h.gch,$(objs))
216 $(call xargs,$(QUIET)$(TOOL_GXX_AR) $(flags) $(out),$(filter-out %.h.gch,$(objs)))
217 $(foreach lib,$(othersrc)\
218 ,$(NL)$(TAB)$(call MSG_AR_MERGE,$(target),$(out),$(lib)) \
219 $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))ar.tmp.dir/* \
220 $(NL)$(TAB)$(QUIET)$(MKDIR) -p $(dir $(outbase))/ar.tmp.dir/ \
221 $(NL)$(TAB)$(QUIET)(cd $(dir $(outbase))ar.tmp.dir/ \
222 && $(TOOL_GXX_AR) x $(abspath $(lib)) \
223 && $(TOOL_GXX_AR) $(flags) $(out) *) \
224 $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))/ar.tmp.dir/* \
225 $(NL)$(TAB)$(QUIET)$(RMDIR) $(dir $(outbase))ar.tmp.dir/)
226 $(QUIET)$(TOOL_GXX_RANLIB) $(out)
227endef
228
229
230## Link program
231# @param $(target) Normalized main target name.
232# @param $(out) Program name.
233# @param $(objs) Object files to link together.
234# @param $(libs) Libraries to search.
235# @param $(libpath) Library search paths.
236# @param $(flags) Flags.
237# @param $(dirdep) Directory creation dependency.
238# @param $(deps) Other dependencies.
239# @param $(othersrc) Unhandled sources.
240# @param $(custom_pre) Custom step invoked before linking.
241# @param $(custom_post) Custom step invoked after linking.
242#
243# @param $(outbase) Output basename (full). Use this for list files and such.
244TOOL_GXX_LINK_PROGRAM_OUTPUT =
245TOOL_GXX_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
246TOOL_GXX_LINK_PROGRAM_DEPORD =
247define TOOL_GXX_LINK_PROGRAM_CMDS
248 $(QUIET)$(TOOL_GXX_LD) $(flags) -o $(out) $(filter-out %.h.gch,$(objs)) \
249 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
250endef
251
252
253## Link DLL
254# @param $(target) Normalized main target name.
255# @param $(out) Program name.
256# @param $(objs) Object files to link together.
257# @param $(libs) Libraries to search.
258# @param $(libpath) Library search paths.
259# @param $(flags) Flags.
260# @param $(dirdep) Directory creation dependency.
261# @param $(deps) Other dependencies.
262# @param $(othersrc) Unhandled sources.
263# @param $(custom_pre) Custom step invoked before linking.
264# @param $(custom_post) Custom step invoked after linking.
265# @param $(outbase) Output basename (full). Use this for list files and such.
266TOOL_GXX_LINK_DLL_OUTPUT =
267TOOL_GXX_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
268TOOL_GXX_LINK_DLL_DEPORD =
269define TOOL_GXX_LINK_DLL_CMDS
270 $(QUIET)$(TOOL_GXX_LD) $(TOOL_GXX_LDFLAGS.dll) $(flags) -o $(out) $(filter-out %.h.gch,$(objs)) \
271 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
272endef
273
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette