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

Last change on this file since 653 was 650, checked in by bird, 19 years ago

PATH_DEV -> PATH_DEV_BLD w/ compatability hack.

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