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