Built win.arm64 against r3658
[kbuild-mirror.git] / kBuild / tools / XGCCAMD64LINUX.kmk
blobe0904047bcb4af9b26cc07a9c2af1bb717c760a6
1 # $Id$
2 ## @file
3 # kBuild Tool Config - GCC Cross compiler for AMD64+Linux.
7 # Copyright (c) 2004-2017 knut st. osmundsen <bird-kBuild-spam-xviiv@anduin.net>
9 # This file is part of kBuild.
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.
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.
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
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.
34 TOOL_XGCCAMD64LINUX := GCC Cross compiler for AMD64+Linux.
36 # Tool Specific Properties
37 TOOL_XGCCAMD64LINUX_SUFFIX ?= $(HOSTSUFF_EXE)
38 ifeq ($(KBUILD_HOST).$(KBUILD_HOST_ARCH),linux.amd64)
39 # not x-compile, use the default gcc.
40 TOOL_XGCCAMD64LINUX_PREFIX := $(TOOL_XGCCAMD64LINUX_PREFIX)
41 else # 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
68 endif
70 TOOL_XGCCAMD64LINUX_PREFIX2 ?= $(TOOL_XGCCAMD64LINUX_PREFIX)
71 TOOL_XGCCAMD64LINUX_SUFFIX2 ?= $(TOOL_XGCCAMD64LINUX_SUFFIX)
72 TOOL_XGCCAMD64LINUX_CC ?= $(TOOL_XGCCAMD64LINUX_PREFIX)gcc$(TOOL_XGCCAMD64LINUX_SUFFIX)
73 TOOL_XGCCAMD64LINUX_CXX ?= $(TOOL_XGCCAMD64LINUX_PREFIX)g++$(TOOL_XGCCAMD64LINUX_SUFFIX)
74 TOOL_XGCCAMD64LINUX_AS ?= $(TOOL_XGCCAMD64LINUX_PREFIX)gcc$(TOOL_XGCCAMD64LINUX_SUFFIX)
75 TOOL_XGCCAMD64LINUX_AR ?= $(TOOL_XGCCAMD64LINUX_PREFIX2)ar$(TOOL_XGCCAMD64LINUX_SUFFIX2)
76 TOOL_XGCCAMD64LINUX_LD ?= $(TOOL_XGCCAMD64LINUX_PREFIX)g++$(TOOL_XGCCAMD64LINUX_SUFFIX)
77 TOOL_XGCCAMD64LINUX_LD_SYSMOD ?= $(TOOL_XGCCAMD64LINUX_PREFIX2)ld$(TOOL_XGCCAMD64LINUX_SUFFIX2)
79 TOOL_XGCCAMD64LINUX_LD_SONAME ?= -Wl,-soname=$(firstword $($(1)_SONAME.$(KBUILD_TARGET).$(KBUILD_TYPE)) $($(1)_SONAME.$(KBUILD_TARGET)) $($(1)_SONAME.$(KBUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
80 TOOL_XGCCAMD64LINUX_LD_MAP ?= -Wl,-Map -Wl,$(1) -Wl,--cref
81 TOOL_XGCCAMD64LINUX_LD_SYSMOD_MAP ?= -Map $(1) --cref
82 TOOL_XGCCAMD64LINUX_LDFLAGS.dll ?= -shared
83 TOOL_XGCCAMD64LINUX_LDFLAGS.sysmod ?= -r
85 # General Properties used by kBuild
86 TOOL_XGCCAMD64LINUX_COBJSUFF ?= .o
87 TOOL_XGCCAMD64LINUX_CFLAGS ?= -g
88 TOOL_XGCCAMD64LINUX_CFLAGS.debug ?= -O0
89 TOOL_XGCCAMD64LINUX_CFLAGS.release ?= -O2
90 TOOL_XGCCAMD64LINUX_CFLAGS.profile ?= -O2 #-pg
91 TOOL_XGCCAMD64LINUX_CINCS ?=
92 TOOL_XGCCAMD64LINUX_CDEFS ?=
94 TOOL_XGCCAMD64LINUX_CXXOBJSUFF ?= .o
95 TOOL_XGCCAMD64LINUX_CXXOBJSUFF ?= .o
96 TOOL_XGCCAMD64LINUX_CXXFLAGS ?= -g
97 TOOL_XGCCAMD64LINUX_CXXFLAGS.debug ?= -O0
98 TOOL_XGCCAMD64LINUX_CXXFLAGS.release ?= -O2
99 TOOL_XGCCAMD64LINUX_CXXFLAGS.profile ?= -O2 #-pg
100 TOOL_XGCCAMD64LINUX_CXXINCS ?=
101 TOOL_XGCCAMD64LINUX_CXXDEFS ?=
103 TOOL_XGCCAMD64LINUX_ASFLAGS ?= -g -x assembler-with-cpp
104 TOOL_XGCCAMD64LINUX_ASOBJSUFF ?= .o
106 TOOL_XGCCAMD64LINUX_ARFLAGS ?= cr
107 TOOL_XGCCAMD64LINUX_ARLIBSUFF ?= .a
109 TOOL_XGCCAMD64LINUX_LDFLAGS ?=
110 TOOL_XGCCAMD64LINUX_LDFLAGS.debug ?= -g
111 TOOL_XGCCAMD64LINUX_LDFLAGS.release ?= -s
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.
126 # @param $(outbase) Output basename (full). Use this for list files and such.
127 # @param $(objsuff) Object suffix.
128 TOOL_XGCCAMD64LINUX_COMPILE_C_OUTPUT =
129 TOOL_XGCCAMD64LINUX_COMPILE_C_DEPEND =
130 TOOL_XGCCAMD64LINUX_COMPILE_C_DEPORD =
131 define 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))
137 endef
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.
152 TOOL_XGCCAMD64LINUX_COMPILE_CXX_OUTPUT =
153 TOOL_XGCCAMD64LINUX_COMPILE_CXX_DEPEND =
154 TOOL_XGCCAMD64LINUX_COMPILE_CXX_DEPORD =
155 define 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))
161 endef
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.
176 TOOL_XGCCAMD64LINUX_COMPILE_AS_OUTPUT =
177 TOOL_XGCCAMD64LINUX_COMPILE_AS_DEPEND =
178 TOOL_XGCCAMD64LINUX_COMPILE_AS_DEPORD =
179 define 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))
185 endef
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.
197 TOOL_XGCCAMD64LINUX_LINK_LIBRARY_OUTPUT = $(out).ar-script
198 TOOL_XGCCAMD64LINUX_LINK_LIBRARY_DEPEND = $(othersrc)
199 TOOL_XGCCAMD64LINUX_LINK_LIBRARY_DEPORD =
200 define 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
208 endef
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.
224 TOOL_XGCCAMD64LINUX_LINK_PROGRAM_OUTPUT = $(outbase).map
225 TOOL_XGCCAMD64LINUX_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
226 TOOL_XGCCAMD64LINUX_LINK_PROGRAM_DEPORD =
227 define 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)
232 endef
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.
248 TOOL_XGCCAMD64LINUX_LINK_DLL_OUTPUT = $(outbase).map
249 TOOL_XGCCAMD64LINUX_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
250 TOOL_XGCCAMD64LINUX_LINK_DLL_DEPORD =
251 define 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)
258 endef
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.
274 TOOL_XGCCAMD64LINUX_LINK_SYSMOD_OUTPUT = $(outbase).map
275 TOOL_XGCCAMD64LINUX_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
276 TOOL_XGCCAMD64LINUX_LINK_SYSMOD_DEPORD =
277 define 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)
282 endef