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

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