source: trunk/kBuild/tools/XGCCAMD64LINUX.kmk@ 3669

Last change on this file since 3669 was 3579, checked in by bird, 3 years ago

tools/CLANG*,tools/LLVM*,tools/XGCCAMD64LINUX.kmk: Use qaddprefix in sh-mode for -D and -I processing, just like VCC14*.kmk does. Forced update of header.kmk so KMK_REVISION can be used to detect the changes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.4 KB
Line 
1# $Id: XGCCAMD64LINUX.kmk 3579 2023-01-05 01:53:41Z bird $
2## @file
3# kBuild Tool Config - GCC Cross compiler for AMD64+Linux.
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_XGCCAMD64LINUX := GCC Cross compiler for AMD64+Linux.
35
36# Tool Specific Properties
37TOOL_XGCCAMD64LINUX_SUFFIX ?= $(HOSTSUFF_EXE)
38ifeq ($(KBUILD_HOST).$(KBUILD_HOST_ARCH),linux.amd64)
39 # not x-compile, use the default gcc.
40 TOOL_XGCCAMD64LINUX_PREFIX := $(TOOL_XGCCAMD64LINUX_PREFIX)
41else # x-compile:
42 # find the latest xgcc build.
43 ifndef TOOL_XGCCAMD64LINUX_PREFIX
44 TOOL_XGCCAMD64LINUX_PREFIX := x86_64-unknown-linux-gnu-
45 ifndef PATH_TOOL_XGCCAMD64LINUX
46 PATH_TOOL_XGCCAMD64LINUX := $(sort $(wildcard $(KBUILD_DEVTOOLS_HST)/x86_64-unknown-linux-gnu/*))
47 ifeq ($(PATH_TOOL_XGCCAMD64LINUX),)
48 ifeq ($(filter-out win.amd64,$(KBUILD_HOST).$(KBUILD_HOST_ARCH)),) # these can use the windows build.
49 TOOL_XGCCAMD64LINUX_EXEC_PREFIX ?= $(EXEC_X86_WIN32)
50 TOOL_XGCCAMD64LINUX_SUFFIX := .exe
51 PATH_TOOL_XGCCAMD64LINUX := $(sort $(wildcard $(KBUILD_DEVTOOLS)/win.x86/x86_64-unknown-linux-gnu/*))
52 ifeq ($(PATH_TOOL_XGCCAMD64LINUX),)
53 PATH_TOOL_XGCCAMD64LINUX := $(sort $(wildcard $(KBUILD_DEVTOOLS)/x86.win32/x86_64-unknown-linux-gnu/*))
54 endif
55 endif
56 endif
57 ifneq ($(PATH_TOOL_XGCCAMD64LINUX),)
58 PATH_TOOL_XGCCAMD64LINUX := $(call lastword,$(PATH_TOOL_XGCCAMD64LINUX))
59 endif
60 endif # !PATH_TOOL_XGCCAMD64LINUX
61 ifneq ($(PATH_TOOL_XGCCAMD64LINUX),)
62 TOOL_XGCCAMD64LINUX_PREFIX := $(TOOL_XGCCAMD64LINUX_EXEC_PREFIX) $(PATH_TOOL_XGCCAMD64LINUX)/bin/$(TOOL_XGCCAMD64LINUX_PREFIX)
63 endif
64 else
65 # Resolve any fancy stuff once and for all.
66 TOOL_XGCCAMD64LINUX_PREFIX := $(TOOL_XGCCAMD64LINUX_PREFIX)
67 endif
68endif
69
70TOOL_XGCCAMD64LINUX_PREFIX2 ?= $(TOOL_XGCCAMD64LINUX_PREFIX)
71TOOL_XGCCAMD64LINUX_SUFFIX2 ?= $(TOOL_XGCCAMD64LINUX_SUFFIX)
72TOOL_XGCCAMD64LINUX_CC ?= $(TOOL_XGCCAMD64LINUX_PREFIX)gcc$(TOOL_XGCCAMD64LINUX_SUFFIX)
73TOOL_XGCCAMD64LINUX_CXX ?= $(TOOL_XGCCAMD64LINUX_PREFIX)g++$(TOOL_XGCCAMD64LINUX_SUFFIX)
74TOOL_XGCCAMD64LINUX_AS ?= $(TOOL_XGCCAMD64LINUX_PREFIX)gcc$(TOOL_XGCCAMD64LINUX_SUFFIX)
75TOOL_XGCCAMD64LINUX_AR ?= $(TOOL_XGCCAMD64LINUX_PREFIX2)ar$(TOOL_XGCCAMD64LINUX_SUFFIX2)
76TOOL_XGCCAMD64LINUX_LD ?= $(TOOL_XGCCAMD64LINUX_PREFIX)g++$(TOOL_XGCCAMD64LINUX_SUFFIX)
77TOOL_XGCCAMD64LINUX_LD_SYSMOD ?= $(TOOL_XGCCAMD64LINUX_PREFIX2)ld$(TOOL_XGCCAMD64LINUX_SUFFIX2)
78
79TOOL_XGCCAMD64LINUX_LD_SONAME ?= -Wl,-soname=$(firstword $($(1)_SONAME.$(KBUILD_TARGET).$(KBUILD_TYPE)) $($(1)_SONAME.$(KBUILD_TARGET)) $($(1)_SONAME.$(KBUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
80TOOL_XGCCAMD64LINUX_LD_MAP ?= -Wl,-Map -Wl,$(1) -Wl,--cref
81TOOL_XGCCAMD64LINUX_LD_SYSMOD_MAP ?= -Map $(1) --cref
82TOOL_XGCCAMD64LINUX_LDFLAGS.dll ?= -shared
83TOOL_XGCCAMD64LINUX_LDFLAGS.sysmod ?= -r
84
85# General Properties used by kBuild
86TOOL_XGCCAMD64LINUX_COBJSUFF ?= .o
87TOOL_XGCCAMD64LINUX_CFLAGS ?= -g
88TOOL_XGCCAMD64LINUX_CFLAGS.debug ?= -O0
89TOOL_XGCCAMD64LINUX_CFLAGS.release ?= -O2
90TOOL_XGCCAMD64LINUX_CFLAGS.profile ?= -O2 #-pg
91TOOL_XGCCAMD64LINUX_CINCS ?=
92TOOL_XGCCAMD64LINUX_CDEFS ?=
93
94TOOL_XGCCAMD64LINUX_CXXOBJSUFF ?= .o
95TOOL_XGCCAMD64LINUX_CXXOBJSUFF ?= .o
96TOOL_XGCCAMD64LINUX_CXXFLAGS ?= -g
97TOOL_XGCCAMD64LINUX_CXXFLAGS.debug ?= -O0
98TOOL_XGCCAMD64LINUX_CXXFLAGS.release ?= -O2
99TOOL_XGCCAMD64LINUX_CXXFLAGS.profile ?= -O2 #-pg
100TOOL_XGCCAMD64LINUX_CXXINCS ?=
101TOOL_XGCCAMD64LINUX_CXXDEFS ?=
102
103TOOL_XGCCAMD64LINUX_ASFLAGS ?= -g -x assembler-with-cpp
104TOOL_XGCCAMD64LINUX_ASOBJSUFF ?= .o
105
106TOOL_XGCCAMD64LINUX_ARFLAGS ?= cr
107TOOL_XGCCAMD64LINUX_ARLIBSUFF ?= .a
108
109TOOL_XGCCAMD64LINUX_LDFLAGS ?=
110TOOL_XGCCAMD64LINUX_LDFLAGS.debug ?= -g
111TOOL_XGCCAMD64LINUX_LDFLAGS.release ?= -s
112
113
114
115## Compile C source.
116# @param $(target) Normalized main target name.
117# @param $(source) Source filename (relative).
118# @param $(obj) Object file name. This shall be (re)created by the compilation.
119# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
120# @param $(flags) Flags.
121# @param $(defs) Definitions. No -D or something.
122# @param $(incs) Includes. No -I or something.
123# @param $(dirdep) Directory creation dependency.
124# @param $(deps) Other dependencies.
125#
126# @param $(outbase) Output basename (full). Use this for list files and such.
127# @param $(objsuff) Object suffix.
128TOOL_XGCCAMD64LINUX_COMPILE_C_OUTPUT =
129TOOL_XGCCAMD64LINUX_COMPILE_C_DEPEND =
130TOOL_XGCCAMD64LINUX_COMPILE_C_DEPORD =
131define TOOL_XGCCAMD64LINUX_COMPILE_C_CMDS
132 $(QUIET)$(TOOL_XGCCAMD64LINUX_CC) -c\
133 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
134 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
135 -o $(obj)\
136 $(abspath $(source))
137endef
138
139
140## Compile C++ source.
141# @param $(target) Normalized main target name.
142# @param $(source) Source filename (relative).
143# @param $(obj) Object file name. This shall be (re)created by the compilation.
144# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
145# @param $(flags) Flags.
146# @param $(defs) Definitions. No -D or something.
147# @param $(incs) Includes. No -I or something.
148# @param $(dirdep) Directory creation dependency.
149# @param $(deps) Other dependencies.
150# @param $(outbase) Output basename (full). Use this for list files and such.
151# @param $(objsuff) Object suffix.
152TOOL_XGCCAMD64LINUX_COMPILE_CXX_OUTPUT =
153TOOL_XGCCAMD64LINUX_COMPILE_CXX_DEPEND =
154TOOL_XGCCAMD64LINUX_COMPILE_CXX_DEPORD =
155define TOOL_XGCCAMD64LINUX_COMPILE_CXX_CMDS
156 $(QUIET)$(TOOL_XGCCAMD64LINUX_CXX) -c\
157 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
158 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
159 -o $(obj)\
160 $(abspath $(source))
161endef
162
163## Compile Assembly source.
164# @param $(target) Normalized main target name.
165# @param $(source) Source filename (relative).
166# @param $(obj) Object file name. This shall be (re)created by the compilation.
167# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
168# @param $(flags) Flags.
169# @param $(defs) Definitions. No -D or something.
170# @param $(incs) Includes. No -I or something.
171# @param $(dirdep) Directory creation dependency.
172# @param $(deps) Other dependencies.
173# @param $(outbase) Output basename (full). Use this for list files and such.
174# @param $(objsuff) Object suffix.
175#
176TOOL_XGCCAMD64LINUX_COMPILE_AS_OUTPUT =
177TOOL_XGCCAMD64LINUX_COMPILE_AS_DEPEND =
178TOOL_XGCCAMD64LINUX_COMPILE_AS_DEPORD =
179define TOOL_XGCCAMD64LINUX_COMPILE_AS_CMDS
180 $(QUIET)$(TOOL_XGCCAMD64LINUX_AS) -c\
181 $(flags) $(qaddprefix sh,-I, $(incs)) $(qaddprefix sh,-D, $(defs))\
182 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
183 -o $(obj)\
184 $(abspath $(source))
185endef
186
187
188## Link library
189# @param $(target) Normalized main target name.
190# @param $(out) Library name.
191# @param $(objs) Object files to put in the library.
192# @param $(flags) Flags.
193# @param $(dirdep) Directory creation dependency.
194# @param $(deps) Other dependencies.
195# @param $(othersrc) Unhandled sources.
196# @param $(outbase) Output basename (full). Use this for list files and such.
197TOOL_XGCCAMD64LINUX_LINK_LIBRARY_OUTPUT = $(out).ar-script
198TOOL_XGCCAMD64LINUX_LINK_LIBRARY_DEPEND = $(othersrc)
199TOOL_XGCCAMD64LINUX_LINK_LIBRARY_DEPORD =
200define TOOL_XGCCAMD64LINUX_LINK_LIBRARY_CMDS
201 $(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)'
202 $(QUIET)$(APPEND) -n $(out).ar-script \
203 $(foreach o,$(objs), 'ADDMOD $(o)') \
204 $(foreach o,$(othersrc), 'ADDLIB $(o)')
205 $(QUIET)$(APPEND) $(out).ar-script 'SAVE'
206 $(QUIET)$(APPEND) $(out).ar-script 'END'
207 $(QUIET)$(REDIRECT) -rti $(out).ar-script -- $(TOOL_XGCCAMD64LINUX_AR) -M
208endef
209
210
211## Link program
212# @param $(target) Normalized main target name.
213# @param $(out) Program name.
214# @param $(objs) Object files to link together.
215# @param $(libs) Libraries to search.
216# @param $(libpath) Library search paths.
217# @param $(flags) Flags.
218# @param $(dirdep) Directory creation dependency.
219# @param $(deps) Other dependencies.
220# @param $(othersrc) Unhandled sources.
221# @param $(custom_pre) Custom step invoked before linking.
222# @param $(custom_post) Custom step invoked after linking.
223# @param $(outbase) Output basename (full). Use this for list files and such.
224TOOL_XGCCAMD64LINUX_LINK_PROGRAM_OUTPUT = $(outbase).map
225TOOL_XGCCAMD64LINUX_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
226TOOL_XGCCAMD64LINUX_LINK_PROGRAM_DEPORD =
227define TOOL_XGCCAMD64LINUX_LINK_PROGRAM_CMDS
228 $(QUIET)$(TOOL_XGCCAMD64LINUX_LD) $(flags) -o $(out) $(objs)\
229 $(foreach p,$(libpath), -L$(p))\
230 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
231 $(call TOOL_XGCCAMD64LINUX_LD_MAP,$(outbase).map)
232endef
233
234
235## Link DLL
236# @param $(target) Normalized main target name.
237# @param $(out) Program name.
238# @param $(objs) Object files to link together.
239# @param $(libs) Libraries to search.
240# @param $(libpath) Library search paths.
241# @param $(flags) Flags.
242# @param $(dirdep) Directory creation dependency.
243# @param $(deps) Other dependencies.
244# @param $(othersrc) Unhandled sources.
245# @param $(custom_pre) Custom step invoked before linking.
246# @param $(custom_post) Custom step invoked after linking.
247# @param $(outbase) Output basename (full). Use this for list files and such.
248TOOL_XGCCAMD64LINUX_LINK_DLL_OUTPUT = $(outbase).map
249TOOL_XGCCAMD64LINUX_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
250TOOL_XGCCAMD64LINUX_LINK_DLL_DEPORD =
251define TOOL_XGCCAMD64LINUX_LINK_DLL_CMDS
252 $(QUIET)$(TOOL_XGCCAMD64LINUX_LD) $(TOOL_XGCCAMD64LINUX_LDFLAGS.dll) $(flags) -o $(out)\
253 $(if $(filter-out win32 os2, $(KBUILD_TARGET)),$(call TOOL_XGCCAMD64LINUX_LD_SONAME,$(target),$(out)))\
254 $(objs)\
255 $(foreach p,$(libpath), -L$(p))\
256 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
257 $(call TOOL_XGCCAMD64LINUX_LD_MAP,$(outbase).map)
258endef
259
260
261## Link system module (windows aka driver, linux aka kernel module)
262# @param $(target) Normalized main target name.
263# @param $(out) System module name.
264# @param $(objs) Object files to link together.
265# @param $(libs) Libraries to search.
266# @param $(libpath) Library search paths.
267# @param $(flags) Flags.
268# @param $(dirdep) Directory creation dependency.
269# @param $(deps) Other dependencies.
270# @param $(othersrc) Unhandled sources.
271# @param $(custom_pre) Custom step invoked before linking.
272# @param $(custom_post) Custom step invoked after linking.
273# @param $(outbase) Output basename (full). Use this for list files and such.
274TOOL_XGCCAMD64LINUX_LINK_SYSMOD_OUTPUT = $(outbase).map
275TOOL_XGCCAMD64LINUX_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
276TOOL_XGCCAMD64LINUX_LINK_SYSMOD_DEPORD =
277define TOOL_XGCCAMD64LINUX_LINK_SYSMOD_CMDS
278 $(QUIET)$(TOOL_XGCCAMD64LINUX_LD_SYSMOD) $(TOOL_XGCCAMD64LINUX_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
279 $(foreach p,$(libpath), -L$(p))\
280 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
281 $(call TOOL_XGCCAMD64LINUX_LD_SYSMOD_MAP,$(outbase).map)
282endef
283
Note: See TracBrowser for help on using the repository browser.