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

Last change on this file since 1312 was 848, checked in by bird, 18 years ago

win.amd64 fixes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 12.5 KB
Line 
1# $Id: XGCCAMD64LINUX.kmk 848 2007-02-06 03:13:07Z bird $
2## @file
3#
4# kBuild Tool Config - GCC Cross compiler for AMD64+Linux.
5#
6# Copyright (c) 2004-2007 knut st. osmundsen <bird-kBuild-spam@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
27TOOL_XGCCAMD64LINUX := GCC Cross compiler for AMD64+Linux.
28
29# Tool Specific Properties
30TOOL_XGCCAMD64LINUX_HOSTSUFF_EXE ?= $(HOSTSUFF_EXE)
31ifeq ($(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH),linux.amd64)
32 # not x-compile, use the default gcc.
33 TOOL_XGCCAMD64LINUX_PREFIX := $(TOOL_XGCCAMD64LINUX_PREFIX)
34else # x-compile:
35 # find the latest xgcc build.
36 ifndef 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)/win.x86/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
61endif
62
63TOOL_XGCCAMD64LINUX_CC ?= $(TOOL_XGCCAMD64LINUX_PREFIX)gcc$(TOOL_XGCCAMD64LINUX_HOSTSUFF_EXE)
64TOOL_XGCCAMD64LINUX_CXX ?= $(TOOL_XGCCAMD64LINUX_PREFIX)g++$(TOOL_XGCCAMD64LINUX_HOSTSUFF_EXE)
65TOOL_XGCCAMD64LINUX_AS ?= $(TOOL_XGCCAMD64LINUX_PREFIX)gcc$(TOOL_XGCCAMD64LINUX_HOSTSUFF_EXE)
66TOOL_XGCCAMD64LINUX_AR ?= $(TOOL_XGCCAMD64LINUX_PREFIX)ar$(TOOL_XGCCAMD64LINUX_HOSTSUFF_EXE)
67TOOL_XGCCAMD64LINUX_LD ?= $(TOOL_XGCCAMD64LINUX_PREFIX)g++$(TOOL_XGCCAMD64LINUX_HOSTSUFF_EXE)
68TOOL_XGCCAMD64LINUX_LD_SYSMOD ?= $(TOOL_XGCCAMD64LINUX_PREFIX)ld$(TOOL_XGCCAMD64LINUX_HOSTSUFF_EXE)
69
70TOOL_XGCCAMD64LINUX_LD_SONAME ?= -Wl,-soname=$(firstword $($(1)_SONAME.$(BUILD_TARGET).$(BUILD_TYPE)) $($(1)_SONAME.$(BUILD_TARGET)) $($(1)_SONAME.$(BUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
71TOOL_XGCCAMD64LINUX_LD_MAP ?= -Wl,-Map -Wl,$(1) -Wl,--cref
72TOOL_XGCCAMD64LINUX_LD_SYSMOD_MAP ?= -Map $(1) --cref
73TOOL_XGCCAMD64LINUX_LDFLAGS.dll ?= -shared
74TOOL_XGCCAMD64LINUX_LDFLAGS.sysmod ?= -r
75
76ifdef SLKRUNS
77TOOL_XGCCAMD64LINUX_CC += -fmessage-length=0
78TOOL_XGCCAMD64LINUX_CXX += -fmessage-length=0
79endif
80
81# General Properties used by kBuild
82TOOL_XGCCAMD64LINUX_COBJSUFF ?= .o
83TOOL_XGCCAMD64LINUX_CFLAGS ?= -g
84TOOL_XGCCAMD64LINUX_CFLAGS.debug ?= -O0
85TOOL_XGCCAMD64LINUX_CFLAGS.release ?= -O2
86TOOL_XGCCAMD64LINUX_CFLAGS.profile ?= -O2 #-pg
87TOOL_XGCCAMD64LINUX_CINCS ?=
88TOOL_XGCCAMD64LINUX_CDEFS ?=
89
90TOOL_XGCCAMD64LINUX_CXXOBJSUFF ?= .o
91TOOL_XGCCAMD64LINUX_CXXOBJSUFF ?= .o
92TOOL_XGCCAMD64LINUX_CXXFLAGS ?= -g
93TOOL_XGCCAMD64LINUX_CXXFLAGS.debug ?= -O0
94TOOL_XGCCAMD64LINUX_CXXFLAGS.release ?= -O2
95TOOL_XGCCAMD64LINUX_CXXFLAGS.profile ?= -O2 #-pg
96TOOL_XGCCAMD64LINUX_CXXINCS ?=
97TOOL_XGCCAMD64LINUX_CXXDEFS ?=
98
99TOOL_XGCCAMD64LINUX_ASFLAGS ?= -g -x assembler-with-cpp
100TOOL_XGCCAMD64LINUX_ASOBJSUFF ?= .o
101
102TOOL_XGCCAMD64LINUX_ARFLAGS ?= cr
103TOOL_XGCCAMD64LINUX_ARLIBSUFF ?= .a
104
105TOOL_XGCCAMD64LINUX_LDFLAGS ?=
106TOOL_XGCCAMD64LINUX_LDFLAGS.debug ?= -g
107TOOL_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.
124TOOL_XGCCAMD64LINUX_COMPILE_C_OUTPUT =
125TOOL_XGCCAMD64LINUX_COMPILE_C_DEPEND =
126TOOL_XGCCAMD64LINUX_COMPILE_C_DEPORD =
127define 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))
133endef
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.
148TOOL_XGCCAMD64LINUX_COMPILE_CXX_OUTPUT =
149TOOL_XGCCAMD64LINUX_COMPILE_CXX_DEPEND =
150TOOL_XGCCAMD64LINUX_COMPILE_CXX_DEPORD =
151define 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))
157endef
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#
172TOOL_XGCCAMD64LINUX_COMPILE_AS_OUTPUT =
173TOOL_XGCCAMD64LINUX_COMPILE_AS_DEPEND =
174TOOL_XGCCAMD64LINUX_COMPILE_AS_DEPORD =
175define 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))
181endef
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.
193TOOL_XGCCAMD64LINUX_LINK_LIBRARY_OUTPUT = $(out).ar-script
194TOOL_XGCCAMD64LINUX_LINK_LIBRARY_DEPEND = $(othersrc)
195TOOL_XGCCAMD64LINUX_LINK_LIBRARY_DEPORD =
196ifeq ($(filter append-dash-n,$(KMK_FEATURES)),append-dash-n)
197define TOOL_XGCCAMD64LINUX_LINK_LIBRARY_CMDS
198 $(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)'
199 $(QUIET)$(APPEND) -n $(out).ar-script \
200 $(foreach o,$(objs), 'ADDMOD $(o)') \
201 $(foreach o,$(othersrc), 'ADDLIB $(o)')
202 $(QUIET)$(APPEND) $(out).ar-script 'SAVE'
203 $(QUIET)$(APPEND) $(out).ar-script 'END'
204 $(QUIET)$(TOOL_XGCCAMD64LINUX_AR) -M < $(out).ar-script
205endef
206else
207define TOOL_XGCCAMD64LINUX_LINK_LIBRARY_CMDS
208 $(QUIET)$(APPEND) $(out).ar-script "CREATE $(out)"
209 $(foreach o, $(objs)\
210 ,$(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script "ADDMOD $(o)")
211 $(foreach srclib, $(othersrc)\
212 ,$(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script "ADDLIB $(srclib)")
213 $(QUIET)$(APPEND) $(out).ar-script "SAVE"
214 $(QUIET)$(APPEND) $(out).ar-script "END"
215 $(QUIET)$(TOOL_XGCCAMD64LINUX_AR) -M < $(out).ar-script
216endef
217endif
218
219
220## Link program
221# @param $(target) Normalized main target name.
222# @param $(out) Program name.
223# @param $(objs) Object files to link together.
224# @param $(libs) Libraries to search.
225# @param $(libpath) Library search paths.
226# @param $(flags) Flags.
227# @param $(dirdep) Directory creation dependency.
228# @param $(deps) Other dependencies.
229# @param $(othersrc) Unhandled sources.
230# @param $(custom_pre) Custom step invoked before linking.
231# @param $(custom_post) Custom step invoked after linking.
232# @param $(outbase) Output basename (full). Use this for list files and such.
233TOOL_XGCCAMD64LINUX_LINK_PROGRAM_OUTPUT = $(outbase).map
234TOOL_XGCCAMD64LINUX_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
235TOOL_XGCCAMD64LINUX_LINK_PROGRAM_DEPORD =
236define TOOL_XGCCAMD64LINUX_LINK_PROGRAM_CMDS
237 $(QUIET)$(TOOL_XGCCAMD64LINUX_LD) $(flags) -o $(out) $(objs)\
238 $(foreach p,$(libpath), -L$(p))\
239 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
240 $(call TOOL_XGCCAMD64LINUX_LD_MAP,$(outbase).map)
241endef
242
243
244## Link DLL
245# @param $(target) Normalized main target name.
246# @param $(out) Program name.
247# @param $(objs) Object files to link together.
248# @param $(libs) Libraries to search.
249# @param $(libpath) Library search paths.
250# @param $(flags) Flags.
251# @param $(dirdep) Directory creation dependency.
252# @param $(deps) Other dependencies.
253# @param $(othersrc) Unhandled sources.
254# @param $(custom_pre) Custom step invoked before linking.
255# @param $(custom_post) Custom step invoked after linking.
256# @param $(outbase) Output basename (full). Use this for list files and such.
257TOOL_XGCCAMD64LINUX_LINK_DLL_OUTPUT = $(outbase).map
258TOOL_XGCCAMD64LINUX_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
259TOOL_XGCCAMD64LINUX_LINK_DLL_DEPORD =
260define TOOL_XGCCAMD64LINUX_LINK_DLL_CMDS
261 $(QUIET)$(TOOL_XGCCAMD64LINUX_LD) $(TOOL_XGCCAMD64LINUX_LDFLAGS.dll) $(flags) -o $(out)\
262 $(if $(filter-out win32 os2, $(BUILD_TARGET)),$(call TOOL_XGCCAMD64LINUX_LD_SONAME,$(target),$(out)))\
263 $(objs)\
264 $(foreach p,$(libpath), -L$(p))\
265 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
266 $(call TOOL_XGCCAMD64LINUX_LD_MAP,$(outbase).map)
267endef
268
269
270## Link system module (windows aka driver, linux aka kernel module)
271# @param $(target) Normalized main target name.
272# @param $(out) System module name.
273# @param $(objs) Object files to link together.
274# @param $(libs) Libraries to search.
275# @param $(libpath) Library search paths.
276# @param $(flags) Flags.
277# @param $(dirdep) Directory creation dependency.
278# @param $(deps) Other dependencies.
279# @param $(othersrc) Unhandled sources.
280# @param $(custom_pre) Custom step invoked before linking.
281# @param $(custom_post) Custom step invoked after linking.
282# @param $(outbase) Output basename (full). Use this for list files and such.
283TOOL_XGCCAMD64LINUX_LINK_SYSMOD_OUTPUT = $(outbase).map
284TOOL_XGCCAMD64LINUX_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
285TOOL_XGCCAMD64LINUX_LINK_SYSMOD_DEPORD =
286define TOOL_XGCCAMD64LINUX_LINK_SYSMOD_CMDS
287 $(QUIET)$(TOOL_XGCCAMD64LINUX_LD_SYSMOD) $(TOOL_XGCCAMD64LINUX_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
288 $(foreach p,$(libpath), -L$(p))\
289 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
290 $(call TOOL_XGCCAMD64LINUX_LD_SYSMOD_MAP,$(outbase).map)
291endef
292
Note: See TracBrowser for help on using the repository browser.