source: trunk/kBuild/tools/GCC3PLAIN.kmk

Last change on this file 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: 13.5 KB
Line 
1# $Id: GCC3PLAIN.kmk 3567 2022-06-26 20:00:02Z 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
69
70# General Properties used by kBuild
71TOOL_GCC3PLAIN_COBJSUFF ?= .o
72TOOL_GCC3PLAIN_CFLAGS ?=
73TOOL_GCC3PLAIN_CFLAGS.debug ?= -g
74TOOL_GCC3PLAIN_CFLAGS.profile ?= -O2 #-g -pg
75TOOL_GCC3PLAIN_CFLAGS.release ?= -O2
76TOOL_GCC3PLAIN_CINCS ?=
77TOOL_GCC3PLAIN_CDEFS ?=
78
79TOOL_GCC3PLAIN_CXXOBJSUFF ?= .o
80TOOL_GCC3PLAIN_CXXOBJSUFF ?= .o
81TOOL_GCC3PLAIN_CXXFLAGS ?=
82TOOL_GCC3PLAIN_CXXFLAGS.debug ?= -g
83TOOL_GCC3PLAIN_CXXFLAGS.profile ?= -O2 #-g -pg
84TOOL_GCC3PLAIN_CXXFLAGS.release ?= -O2
85TOOL_GCC3PLAIN_CXXINCS ?=
86TOOL_GCC3PLAIN_CXXDEFS ?=
87
88TOOL_GCC3PLAIN_ASFLAGS ?= -x assembler-with-cpp
89TOOL_GCC3PLAIN_ASFLAGS.debug ?= -g
90TOOL_GCC3PLAIN_ASFLAGS.profile ?= -g
91TOOL_GCC3PLAIN_ASOBJSUFF ?= .o
92
93TOOL_GCC3PLAIN_ARFLAGS ?= cr
94TOOL_GCC3PLAIN_ARLIBSUFF ?= .a
95
96TOOL_GCC3PLAIN_LDFLAGS ?=
97
98
99## Compile C source.
100# @param $(target) Normalized main target name.
101# @param $(source) Source filename (relative).
102# @param $(obj) Object file name. This shall be (re)created by the compilation.
103# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
104# @param $(flags) Flags.
105# @param $(defs) Definitions. No -D or something.
106# @param $(incs) Includes. No -I or something.
107# @param $(dirdep) Directory creation dependency.
108# @param $(deps) Other dependencies.
109#
110# @param $(outbase) Output basename (full). Use this for list files and such.
111# @param $(objsuff) Object suffix.
112TOOL_GCC3PLAIN_COMPILE_C_DEPEND =
113TOOL_GCC3PLAIN_COMPILE_C_DEPORD =
114ifdef KBUILD_USE_KOBJCACHE
115TOOL_GCC3PLAIN_COMPILE_C_USES_KOBJCACHE = 1
116TOOL_GCC3PLAIN_COMPILE_C_OUTPUT = $(outbase).i
117define TOOL_GCC3PLAIN_COMPILE_C_CMDS
118 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
119 --kObjCache-cpp $(outbase).i\
120 $(TOOL_GCC3PLAIN_CC) -E -o -\
121 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
122 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
123 $(abspath $(source))\
124 --kObjCache-cc $(obj)\
125 $(TOOL_GCC3PLAIN_CC) -c\
126 $(flags) -fpreprocessed -x c\
127 -o $(obj)\
128 -
129 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
130endef
131else # !KBUILD_USE_KOBJCACHE
132TOOL_GCC3PLAIN_COMPILE_C_OUTPUT =
133define TOOL_GCC3PLAIN_COMPILE_C_CMDS
134 $(QUIET)$(TOOL_GCC3PLAIN_CC) -c\
135 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
136 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
137 -o $(obj)\
138 $(abspath $(source))
139 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
140endef
141endif # !KBUILD_USE_KOBJCACHE
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_GCC3PLAIN_COMPILE_CXX_DEPEND =
157TOOL_GCC3PLAIN_COMPILE_CXX_DEPORD =
158ifdef KBUILD_USE_KOBJCACHE
159TOOL_GCC3PLAIN_COMPILE_CXX_USES_KOBJCACHE = 1
160TOOL_GCC3PLAIN_COMPILE_CXX_OUTPUT = $(outbase).ii
161define TOOL_GCC3PLAIN_COMPILE_CXX_CMDS
162 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
163 --kObjCache-cpp $(outbase).ii\
164 $(TOOL_GCC3PLAIN_CXX) -E -o -\
165 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
166 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
167 $(abspath $(source))\
168 --kObjCache-cc $(obj)\
169 $(TOOL_GCC3PLAIN_CXX) -c\
170 $(flags) -fpreprocessed -x c++\
171 -o $(obj)\
172 -
173 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
174endef
175else # !KBUILD_USE_KOBJCACHE
176TOOL_GCC3PLAIN_COMPILE_CXX_OUTPUT =
177define TOOL_GCC3PLAIN_COMPILE_CXX_CMDS
178 $(QUIET)$(TOOL_GCC3PLAIN_CXX) -c\
179 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
180 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
181 -o $(obj)\
182 $(abspath $(source))
183 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
184endef
185endif # !KBUILD_USE_KOBJCACHE
186
187
188## Compile Assembly source.
189# @param $(target) Normalized main target name.
190# @param $(source) Source filename (relative).
191# @param $(obj) Object file name. This shall be (re)created by the compilation.
192# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
193# @param $(flags) Flags.
194# @param $(defs) Definitions. No -D or something.
195# @param $(incs) Includes. No -I or something.
196# @param $(dirdep) Directory creation dependency.
197# @param $(deps) Other dependencies.
198# @param $(outbase) Output basename (full). Use this for list files and such.
199# @param $(objsuff) Object suffix.
200#
201TOOL_GCC3PLAIN_COMPILE_AS_OUTPUT =
202TOOL_GCC3PLAIN_COMPILE_AS_DEPEND =
203TOOL_GCC3PLAIN_COMPILE_AS_DEPORD =
204define TOOL_GCC3PLAIN_COMPILE_AS_CMDS
205 $(QUIET)$(TOOL_GCC3PLAIN_AS) -c\
206 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
207 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
208 -o $(obj)\
209 $(abspath $(source))
210 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
211endef
212
213
214## Link library
215# @param $(target) Normalized main target name.
216# @param $(out) Library name.
217# @param $(objs) Object files to put in the library.
218# @param $(flags) Flags.
219# @param $(dirdep) Directory creation dependency.
220# @param $(deps) Other dependencies.
221# @param $(othersrc) Unhandled sources.
222# @param $(outbase) Output basename (full). Use this for list files and such.
223TOOL_GCC3PLAIN_LINK_LIBRARY_OUTPUT =
224TOOL_GCC3PLAIN_LINK_LIBRARY_DEPEND = $(othersrc)
225TOOL_GCC3PLAIN_LINK_LIBRARY_DEPORD =
226define TOOL_GCC3PLAIN_LINK_LIBRARY_CMDS
227 $(call xargs,$(QUIET)$(TOOL_GCC3PLAIN_AR) $(flags) $(out),$(objs))
228 $(foreach lib,$(othersrc)\
229 ,$(NL)$(TAB)$(call MSG_AR_MERGE,$(target),$(out),$(lib)) \
230 $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))ar.tmp.dir/* \
231 $(NL)$(TAB)$(QUIET)$(MKDIR) -p $(dir $(outbase))/ar.tmp.dir/ \
232 $(NL)$(TAB)$(QUIET)(cd $(dir $(outbase))ar.tmp.dir/ \
233 && $(TOOL_GCC3PLAIN_AR) x $(abspath $(lib)) \
234 && $(TOOL_GCC3PLAIN_AR) $(flags) $(out) *) \
235 $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))/ar.tmp.dir/* \
236 $(NL)$(TAB)$(QUIET)$(RMDIR) $(dir $(outbase))ar.tmp.dir/)
237 $(QUIET)$(TOOL_GCC3PLAIN_RANLIB) $(out)
238endef
239
240
241## Link program
242# @param $(target) Normalized main target name.
243# @param $(out) Program name.
244# @param $(objs) Object files to link together.
245# @param $(libs) Libraries to search.
246# @param $(libpath) Library search paths.
247# @param $(flags) Flags.
248# @param $(dirdep) Directory creation dependency.
249# @param $(deps) Other dependencies.
250# @param $(othersrc) Unhandled sources.
251# @param $(custom_pre) Custom step invoked before linking.
252# @param $(custom_post) Custom step invoked after linking.
253# @param $(outbase) Output basename (full). Use this for list files and such.
254TOOL_GCC3PLAIN_LINK_PROGRAM_OUTPUT =
255TOOL_GCC3PLAIN_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map
256TOOL_GCC3PLAIN_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
257 $(filter %.def, $(othersrc))
258TOOL_GCC3PLAIN_LINK_PROGRAM_DEPORD =
259define TOOL_GCC3PLAIN_LINK_PROGRAM_CMDS
260 $(QUIET)$(TOOL_GCC3PLAIN_LD) $(flags) -o $(out) $(objs)\
261 $(filter %.def, $(othersrc))\
262 $(foreach p,$(libpath), -L$(p))\
263 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
264endef
265
266
267## Link DLL
268# @param $(target) Normalized main target name.
269# @param $(out) Program name.
270# @param $(objs) Object files to link together.
271# @param $(libs) Libraries to search.
272# @param $(libpath) Library search paths.
273# @param $(flags) Flags.
274# @param $(dirdep) Directory creation dependency.
275# @param $(deps) Other dependencies.
276# @param $(othersrc) Unhandled sources.
277# @param $(custom_pre) Custom step invoked before linking.
278# @param $(custom_post) Custom step invoked after linking.
279# @param $(outbase) Output basename (full). Use this for list files and such.
280TOOL_GCC3PLAIN_LINK_DLL_OUTPUT =
281TOOL_GCC3PLAIN_LINK_DLL_OUTPUT_MAYBE = $(outbase).map
282TOOL_GCC3PLAIN_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
283 $(filter %.def, $(othersrc))
284TOOL_GCC3PLAIN_LINK_DLL_DEPORD =
285define TOOL_GCC3PLAIN_LINK_DLL_CMDS
286 $(QUIET)$(TOOL_GCC3PLAIN_LD) $(TOOL_GCC3PLAIN_LDFLAGS.dll) $(flags) -o $(out)\
287 $(if $(filter-out win32 os2, $(KBUILD_TARGET)),$(call TOOL_GCC3PLAIN_LD_SONAME,$(target),$(out)))\
288 $(objs)\
289 $(filter %.def, $(othersrc))\
290 $(foreach p,$(libpath), -L$(p))\
291 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
292endef
293
294
295## Link system module (windows aka driver, linux aka kernel module)
296# This tool target might not work everywhere, but is provided for the
297# platforms where it works (Solaris, etc).
298#
299# @param $(target) Normalized main target name.
300# @param $(out) System module name.
301# @param $(objs) Object files to link together.
302# @param $(libs) Libraries to search.
303# @param $(libpath) Library search paths.
304# @param $(flags) Flags.
305# @param $(dirdep) Directory creation dependency.
306# @param $(deps) Other dependencies.
307# @param $(othersrc) Unhandled sources.
308# @param $(custom_pre) Custom step invoked before linking.
309# @param $(custom_post) Custom step invoked after linking.
310# @param $(outbase) Output basename (full). Use this for list files and such.
311TOOL_GCC3PLAIN_LINK_SYSMOD_OUTPUT =
312TOOL_GCC3PLAIN_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map
313TOOL_GCC3PLAIN_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
314 $(filter %.def, $(othersrc))
315TOOL_GCC3PLAIN_LINK_SYSMOD_DEPORD =
316define TOOL_GCC3PLAIN_LINK_SYSMOD_CMDS
317 $(QUIET)$(if $(TOOL_GCC3PLAIN_LD_SYSMOD.$(bld_trg)),$(TOOL_GCC3PLAIN_LD_SYSMOD.$(bld_trg)),$(TOOL_GCC3PLAIN_LD_SYSMOD))\
318 $(TOOL_GCC3PLAIN_LDFLAGS_SYSMOD.$(bld_trg)) $(flags) -o $(out)\
319 $(objs)\
320 $(filter %.def, $(othersrc))\
321 $(foreach p,$(libpath), -L$(p))\
322 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
323endef
324
Note: See TracBrowser for help on using the repository browser.