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

Last change on this file since 3403 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: 12.4 KB
Line 
1# $Id: XGCCAMD64LINUX.kmk 3393 2020-06-30 17:11:42Z 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
85ifdef SLKRUNS
86TOOL_XGCCAMD64LINUX_CC += -fmessage-length=0
87TOOL_XGCCAMD64LINUX_CXX += -fmessage-length=0
88endif
89
90# General Properties used by kBuild
91TOOL_XGCCAMD64LINUX_COBJSUFF ?= .o
92TOOL_XGCCAMD64LINUX_CFLAGS ?= -g
93TOOL_XGCCAMD64LINUX_CFLAGS.debug ?= -O0
94TOOL_XGCCAMD64LINUX_CFLAGS.release ?= -O2
95TOOL_XGCCAMD64LINUX_CFLAGS.profile ?= -O2 #-pg
96TOOL_XGCCAMD64LINUX_CINCS ?=
97TOOL_XGCCAMD64LINUX_CDEFS ?=
98
99TOOL_XGCCAMD64LINUX_CXXOBJSUFF ?= .o
100TOOL_XGCCAMD64LINUX_CXXOBJSUFF ?= .o
101TOOL_XGCCAMD64LINUX_CXXFLAGS ?= -g
102TOOL_XGCCAMD64LINUX_CXXFLAGS.debug ?= -O0
103TOOL_XGCCAMD64LINUX_CXXFLAGS.release ?= -O2
104TOOL_XGCCAMD64LINUX_CXXFLAGS.profile ?= -O2 #-pg
105TOOL_XGCCAMD64LINUX_CXXINCS ?=
106TOOL_XGCCAMD64LINUX_CXXDEFS ?=
107
108TOOL_XGCCAMD64LINUX_ASFLAGS ?= -g -x assembler-with-cpp
109TOOL_XGCCAMD64LINUX_ASOBJSUFF ?= .o
110
111TOOL_XGCCAMD64LINUX_ARFLAGS ?= cr
112TOOL_XGCCAMD64LINUX_ARLIBSUFF ?= .a
113
114TOOL_XGCCAMD64LINUX_LDFLAGS ?=
115TOOL_XGCCAMD64LINUX_LDFLAGS.debug ?= -g
116TOOL_XGCCAMD64LINUX_LDFLAGS.release ?= -s
117
118
119
120## Compile C source.
121# @param $(target) Normalized main target name.
122# @param $(source) Source filename (relative).
123# @param $(obj) Object file name. This shall be (re)created by the compilation.
124# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
125# @param $(flags) Flags.
126# @param $(defs) Definitions. No -D or something.
127# @param $(incs) Includes. No -I or something.
128# @param $(dirdep) Directory creation dependency.
129# @param $(deps) Other dependencies.
130#
131# @param $(outbase) Output basename (full). Use this for list files and such.
132# @param $(objsuff) Object suffix.
133TOOL_XGCCAMD64LINUX_COMPILE_C_OUTPUT =
134TOOL_XGCCAMD64LINUX_COMPILE_C_DEPEND =
135TOOL_XGCCAMD64LINUX_COMPILE_C_DEPORD =
136define TOOL_XGCCAMD64LINUX_COMPILE_C_CMDS
137 $(QUIET)$(TOOL_XGCCAMD64LINUX_CC) -c\
138 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
139 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
140 -o $(obj)\
141 $(abspath $(source))
142endef
143
144
145## Compile C++ source.
146# @param $(target) Normalized main target name.
147# @param $(source) Source filename (relative).
148# @param $(obj) Object file name. This shall be (re)created by the compilation.
149# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
150# @param $(flags) Flags.
151# @param $(defs) Definitions. No -D or something.
152# @param $(incs) Includes. No -I or something.
153# @param $(dirdep) Directory creation dependency.
154# @param $(deps) Other dependencies.
155# @param $(outbase) Output basename (full). Use this for list files and such.
156# @param $(objsuff) Object suffix.
157TOOL_XGCCAMD64LINUX_COMPILE_CXX_OUTPUT =
158TOOL_XGCCAMD64LINUX_COMPILE_CXX_DEPEND =
159TOOL_XGCCAMD64LINUX_COMPILE_CXX_DEPORD =
160define TOOL_XGCCAMD64LINUX_COMPILE_CXX_CMDS
161 $(QUIET)$(TOOL_XGCCAMD64LINUX_CXX) -c\
162 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
163 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
164 -o $(obj)\
165 $(abspath $(source))
166endef
167
168## Compile Assembly source.
169# @param $(target) Normalized main target name.
170# @param $(source) Source filename (relative).
171# @param $(obj) Object file name. This shall be (re)created by the compilation.
172# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
173# @param $(flags) Flags.
174# @param $(defs) Definitions. No -D or something.
175# @param $(incs) Includes. No -I or something.
176# @param $(dirdep) Directory creation dependency.
177# @param $(deps) Other dependencies.
178# @param $(outbase) Output basename (full). Use this for list files and such.
179# @param $(objsuff) Object suffix.
180#
181TOOL_XGCCAMD64LINUX_COMPILE_AS_OUTPUT =
182TOOL_XGCCAMD64LINUX_COMPILE_AS_DEPEND =
183TOOL_XGCCAMD64LINUX_COMPILE_AS_DEPORD =
184define TOOL_XGCCAMD64LINUX_COMPILE_AS_CMDS
185 $(QUIET)$(TOOL_XGCCAMD64LINUX_AS) -c\
186 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
187 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
188 -o $(obj)\
189 $(abspath $(source))
190endef
191
192
193## Link library
194# @param $(target) Normalized main target name.
195# @param $(out) Library name.
196# @param $(objs) Object files to put in the library.
197# @param $(flags) Flags.
198# @param $(dirdep) Directory creation dependency.
199# @param $(deps) Other dependencies.
200# @param $(othersrc) Unhandled sources.
201# @param $(outbase) Output basename (full). Use this for list files and such.
202TOOL_XGCCAMD64LINUX_LINK_LIBRARY_OUTPUT = $(out).ar-script
203TOOL_XGCCAMD64LINUX_LINK_LIBRARY_DEPEND = $(othersrc)
204TOOL_XGCCAMD64LINUX_LINK_LIBRARY_DEPORD =
205define TOOL_XGCCAMD64LINUX_LINK_LIBRARY_CMDS
206 $(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)'
207 $(QUIET)$(APPEND) -n $(out).ar-script \
208 $(foreach o,$(objs), 'ADDMOD $(o)') \
209 $(foreach o,$(othersrc), 'ADDLIB $(o)')
210 $(QUIET)$(APPEND) $(out).ar-script 'SAVE'
211 $(QUIET)$(APPEND) $(out).ar-script 'END'
212 $(QUIET)$(REDIRECT) -rti $(out).ar-script -- $(TOOL_XGCCAMD64LINUX_AR) -M
213endef
214
215
216## Link program
217# @param $(target) Normalized main target name.
218# @param $(out) Program name.
219# @param $(objs) Object files to link together.
220# @param $(libs) Libraries to search.
221# @param $(libpath) Library search paths.
222# @param $(flags) Flags.
223# @param $(dirdep) Directory creation dependency.
224# @param $(deps) Other dependencies.
225# @param $(othersrc) Unhandled sources.
226# @param $(custom_pre) Custom step invoked before linking.
227# @param $(custom_post) Custom step invoked after linking.
228# @param $(outbase) Output basename (full). Use this for list files and such.
229TOOL_XGCCAMD64LINUX_LINK_PROGRAM_OUTPUT = $(outbase).map
230TOOL_XGCCAMD64LINUX_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
231TOOL_XGCCAMD64LINUX_LINK_PROGRAM_DEPORD =
232define TOOL_XGCCAMD64LINUX_LINK_PROGRAM_CMDS
233 $(QUIET)$(TOOL_XGCCAMD64LINUX_LD) $(flags) -o $(out) $(objs)\
234 $(foreach p,$(libpath), -L$(p))\
235 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
236 $(call TOOL_XGCCAMD64LINUX_LD_MAP,$(outbase).map)
237endef
238
239
240## Link DLL
241# @param $(target) Normalized main target name.
242# @param $(out) Program name.
243# @param $(objs) Object files to link together.
244# @param $(libs) Libraries to search.
245# @param $(libpath) Library search paths.
246# @param $(flags) Flags.
247# @param $(dirdep) Directory creation dependency.
248# @param $(deps) Other dependencies.
249# @param $(othersrc) Unhandled sources.
250# @param $(custom_pre) Custom step invoked before linking.
251# @param $(custom_post) Custom step invoked after linking.
252# @param $(outbase) Output basename (full). Use this for list files and such.
253TOOL_XGCCAMD64LINUX_LINK_DLL_OUTPUT = $(outbase).map
254TOOL_XGCCAMD64LINUX_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
255TOOL_XGCCAMD64LINUX_LINK_DLL_DEPORD =
256define TOOL_XGCCAMD64LINUX_LINK_DLL_CMDS
257 $(QUIET)$(TOOL_XGCCAMD64LINUX_LD) $(TOOL_XGCCAMD64LINUX_LDFLAGS.dll) $(flags) -o $(out)\
258 $(if $(filter-out win32 os2, $(KBUILD_TARGET)),$(call TOOL_XGCCAMD64LINUX_LD_SONAME,$(target),$(out)))\
259 $(objs)\
260 $(foreach p,$(libpath), -L$(p))\
261 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
262 $(call TOOL_XGCCAMD64LINUX_LD_MAP,$(outbase).map)
263endef
264
265
266## Link system module (windows aka driver, linux aka kernel module)
267# @param $(target) Normalized main target name.
268# @param $(out) System module name.
269# @param $(objs) Object files to link together.
270# @param $(libs) Libraries to search.
271# @param $(libpath) Library search paths.
272# @param $(flags) Flags.
273# @param $(dirdep) Directory creation dependency.
274# @param $(deps) Other dependencies.
275# @param $(othersrc) Unhandled sources.
276# @param $(custom_pre) Custom step invoked before linking.
277# @param $(custom_post) Custom step invoked after linking.
278# @param $(outbase) Output basename (full). Use this for list files and such.
279TOOL_XGCCAMD64LINUX_LINK_SYSMOD_OUTPUT = $(outbase).map
280TOOL_XGCCAMD64LINUX_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
281TOOL_XGCCAMD64LINUX_LINK_SYSMOD_DEPORD =
282define TOOL_XGCCAMD64LINUX_LINK_SYSMOD_CMDS
283 $(QUIET)$(TOOL_XGCCAMD64LINUX_LD_SYSMOD) $(TOOL_XGCCAMD64LINUX_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
284 $(foreach p,$(libpath), -L$(p))\
285 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
286 $(call TOOL_XGCCAMD64LINUX_LD_SYSMOD_MAP,$(outbase).map)
287endef
288
Note: See TracBrowser for help on using the repository browser.