3 # kBuild Tool Config - GCC Cross compiler for AMD64+Linux.
7 # Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@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_HOSTSUFF_EXE ?
= $(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
)
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 $(PATH_DEVTOOLS_BLD
)/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 $(PATH_DEVTOOLS
)/win.x86
/x86_64-unknown-linux-gnu
/*))
52 ifeq ($(PATH_TOOL_XGCCAMD64LINUX
),)
53 PATH_TOOL_XGCCAMD64LINUX
:= $(sort $(wildcard $(PATH_DEVTOOLS
)/x86.win32
/x86_64-unknown-linux-gnu
/*))
57 ifneq ($(PATH_TOOL_XGCCAMD64LINUX
),)
58 PATH_TOOL_XGCCAMD64LINUX
:= $(call lastword
,$(PATH_TOOL_XGCCAMD64LINUX
))
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
)
65 # Resolve any fancy stuff once and for all.
66 TOOL_XGCCAMD64LINUX_PREFIX
:= $(TOOL_XGCCAMD64LINUX_PREFIX
)
70 TOOL_XGCCAMD64LINUX_CC ?
= $(TOOL_XGCCAMD64LINUX_PREFIX
)gcc
$(TOOL_XGCCAMD64LINUX_HOSTSUFF_EXE
)
71 TOOL_XGCCAMD64LINUX_CXX ?
= $(TOOL_XGCCAMD64LINUX_PREFIX
)g
++$(TOOL_XGCCAMD64LINUX_HOSTSUFF_EXE
)
72 TOOL_XGCCAMD64LINUX_AS ?
= $(TOOL_XGCCAMD64LINUX_PREFIX
)gcc
$(TOOL_XGCCAMD64LINUX_HOSTSUFF_EXE
)
73 TOOL_XGCCAMD64LINUX_AR ?
= $(TOOL_XGCCAMD64LINUX_PREFIX
)ar$(TOOL_XGCCAMD64LINUX_HOSTSUFF_EXE
)
74 TOOL_XGCCAMD64LINUX_LD ?
= $(TOOL_XGCCAMD64LINUX_PREFIX
)g
++$(TOOL_XGCCAMD64LINUX_HOSTSUFF_EXE
)
75 TOOL_XGCCAMD64LINUX_LD_SYSMOD ?
= $(TOOL_XGCCAMD64LINUX_PREFIX
)ld$(TOOL_XGCCAMD64LINUX_HOSTSUFF_EXE
)
77 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)))
78 TOOL_XGCCAMD64LINUX_LD_MAP ?
= -Wl
,-Map
-Wl
,$(1) -Wl
,--cref
79 TOOL_XGCCAMD64LINUX_LD_SYSMOD_MAP ?
= -Map
$(1) --cref
80 TOOL_XGCCAMD64LINUX_LDFLAGS.dll ?
= -shared
81 TOOL_XGCCAMD64LINUX_LDFLAGS.sysmod ?
= -r
84 TOOL_XGCCAMD64LINUX_CC
+= -fmessage-length
=0
85 TOOL_XGCCAMD64LINUX_CXX
+= -fmessage-length
=0
88 # General Properties used by kBuild
89 TOOL_XGCCAMD64LINUX_COBJSUFF ?
= .o
90 TOOL_XGCCAMD64LINUX_CFLAGS ?
= -g
91 TOOL_XGCCAMD64LINUX_CFLAGS.debug ?
= -O0
92 TOOL_XGCCAMD64LINUX_CFLAGS.release ?
= -O2
93 TOOL_XGCCAMD64LINUX_CFLAGS.profile ?
= -O2
#-pg
94 TOOL_XGCCAMD64LINUX_CINCS ?
=
95 TOOL_XGCCAMD64LINUX_CDEFS ?
=
97 TOOL_XGCCAMD64LINUX_CXXOBJSUFF ?
= .o
98 TOOL_XGCCAMD64LINUX_CXXOBJSUFF ?
= .o
99 TOOL_XGCCAMD64LINUX_CXXFLAGS ?
= -g
100 TOOL_XGCCAMD64LINUX_CXXFLAGS.debug ?
= -O0
101 TOOL_XGCCAMD64LINUX_CXXFLAGS.release ?
= -O2
102 TOOL_XGCCAMD64LINUX_CXXFLAGS.profile ?
= -O2
#-pg
103 TOOL_XGCCAMD64LINUX_CXXINCS ?
=
104 TOOL_XGCCAMD64LINUX_CXXDEFS ?
=
106 TOOL_XGCCAMD64LINUX_ASFLAGS ?
= -g
-x assembler-with-cpp
107 TOOL_XGCCAMD64LINUX_ASOBJSUFF ?
= .o
109 TOOL_XGCCAMD64LINUX_ARFLAGS ?
= cr
110 TOOL_XGCCAMD64LINUX_ARLIBSUFF ?
= .a
112 TOOL_XGCCAMD64LINUX_LDFLAGS ?
=
113 TOOL_XGCCAMD64LINUX_LDFLAGS.debug ?
= -g
114 TOOL_XGCCAMD64LINUX_LDFLAGS.release ?
= -s
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.
129 # @param $(outbase) Output basename (full). Use this for list files and such.
130 # @param $(objsuff) Object suffix.
131 TOOL_XGCCAMD64LINUX_COMPILE_C_OUTPUT
=
132 TOOL_XGCCAMD64LINUX_COMPILE_C_DEPEND
=
133 TOOL_XGCCAMD64LINUX_COMPILE_C_DEPORD
=
134 define 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\
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.
155 TOOL_XGCCAMD64LINUX_COMPILE_CXX_OUTPUT
=
156 TOOL_XGCCAMD64LINUX_COMPILE_CXX_DEPEND
=
157 TOOL_XGCCAMD64LINUX_COMPILE_CXX_DEPORD
=
158 define 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\
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.
179 TOOL_XGCCAMD64LINUX_COMPILE_AS_OUTPUT
=
180 TOOL_XGCCAMD64LINUX_COMPILE_AS_DEPEND
=
181 TOOL_XGCCAMD64LINUX_COMPILE_AS_DEPORD
=
182 define 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\
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.
200 TOOL_XGCCAMD64LINUX_LINK_LIBRARY_OUTPUT
= $(out
).ar-script
201 TOOL_XGCCAMD64LINUX_LINK_LIBRARY_DEPEND
= $(othersrc
)
202 TOOL_XGCCAMD64LINUX_LINK_LIBRARY_DEPORD
=
203 define 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
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.
227 TOOL_XGCCAMD64LINUX_LINK_PROGRAM_OUTPUT
= $(outbase
).map
228 TOOL_XGCCAMD64LINUX_LINK_PROGRAM_DEPEND
= $(foreach lib
,$(libs
),$(if
$(findstring $(lib
),$(subst /,x
,$(lib
))),, $(lib
)))
229 TOOL_XGCCAMD64LINUX_LINK_PROGRAM_DEPORD
=
230 define 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
)
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.
251 TOOL_XGCCAMD64LINUX_LINK_DLL_OUTPUT
= $(outbase
).map
252 TOOL_XGCCAMD64LINUX_LINK_DLL_DEPEND
= $(foreach lib
,$(libs
),$(if
$(findstring $(lib
),$(subst /,x
,$(lib
))),, $(lib
)))
253 TOOL_XGCCAMD64LINUX_LINK_DLL_DEPORD
=
254 define 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
)))\
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
)
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.
277 TOOL_XGCCAMD64LINUX_LINK_SYSMOD_OUTPUT
= $(outbase
).map
278 TOOL_XGCCAMD64LINUX_LINK_SYSMOD_DEPEND
= $(foreach lib
,$(libs
),$(if
$(findstring $(lib
),$(subst /,x
,$(lib
))),, $(lib
)))
279 TOOL_XGCCAMD64LINUX_LINK_SYSMOD_DEPORD
=
280 define 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
)