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

Last change on this file since 570 was 471, checked in by bird, 19 years ago

assembler-with-cpp by default.

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