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

Last change on this file since 2182 was 2018, checked in by bird, 17 years ago

kBuild: svn attributes and some minor file header adjustments and corrections (still GPLv2 w/ big fat exception).

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