source: trunk/kBuild/tools/GCC64.kmk@ 3675

Last change on this file since 3675 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.6 KB
Line 
1# $Id: GCC64.kmk 3567 2022-06-26 20:00:02Z bird $
2## @file
3# kBuild Tool Config - Generic 64-bit GCC v3.2.x or later Using The System GCC.
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_GCC64 := Generic 64-bit GCC v3.2.x or later Using The System GCC. \
35 More or less Linux/ELF specfic.
36
37# Tool Specific Properties
38ifndef TOOL_GCC64_PREFIX
39 TOOL_GCC64_PREFIX :=
40endif
41ifndef TOOL_GCC64_SUFFIX
42 TOOL_GCC64_SUFFIX := $(HOSTSUFF_EXE)
43endif
44if1of ($(KBUILD_HOST), solaris)
45 TOOL_GCC64_PREFIX2 ?= g
46else
47 TOOL_GCC64_PREFIX2 ?=
48endif
49TOOL_GCC64_SUFFIX2 ?= $(HOSTSUFF_EXE)
50TOOL_GCC64_PREFIX3 ?=
51TOOL_GCC64_SUFFIX3 ?= $(HOSTSUFF_EXE)
52TOOL_GCC64_CC ?= $(TOOL_GCC64_PREFIX)gcc$(TOOL_GCC64_SUFFIX) -m64
53TOOL_GCC64_CXX ?= $(TOOL_GCC64_PREFIX)g++$(TOOL_GCC64_SUFFIX) -m64
54TOOL_GCC64_AS ?= $(TOOL_GCC64_PREFIX)gcc$(TOOL_GCC64_SUFFIX) -m64
55TOOL_GCC64_AR ?= $(TOOL_GCC64_PREFIX2)ar$(TOOL_GCC64_SUFFIX2)
56TOOL_GCC64_LD ?= $(TOOL_GCC64_PREFIX)gcc$(TOOL_GCC64_SUFFIX) -m64
57if1of ($(KBUILD_HOST), solaris)
58 TOOL_GCC64_LD_SYSMOD ?= $(TOOL_GCC64_PREFIX3)ld$(TOOL_GCC64_SUFFIX3)
59else
60 TOOL_GCC64_LD_SYSMOD ?= $(TOOL_GCC64_PREFIX2)ld$(TOOL_GCC64_SUFFIX2)
61endif
62ifndef TOOL_GCC64_LDFLAGS.$(KBUILD_TARGET)
63 TOOL_GCC64_LDFLAGS.dll ?= -shared
64else
65 TOOL_GCC64_LDFLAGS.dll ?= $(TOOL_GCC64_LDFLAGS.$(KBUILD_TARGET))
66endif
67TOOL_GCC64_LDFLAGS.sysmod ?= -r -m elf_x86_64$(if-expr "$(KBUILD_TARGET)" == "freebsd" || "$(KBUILD_TARGET)" == "gnukfbsd",_fbsd,)
68TOOL_GCC64_LD_SONAME ?= -Wl,-soname=$(firstword $($(1)_SONAME.$(KBUILD_TARGET).$(KBUILD_TYPE)) $($(1)_SONAME.$(KBUILD_TARGET)) $($(1)_SONAME.$(KBUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
69ifeq ($(KBUILD_TARGET),os2)
70 TOOL_GCC64_LD_MAP ?= -Zmap=$(1)
71else
72 TOOL_GCC64_LD_MAP ?=
73endif
74ifeq ($(KBUILD_TARGET),os2)
75 TOOL_GCC64_LD_SYSMOD_MAP ?= -Zmap=$(1)
76else
77 TOOL_GCC64_LD_SYSMOD_MAP ?=
78endif
79TOOL_GCC64_OBJCOPY ?= $(TOOL_GCC64_PREFIX2)gobjcopy$(TOOL_GCC64_SUFFIX2)
80
81# General Properties used by kBuild
82TOOL_GCC64_COBJSUFF ?= .o
83TOOL_GCC64_CFLAGS ?=
84TOOL_GCC64_CFLAGS.debug ?= -g
85TOOL_GCC64_CFLAGS.profile ?= -O2 #-g -pg
86TOOL_GCC64_CFLAGS.release ?= -O2
87TOOL_GCC64_CINCS ?=
88TOOL_GCC64_CDEFS ?=
89
90TOOL_GCC64_CXXOBJSUFF ?= .o
91TOOL_GCC64_CXXOBJSUFF ?= .o
92TOOL_GCC64_CXXFLAGS ?=
93TOOL_GCC64_CXXFLAGS.debug ?= -g
94TOOL_GCC64_CXXFLAGS.profile ?= -O2 #-g -pg
95TOOL_GCC64_CXXFLAGS.release ?= -O2
96TOOL_GCC64_CXXINCS ?=
97TOOL_GCC64_CXXDEFS ?=
98
99TOOL_GCC64_ASFLAGS ?= -x assembler-with-cpp
100TOOL_GCC64_ASFLAGS.debug ?= -g
101TOOL_GCC64_ASFLAGS.profile ?= -g
102TOOL_GCC64_ASOBJSUFF ?= .o
103
104TOOL_GCC64_ARFLAGS ?= cr
105TOOL_GCC64_ARLIBSUFF ?= .a
106
107TOOL_GCC64_LDFLAGS ?=
108TOOL_GCC64_LDFLAGS.debug ?= -g
109TOOL_GCC64_LDFLAGS.profile ?= -g
110
111
112## Compile C source.
113# @param $(target) Normalized main target name.
114# @param $(source) Source filename (relative).
115# @param $(obj) Object file name. This shall be (re)created by the compilation.
116# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
117# @param $(flags) Flags.
118# @param $(defs) Definitions. No -D or something.
119# @param $(incs) Includes. No -I or something.
120# @param $(dirdep) Directory creation dependency.
121# @param $(deps) Other dependencies.
122#
123# @param $(outbase) Output basename (full). Use this for list files and such.
124# @param $(objsuff) Object suffix.
125TOOL_GCC64_COMPILE_C_DEPEND =
126TOOL_GCC64_COMPILE_C_DEPORD =
127ifdef KBUILD_USE_KOBJCACHE
128TOOL_GCC64_COMPILE_C_USES_KOBJCACHE = 1
129TOOL_GCC64_COMPILE_C_OUTPUT = $(outbase).i
130define TOOL_GCC64_COMPILE_C_CMDS
131 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
132 --kObjCache-cpp $(outbase).i\
133 $(TOOL_GCC64_CC) -E -o -\
134 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
135 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
136 $(abspath $(source))\
137 --kObjCache-cc $(obj)\
138 $(TOOL_GCC64_CC) -c\
139 $(flags) -fpreprocessed -x c\
140 -o $(obj)\
141 -
142 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
143endef
144else # !KBUILD_USE_KOBJCACHE
145TOOL_GCC64_COMPILE_C_OUTPUT =
146define TOOL_GCC64_COMPILE_C_CMDS
147 $(QUIET)$(TOOL_GCC64_CC) -c\
148 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
149 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
150 -o $(obj)\
151 $(abspath $(source))
152 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
153endef
154endif # !KBUILD_USE_KOBJCACHE
155
156
157## Compile C++ source.
158# @param $(target) Normalized main target name.
159# @param $(source) Source filename (relative).
160# @param $(obj) Object file name. This shall be (re)created by the compilation.
161# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
162# @param $(flags) Flags.
163# @param $(defs) Definitions. No -D or something.
164# @param $(incs) Includes. No -I or something.
165# @param $(dirdep) Directory creation dependency.
166# @param $(deps) Other dependencies.
167# @param $(outbase) Output basename (full). Use this for list files and such.
168# @param $(objsuff) Object suffix.
169TOOL_GCC64_COMPILE_CXX_DEPEND =
170TOOL_GCC64_COMPILE_CXX_DEPORD =
171ifdef KBUILD_USE_KOBJCACHE
172TOOL_GCC64_COMPILE_CXX_USES_KOBJCACHE = 1
173TOOL_GCC64_COMPILE_CXX_OUTPUT = $(outbase).ii
174define TOOL_GCC64_COMPILE_CXX_CMDS
175 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
176 --kObjCache-cpp $(outbase).ii\
177 $(TOOL_GCC64_CXX) -E -o -\
178 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
179 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
180 $(abspath $(source))\
181 --kObjCache-cc $(obj)\
182 $(TOOL_GCC64_CXX) -c\
183 $(flags) -fpreprocessed -x c++\
184 -o $(obj)\
185 -
186 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
187endef
188else # !KBUILD_USE_KOBJCACHE
189TOOL_GCC64_COMPILE_CXX_OUTPUT =
190define TOOL_GCC64_COMPILE_CXX_CMDS
191 $(QUIET)$(TOOL_GCC64_CXX) -c\
192 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
193 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
194 -o $(obj)\
195 $(abspath $(source))
196 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
197endef
198endif # !KBUILD_USE_KOBJCACHE
199
200
201## Compile Assembly source.
202# @param $(target) Normalized main target name.
203# @param $(source) Source filename (relative).
204# @param $(obj) Object file name. This shall be (re)created by the compilation.
205# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
206# @param $(flags) Flags.
207# @param $(defs) Definitions. No -D or something.
208# @param $(incs) Includes. No -I or something.
209# @param $(dirdep) Directory creation dependency.
210# @param $(deps) Other dependencies.
211# @param $(outbase) Output basename (full). Use this for list files and such.
212# @param $(objsuff) Object suffix.
213#
214TOOL_GCC64_COMPILE_AS_OUTPUT =
215TOOL_GCC64_COMPILE_AS_DEPEND =
216TOOL_GCC64_COMPILE_AS_DEPORD =
217define TOOL_GCC64_COMPILE_AS_CMDS
218 $(QUIET)$(TOOL_GCC64_AS) -c\
219 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
220 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
221 -o $(obj)\
222 $(abspath $(source))
223 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
224endef
225
226
227## Link library
228# @param $(target) Normalized main target name.
229# @param $(out) Library name.
230# @param $(objs) Object files to put in the library.
231# @param $(flags) Flags.
232# @param $(dirdep) Directory creation dependency.
233# @param $(deps) Other dependencies.
234# @param $(othersrc) Unhandled sources.
235# @param $(outbase) Output basename (full). Use this for list files and such.
236TOOL_GCC64_LINK_LIBRARY_OUTPUT = $(out).ar-script
237TOOL_GCC64_LINK_LIBRARY_DEPEND = $(othersrc)
238TOOL_GCC64_LINK_LIBRARY_DEPORD =
239define TOOL_GCC64_LINK_LIBRARY_CMDS
240 $(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)'
241 $(QUIET)$(APPEND) -n $(out).ar-script \
242 $(foreach o,$(objs), 'ADDMOD $(o)') \
243 $(foreach o,$(othersrc), 'ADDLIB $(o)')
244 $(QUIET)$(APPEND) $(out).ar-script 'SAVE'
245 $(QUIET)$(APPEND) $(out).ar-script 'END'
246 $(QUIET)$(REDIRECT) -rti $(out).ar-script -- $(TOOL_GCC64_AR) -M
247endef
248
249
250## Link program
251# @param $(target) Normalized main target name.
252# @param $(out) Program name.
253# @param $(objs) Object files to link together.
254# @param $(libs) Libraries to search.
255# @param $(libpath) Library search paths.
256# @param $(flags) Flags.
257# @param $(dirdep) Directory creation dependency.
258# @param $(deps) Other dependencies.
259# @param $(othersrc) Unhandled sources.
260# @param $(custom_pre) Custom step invoked before linking.
261# @param $(custom_post) Custom step invoked after linking.
262# @param $(outbase) Output basename (full). Use this for list files and such.
263TOOL_GCC64_LINK_PROGRAM_OUTPUT =
264TOOL_GCC64_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map
265TOOL_GCC64_LINK_PROGRAM_OUTPUT_DEBUG = $(outbase).debug
266TOOL_GCC64_LINK_PROGRAM_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug
267TOOL_GCC64_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
268TOOL_GCC64_LINK_PROGRAM_DEPORD =
269define TOOL_GCC64_LINK_PROGRAM_CMDS
270 $(QUIET)$(TOOL_GCC64_LD) $(flags) -o $(out) $(objs)\
271 $(foreach p,$(libpath), -L$(p))\
272 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
273 $(call TOOL_GCC64_LD_MAP,$(outbase).map)
274 ifeq ($(ld_debug),split)
275 $(QUIET)$(TOOL_GCC64_OBJCOPY) --only-keep-debug $(out) $(outbase).debug
276 $(QUIET)$(CHMOD) a-x $(outbase).debug
277 $(QUIET)$(TOOL_GCC64_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out)
278 endif
279endef
280
281
282## Link DLL
283# @param $(target) Normalized main target name.
284# @param $(out) Program name.
285# @param $(objs) Object files to link together.
286# @param $(libs) Libraries to search.
287# @param $(libpath) Library search paths.
288# @param $(flags) Flags.
289# @param $(dirdep) Directory creation dependency.
290# @param $(deps) Other dependencies.
291# @param $(othersrc) Unhandled sources.
292# @param $(custom_pre) Custom step invoked before linking.
293# @param $(custom_post) Custom step invoked after linking.
294# @param $(outbase) Output basename (full). Use this for list files and such.
295TOOL_GCC64_LINK_DLL_OUTPUT =
296TOOL_GCC64_LINK_DLL_OUTPUT_MAYBE = $(outbase).map
297TOOL_GCC64_LINK_DLL_OUTPUT_DEBUG = $(outbase).debug
298TOOL_GCC64_LINK_DLL_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug
299TOOL_GCC64_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
300TOOL_GCC64_LINK_DLL_DEPORD =
301define TOOL_GCC64_LINK_DLL_CMDS
302 $(QUIET)$(TOOL_GCC64_LD) $(TOOL_GCC64_LDFLAGS.dll) $(flags) -o $(out)\
303 $(if $(filter-out win os2, $(KBUILD_TARGET)),$(call TOOL_GCC64_LD_SONAME,$(target),$(out)))\
304 $(objs)\
305 $(foreach p,$(libpath), -L$(p))\
306 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
307 $(call TOOL_GCC64_LD_MAP,$(outbase).map)
308 ifeq ($(ld_debug),split)
309 $(QUIET)$(TOOL_GCC64_OBJCOPY) --only-keep-debug $(out) $(outbase).debug
310 $(QUIET)$(CHMOD) a-x $(outbase).debug
311 $(QUIET)$(TOOL_GCC64_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out)
312 endif
313endef
314
315
316## Link system module (windows aka driver, linux aka kernel module)
317# @param $(target) Normalized main target name.
318# @param $(out) System module name.
319# @param $(objs) Object files to link together.
320# @param $(libs) Libraries to search.
321# @param $(libpath) Library search paths.
322# @param $(flags) Flags.
323# @param $(dirdep) Directory creation dependency.
324# @param $(deps) Other dependencies.
325# @param $(othersrc) Unhandled sources.
326# @param $(custom_pre) Custom step invoked before linking.
327# @param $(custom_post) Custom step invoked after linking.
328# @param $(outbase) Output basename (full). Use this for list files and such.
329TOOL_GCC64_LINK_SYSMOD_OUTPUT =
330TOOL_GCC64_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map
331TOOL_GCC64_LINK_SYSMOD_OUTPUT_DEBUG = $(outbase).debug
332TOOL_GCC64_LINK_SYSMOD_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug
333TOOL_GCC64_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
334TOOL_GCC64_LINK_SYSMOD_DEPORD =
335define TOOL_GCC64_LINK_SYSMOD_CMDS
336 $(QUIET)$(TOOL_GCC64_LD_SYSMOD) $(TOOL_GCC64_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
337 $(foreach p,$(libpath), -L$(p))\
338 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
339 $(call TOOL_GCC64_LD_SYSMOD_MAP,$(outbase).map)
340 ifeq ($(ld_debug),split)
341 $(QUIET)$(TOOL_GCC64_OBJCOPY) --only-keep-debug $(out) $(outbase).debug
342 $(QUIET)$(CHMOD) a-x $(outbase).debug
343 $(QUIET)$(TOOL_GCC64_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out)
344 endif
345endef
346
Note: See TracBrowser for help on using the repository browser.