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
RevLine 
[93]1# $Id: GCC3PLAIN.kmk 3567 2022-06-26 20:00:02Z bird $
2## @file
[826]3# kBuild Tool Config - Generic GCC v3.2.x or later Using The System GCC, any Unix Linker and Unix Archiver.
[93]4#
[1547]5
6#
[3121]7# Copyright (c) 2004-2017 knut st. osmundsen <bird-kBuild-spam-xviiv@anduin.net>
[93]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#
[1547]26# As a special exception you are granted permission to include this file, via
[1612]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.
[1547]29# This exception does not however invalidate any other reasons why the makefile,
30# program, whatever should not be covered the GPL.
31#
32#
[93]33
[847]34TOOL_GCC3PLAIN := Generic GCC v3.2.x or later Using The System GCC, any Unix Linker and Unix Archiver.
[93]35
[667]36# Tool Specific Properties
[3393]37ifndef TOOL_GCC3PLAIN_PREFIX
38 TOOL_GCC3PLAIN_PREFIX :=
39endif
40ifndef TOOL_GCC3PLAIN_SUFFIX
41 TOOL_GCC3PLAIN_SUFFIX := $(HOSTSUFF_EXE)
42endif
43TOOL_GCC3PLAIN_PRE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H_VARIABLE)
[1504]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)))
[3393]63TOOL_GCC3PLAIN_LD_SONAME.win ?= $(NO_SUCH_VARIABLE)
[1504]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)))
[847]66else
[1504]67 TOOL_GCC3PLAIN_LD_SONAME ?= $(TOOL_GCC3PLAIN_LD_SONAME.$(KBUILD_TARGET))
[847]68endif
[93]69
[667]70# General Properties used by kBuild
[826]71TOOL_GCC3PLAIN_COBJSUFF ?= .o
72TOOL_GCC3PLAIN_CFLAGS ?=
73TOOL_GCC3PLAIN_CFLAGS.debug ?= -g
[1058]74TOOL_GCC3PLAIN_CFLAGS.profile ?= -O2 #-g -pg
[826]75TOOL_GCC3PLAIN_CFLAGS.release ?= -O2
76TOOL_GCC3PLAIN_CINCS ?=
77TOOL_GCC3PLAIN_CDEFS ?=
[137]78
[826]79TOOL_GCC3PLAIN_CXXOBJSUFF ?= .o
80TOOL_GCC3PLAIN_CXXOBJSUFF ?= .o
81TOOL_GCC3PLAIN_CXXFLAGS ?=
82TOOL_GCC3PLAIN_CXXFLAGS.debug ?= -g
[1058]83TOOL_GCC3PLAIN_CXXFLAGS.profile ?= -O2 #-g -pg
[826]84TOOL_GCC3PLAIN_CXXFLAGS.release ?= -O2
85TOOL_GCC3PLAIN_CXXINCS ?=
86TOOL_GCC3PLAIN_CXXDEFS ?=
[667]87
[826]88TOOL_GCC3PLAIN_ASFLAGS ?= -x assembler-with-cpp
89TOOL_GCC3PLAIN_ASFLAGS.debug ?= -g
90TOOL_GCC3PLAIN_ASFLAGS.profile ?= -g
91TOOL_GCC3PLAIN_ASOBJSUFF ?= .o
[667]92
[826]93TOOL_GCC3PLAIN_ARFLAGS ?= cr
94TOOL_GCC3PLAIN_ARLIBSUFF ?= .a
[667]95
[826]96TOOL_GCC3PLAIN_LDFLAGS ?=
[667]97
98
[93]99## Compile C source.
100# @param $(target) Normalized main target name.
101# @param $(source) Source filename (relative).
[235]102# @param $(obj) Object file name. This shall be (re)created by the compilation.
[93]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.
[235]107# @param $(dirdep) Directory creation dependency.
108# @param $(deps) Other dependencies.
[93]109#
110# @param $(outbase) Output basename (full). Use this for list files and such.
[235]111# @param $(objsuff) Object suffix.
[826]112TOOL_GCC3PLAIN_COMPILE_C_DEPEND =
113TOOL_GCC3PLAIN_COMPILE_C_DEPORD =
[1418]114ifdef KBUILD_USE_KOBJCACHE
[1015]115TOOL_GCC3PLAIN_COMPILE_C_USES_KOBJCACHE = 1
116TOOL_GCC3PLAIN_COMPILE_C_OUTPUT = $(outbase).i
[826]117define TOOL_GCC3PLAIN_COMPILE_C_CMDS
[1058]118 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
119 --kObjCache-cpp $(outbase).i\
[1015]120 $(TOOL_GCC3PLAIN_CC) -E -o -\
[3566]121 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
[1015]122 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
[1058]123 $(abspath $(source))\
124 --kObjCache-cc $(obj)\
[1015]125 $(TOOL_GCC3PLAIN_CC) -c\
[1058]126 $(flags) -fpreprocessed -x c\
[1015]127 -o $(obj)\
[1058]128 -
[2431]129 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
[1015]130endef
[1418]131else # !KBUILD_USE_KOBJCACHE
[1015]132TOOL_GCC3PLAIN_COMPILE_C_OUTPUT =
133define TOOL_GCC3PLAIN_COMPILE_C_CMDS
[826]134 $(QUIET)$(TOOL_GCC3PLAIN_CC) -c\
[3566]135 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
[380]136 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
137 -o $(obj)\
[697]138 $(abspath $(source))
[2431]139 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
[93]140endef
[1418]141endif # !KBUILD_USE_KOBJCACHE
[93]142
143
144## Compile C++ source.
145# @param $(target) Normalized main target name.
146# @param $(source) Source filename (relative).
[235]147# @param $(obj) Object file name. This shall be (re)created by the compilation.
[93]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.
[235]152# @param $(dirdep) Directory creation dependency.
153# @param $(deps) Other dependencies.
[93]154# @param $(outbase) Output basename (full). Use this for list files and such.
[235]155# @param $(objsuff) Object suffix.
[826]156TOOL_GCC3PLAIN_COMPILE_CXX_DEPEND =
157TOOL_GCC3PLAIN_COMPILE_CXX_DEPORD =
[1418]158ifdef KBUILD_USE_KOBJCACHE
[1015]159TOOL_GCC3PLAIN_COMPILE_CXX_USES_KOBJCACHE = 1
160TOOL_GCC3PLAIN_COMPILE_CXX_OUTPUT = $(outbase).ii
[826]161define TOOL_GCC3PLAIN_COMPILE_CXX_CMDS
[1058]162 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
163 --kObjCache-cpp $(outbase).ii\
[1015]164 $(TOOL_GCC3PLAIN_CXX) -E -o -\
[3566]165 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
[1015]166 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
[1058]167 $(abspath $(source))\
168 --kObjCache-cc $(obj)\
[1015]169 $(TOOL_GCC3PLAIN_CXX) -c\
[1058]170 $(flags) -fpreprocessed -x c++\
[1015]171 -o $(obj)\
[1058]172 -
[2431]173 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
[1015]174endef
[1418]175else # !KBUILD_USE_KOBJCACHE
[1015]176TOOL_GCC3PLAIN_COMPILE_CXX_OUTPUT =
177define TOOL_GCC3PLAIN_COMPILE_CXX_CMDS
[826]178 $(QUIET)$(TOOL_GCC3PLAIN_CXX) -c\
[3566]179 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
[380]180 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
181 -o $(obj)\
[697]182 $(abspath $(source))
[2431]183 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
[93]184endef
[1418]185endif # !KBUILD_USE_KOBJCACHE
[93]186
187
[461]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#
[826]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\
[3566]206 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
[461]207 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
208 -o $(obj)\
[697]209 $(abspath $(source))
[2431]210 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
[461]211endef
212
213
[93]214## Link library
215# @param $(target) Normalized main target name.
[380]216# @param $(out) Library name.
[93]217# @param $(objs) Object files to put in the library.
218# @param $(flags) Flags.
[235]219# @param $(dirdep) Directory creation dependency.
220# @param $(deps) Other dependencies.
221# @param $(othersrc) Unhandled sources.
[93]222# @param $(outbase) Output basename (full). Use this for list files and such.
[1098]223TOOL_GCC3PLAIN_LINK_LIBRARY_OUTPUT =
[826]224TOOL_GCC3PLAIN_LINK_LIBRARY_DEPEND = $(othersrc)
225TOOL_GCC3PLAIN_LINK_LIBRARY_DEPORD =
226define TOOL_GCC3PLAIN_LINK_LIBRARY_CMDS
[847]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/)
[826]237 $(QUIET)$(TOOL_GCC3PLAIN_RANLIB) $(out)
[772]238endef
[206]239
240
[93]241## Link program
242# @param $(target) Normalized main target name.
[353]243# @param $(out) Program name.
[93]244# @param $(objs) Object files to link together.
245# @param $(libs) Libraries to search.
246# @param $(libpath) Library search paths.
247# @param $(flags) Flags.
[235]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.
[93]253# @param $(outbase) Output basename (full). Use this for list files and such.
[1033]254TOOL_GCC3PLAIN_LINK_PROGRAM_OUTPUT =
255TOOL_GCC3PLAIN_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map
[826]256TOOL_GCC3PLAIN_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
[572]257 $(filter %.def, $(othersrc))
[826]258TOOL_GCC3PLAIN_LINK_PROGRAM_DEPORD =
259define TOOL_GCC3PLAIN_LINK_PROGRAM_CMDS
260 $(QUIET)$(TOOL_GCC3PLAIN_LD) $(flags) -o $(out) $(objs)\
[572]261 $(filter %.def, $(othersrc))\
[380]262 $(foreach p,$(libpath), -L$(p))\
[1259]263 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
[93]264endef
265
[130]266
267## Link DLL
268# @param $(target) Normalized main target name.
[353]269# @param $(out) Program name.
[130]270# @param $(objs) Object files to link together.
271# @param $(libs) Libraries to search.
272# @param $(libpath) Library search paths.
273# @param $(flags) Flags.
[235]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.
[130]279# @param $(outbase) Output basename (full). Use this for list files and such.
[1033]280TOOL_GCC3PLAIN_LINK_DLL_OUTPUT =
281TOOL_GCC3PLAIN_LINK_DLL_OUTPUT_MAYBE = $(outbase).map
[826]282TOOL_GCC3PLAIN_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
[572]283 $(filter %.def, $(othersrc))
[826]284TOOL_GCC3PLAIN_LINK_DLL_DEPORD =
285define TOOL_GCC3PLAIN_LINK_DLL_CMDS
286 $(QUIET)$(TOOL_GCC3PLAIN_LD) $(TOOL_GCC3PLAIN_LDFLAGS.dll) $(flags) -o $(out)\
[1504]287 $(if $(filter-out win32 os2, $(KBUILD_TARGET)),$(call TOOL_GCC3PLAIN_LD_SONAME,$(target),$(out)))\
[380]288 $(objs)\
[572]289 $(filter %.def, $(othersrc))\
[380]290 $(foreach p,$(libpath), -L$(p))\
[1259]291 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
[130]292endef
293
[1084]294
295## Link system module (windows aka driver, linux aka kernel module)
[1259]296# This tool target might not work everywhere, but is provided for the
[1084]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))\
[1612]322 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
[1084]323endef
324
Note: See TracBrowser for help on using the repository browser.