source: trunk/kBuild/tools/GCC3PLAIN.kmk@ 3492

Last change on this file since 3492 was 3393, checked in by bird, 5 years ago

tools/*GCC|GXX*: More prefix/suffix stuff. Separate for gcc/g++, binutils and other stuff.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.6 KB
Line 
1# $Id: GCC3PLAIN.kmk 3393 2020-06-30 17:11:42Z bird $
2## @file
3# kBuild Tool Config - Generic GCC v3.2.x or later Using The System GCC, any Unix Linker and Unix Archiver.
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_GCC3PLAIN := Generic GCC v3.2.x or later Using The System GCC, any Unix Linker and Unix Archiver.
35
36# Tool Specific Properties
37ifndef TOOL_GCC3PLAIN_PREFIX
38 TOOL_GCC3PLAIN_PREFIX :=
39endif
40ifndef TOOL_GCC3PLAIN_SUFFIX
41 TOOL_GCC3PLAIN_SUFFIX := $(HOSTSUFF_EXE)
42endif
43TOOL_GCC3PLAIN_PREFIX2 ?= $(TOOL_GCC3PLAIN_PREFIX)
44TOOL_GCC3PLAIN_SUFFIX2 ?= $(TOOL_GCC3PLAIN_SUFFIX)
45TOOL_GCC3PLAIN_CC ?= $(TOOL_GCC3PLAIN_PREFIX)gcc$(TOOL_GCC3PLAIN_SUFFIX)
46TOOL_GCC3PLAIN_CXX ?= $(TOOL_GCC3PLAIN_PREFIX)g++$(TOOL_GCC3PLAIN_SUFFIX)
47TOOL_GCC3PLAIN_AS ?= $(TOOL_GCC3PLAIN_PREFIX)gcc$(TOOL_GCC3PLAIN_SUFFIX)
48TOOL_GCC3PLAIN_AR ?= $(TOOL_GCC3PLAIN_PREFIX2)ar$(TOOL_GCC3PLAIN_SUFFIX2)
49TOOL_GCC3PLAIN_RANLIB ?= $(TOOL_GCC3PLAIN_PREFIX2)ranlib$(TOOL_GCC3PLAIN_SUFFIX2)
50TOOL_GCC3PLAIN_LD ?= $(TOOL_GCC3PLAIN_PREFIX)gcc$(TOOL_GCC3PLAIN_SUFFIX)
51TOOL_GCC3PLAIN_LD_SYSMOD ?= $(TOOL_GCC3PLAIN_PREFIX2)ld$(TOOL_GCC3PLAIN_SUFFIX2)
52TOOL_GCC3PLAIN_LD_SYSMOD.os2 ?= $(TOOL_GCC3PLAIN_PREFIX)g++$(TOOL_GCC3PLAIN_SUFFIX)
53TOOL_GCC3PLAIN_LDFLAGS.dll.os2 ?= -Zdll
54TOOL_GCC3PLAIN_LDFLAGS.dll.darwin ?= -dynamiclib
55ifndef TOOL_GCC3PLAIN_LDFLAGS.$(KBUILD_TARGET)
56 TOOL_GCC3PLAIN_LDFLAGS.dll ?= -shared
57else
58 TOOL_GCC3PLAIN_LDFLAGS.dll ?= $(TOOL_GCC3PLAIN_LDFLAGS.$(KBUILD_TARGET))
59endif
60TOOL_GCC3PLAIN_LD_SONAME.darwin ?= $(NO_SUCH_VARIABLE)
61TOOL_GCC3PLAIN_LD_SONAME.os2 ?= $(NO_SUCH_VARIABLE)
62TOOL_GCC3PLAIN_LD_SONAME.solaris ?= -Wl,-h,$(firstword $($(1)_SONAME.$(KBUILD_TARGET).$(KBUILD_TYPE)) $($(1)_SONAME.$(KBUILD_TARGET)) $($(1)_SONAME.$(KBUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
63TOOL_GCC3PLAIN_LD_SONAME.win ?= $(NO_SUCH_VARIABLE)
64ifndef TOOL_GCC3PLAIN_LD_SONAME.$(KBUILD_TARGET)
65 TOOL_GCC3PLAIN_LD_SONAME ?= -Wl,-soname=$(firstword $($(1)_SONAME.$(KBUILD_TARGET).$(KBUILD_TYPE)) $($(1)_SONAME.$(KBUILD_TARGET)) $($(1)_SONAME.$(KBUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
66else
67 TOOL_GCC3PLAIN_LD_SONAME ?= $(TOOL_GCC3PLAIN_LD_SONAME.$(KBUILD_TARGET))
68endif
69ifdef SLKRUNS
70 TOOL_GCC3PLAIN_CC += -fmessage-length=0
71 TOOL_GCC3PLAIN_CXX += -fmessage-length=0
72endif
73
74# General Properties used by kBuild
75TOOL_GCC3PLAIN_COBJSUFF ?= .o
76TOOL_GCC3PLAIN_CFLAGS ?=
77TOOL_GCC3PLAIN_CFLAGS.debug ?= -g
78TOOL_GCC3PLAIN_CFLAGS.profile ?= -O2 #-g -pg
79TOOL_GCC3PLAIN_CFLAGS.release ?= -O2
80TOOL_GCC3PLAIN_CINCS ?=
81TOOL_GCC3PLAIN_CDEFS ?=
82
83TOOL_GCC3PLAIN_CXXOBJSUFF ?= .o
84TOOL_GCC3PLAIN_CXXOBJSUFF ?= .o
85TOOL_GCC3PLAIN_CXXFLAGS ?=
86TOOL_GCC3PLAIN_CXXFLAGS.debug ?= -g
87TOOL_GCC3PLAIN_CXXFLAGS.profile ?= -O2 #-g -pg
88TOOL_GCC3PLAIN_CXXFLAGS.release ?= -O2
89TOOL_GCC3PLAIN_CXXINCS ?=
90TOOL_GCC3PLAIN_CXXDEFS ?=
91
92TOOL_GCC3PLAIN_ASFLAGS ?= -x assembler-with-cpp
93TOOL_GCC3PLAIN_ASFLAGS.debug ?= -g
94TOOL_GCC3PLAIN_ASFLAGS.profile ?= -g
95TOOL_GCC3PLAIN_ASOBJSUFF ?= .o
96
97TOOL_GCC3PLAIN_ARFLAGS ?= cr
98TOOL_GCC3PLAIN_ARLIBSUFF ?= .a
99
100TOOL_GCC3PLAIN_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_GCC3PLAIN_COMPILE_C_DEPEND =
117TOOL_GCC3PLAIN_COMPILE_C_DEPORD =
118ifdef KBUILD_USE_KOBJCACHE
119TOOL_GCC3PLAIN_COMPILE_C_USES_KOBJCACHE = 1
120TOOL_GCC3PLAIN_COMPILE_C_OUTPUT = $(outbase).i
121define TOOL_GCC3PLAIN_COMPILE_C_CMDS
122 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
123 --kObjCache-cpp $(outbase).i\
124 $(TOOL_GCC3PLAIN_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_GCC3PLAIN_CC) -c\
130 $(flags) -fpreprocessed -x c\
131 -o $(obj)\
132 -
133 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
134endef
135else # !KBUILD_USE_KOBJCACHE
136TOOL_GCC3PLAIN_COMPILE_C_OUTPUT =
137define TOOL_GCC3PLAIN_COMPILE_C_CMDS
138 $(QUIET)$(TOOL_GCC3PLAIN_CC) -c\
139 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
140 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
141 -o $(obj)\
142 $(abspath $(source))
143 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
144endef
145endif # !KBUILD_USE_KOBJCACHE
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_GCC3PLAIN_COMPILE_CXX_DEPEND =
161TOOL_GCC3PLAIN_COMPILE_CXX_DEPORD =
162ifdef KBUILD_USE_KOBJCACHE
163TOOL_GCC3PLAIN_COMPILE_CXX_USES_KOBJCACHE = 1
164TOOL_GCC3PLAIN_COMPILE_CXX_OUTPUT = $(outbase).ii
165define TOOL_GCC3PLAIN_COMPILE_CXX_CMDS
166 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
167 --kObjCache-cpp $(outbase).ii\
168 $(TOOL_GCC3PLAIN_CXX) -E -o -\
169 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
170 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
171 $(abspath $(source))\
172 --kObjCache-cc $(obj)\
173 $(TOOL_GCC3PLAIN_CXX) -c\
174 $(flags) -fpreprocessed -x c++\
175 -o $(obj)\
176 -
177 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
178endef
179else # !KBUILD_USE_KOBJCACHE
180TOOL_GCC3PLAIN_COMPILE_CXX_OUTPUT =
181define TOOL_GCC3PLAIN_COMPILE_CXX_CMDS
182 $(QUIET)$(TOOL_GCC3PLAIN_CXX) -c\
183 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
184 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
185 -o $(obj)\
186 $(abspath $(source))
187 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
188endef
189endif # !KBUILD_USE_KOBJCACHE
190
191
192## Compile Assembly source.
193# @param $(target) Normalized main target name.
194# @param $(source) Source filename (relative).
195# @param $(obj) Object file name. This shall be (re)created by the compilation.
196# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
197# @param $(flags) Flags.
198# @param $(defs) Definitions. No -D or something.
199# @param $(incs) Includes. No -I or something.
200# @param $(dirdep) Directory creation dependency.
201# @param $(deps) Other dependencies.
202# @param $(outbase) Output basename (full). Use this for list files and such.
203# @param $(objsuff) Object suffix.
204#
205TOOL_GCC3PLAIN_COMPILE_AS_OUTPUT =
206TOOL_GCC3PLAIN_COMPILE_AS_DEPEND =
207TOOL_GCC3PLAIN_COMPILE_AS_DEPORD =
208define TOOL_GCC3PLAIN_COMPILE_AS_CMDS
209 $(QUIET)$(TOOL_GCC3PLAIN_AS) -c\
210 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
211 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
212 -o $(obj)\
213 $(abspath $(source))
214 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
215endef
216
217
218## Link library
219# @param $(target) Normalized main target name.
220# @param $(out) Library name.
221# @param $(objs) Object files to put in the library.
222# @param $(flags) Flags.
223# @param $(dirdep) Directory creation dependency.
224# @param $(deps) Other dependencies.
225# @param $(othersrc) Unhandled sources.
226# @param $(outbase) Output basename (full). Use this for list files and such.
227TOOL_GCC3PLAIN_LINK_LIBRARY_OUTPUT =
228TOOL_GCC3PLAIN_LINK_LIBRARY_DEPEND = $(othersrc)
229TOOL_GCC3PLAIN_LINK_LIBRARY_DEPORD =
230define TOOL_GCC3PLAIN_LINK_LIBRARY_CMDS
231 $(call xargs,$(QUIET)$(TOOL_GCC3PLAIN_AR) $(flags) $(out),$(objs))
232 $(foreach lib,$(othersrc)\
233 ,$(NL)$(TAB)$(call MSG_AR_MERGE,$(target),$(out),$(lib)) \
234 $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))ar.tmp.dir/* \
235 $(NL)$(TAB)$(QUIET)$(MKDIR) -p $(dir $(outbase))/ar.tmp.dir/ \
236 $(NL)$(TAB)$(QUIET)(cd $(dir $(outbase))ar.tmp.dir/ \
237 && $(TOOL_GCC3PLAIN_AR) x $(abspath $(lib)) \
238 && $(TOOL_GCC3PLAIN_AR) $(flags) $(out) *) \
239 $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))/ar.tmp.dir/* \
240 $(NL)$(TAB)$(QUIET)$(RMDIR) $(dir $(outbase))ar.tmp.dir/)
241 $(QUIET)$(TOOL_GCC3PLAIN_RANLIB) $(out)
242endef
243
244
245## Link program
246# @param $(target) Normalized main target name.
247# @param $(out) Program name.
248# @param $(objs) Object files to link together.
249# @param $(libs) Libraries to search.
250# @param $(libpath) Library search paths.
251# @param $(flags) Flags.
252# @param $(dirdep) Directory creation dependency.
253# @param $(deps) Other dependencies.
254# @param $(othersrc) Unhandled sources.
255# @param $(custom_pre) Custom step invoked before linking.
256# @param $(custom_post) Custom step invoked after linking.
257# @param $(outbase) Output basename (full). Use this for list files and such.
258TOOL_GCC3PLAIN_LINK_PROGRAM_OUTPUT =
259TOOL_GCC3PLAIN_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map
260TOOL_GCC3PLAIN_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
261 $(filter %.def, $(othersrc))
262TOOL_GCC3PLAIN_LINK_PROGRAM_DEPORD =
263define TOOL_GCC3PLAIN_LINK_PROGRAM_CMDS
264 $(QUIET)$(TOOL_GCC3PLAIN_LD) $(flags) -o $(out) $(objs)\
265 $(filter %.def, $(othersrc))\
266 $(foreach p,$(libpath), -L$(p))\
267 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
268endef
269
270
271## Link DLL
272# @param $(target) Normalized main target name.
273# @param $(out) Program name.
274# @param $(objs) Object files to link together.
275# @param $(libs) Libraries to search.
276# @param $(libpath) Library search paths.
277# @param $(flags) Flags.
278# @param $(dirdep) Directory creation dependency.
279# @param $(deps) Other dependencies.
280# @param $(othersrc) Unhandled sources.
281# @param $(custom_pre) Custom step invoked before linking.
282# @param $(custom_post) Custom step invoked after linking.
283# @param $(outbase) Output basename (full). Use this for list files and such.
284TOOL_GCC3PLAIN_LINK_DLL_OUTPUT =
285TOOL_GCC3PLAIN_LINK_DLL_OUTPUT_MAYBE = $(outbase).map
286TOOL_GCC3PLAIN_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
287 $(filter %.def, $(othersrc))
288TOOL_GCC3PLAIN_LINK_DLL_DEPORD =
289define TOOL_GCC3PLAIN_LINK_DLL_CMDS
290 $(QUIET)$(TOOL_GCC3PLAIN_LD) $(TOOL_GCC3PLAIN_LDFLAGS.dll) $(flags) -o $(out)\
291 $(if $(filter-out win32 os2, $(KBUILD_TARGET)),$(call TOOL_GCC3PLAIN_LD_SONAME,$(target),$(out)))\
292 $(objs)\
293 $(filter %.def, $(othersrc))\
294 $(foreach p,$(libpath), -L$(p))\
295 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
296endef
297
298
299## Link system module (windows aka driver, linux aka kernel module)
300# This tool target might not work everywhere, but is provided for the
301# platforms where it works (Solaris, etc).
302#
303# @param $(target) Normalized main target name.
304# @param $(out) System module name.
305# @param $(objs) Object files to link together.
306# @param $(libs) Libraries to search.
307# @param $(libpath) Library search paths.
308# @param $(flags) Flags.
309# @param $(dirdep) Directory creation dependency.
310# @param $(deps) Other dependencies.
311# @param $(othersrc) Unhandled sources.
312# @param $(custom_pre) Custom step invoked before linking.
313# @param $(custom_post) Custom step invoked after linking.
314# @param $(outbase) Output basename (full). Use this for list files and such.
315TOOL_GCC3PLAIN_LINK_SYSMOD_OUTPUT =
316TOOL_GCC3PLAIN_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map
317TOOL_GCC3PLAIN_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
318 $(filter %.def, $(othersrc))
319TOOL_GCC3PLAIN_LINK_SYSMOD_DEPORD =
320define TOOL_GCC3PLAIN_LINK_SYSMOD_CMDS
321 $(QUIET)$(if $(TOOL_GCC3PLAIN_LD_SYSMOD.$(bld_trg)),$(TOOL_GCC3PLAIN_LD_SYSMOD.$(bld_trg)),$(TOOL_GCC3PLAIN_LD_SYSMOD))\
322 $(TOOL_GCC3PLAIN_LDFLAGS_SYSMOD.$(bld_trg)) $(flags) -o $(out)\
323 $(objs)\
324 $(filter %.def, $(othersrc))\
325 $(foreach p,$(libpath), -L$(p))\
326 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
327endef
328
Note: See TracBrowser for help on using the repository browser.