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

Last change on this file since 3121 was 3121, checked in by bird, 8 years ago

(C) year)

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