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

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

Implemented KBUILD_QUIET and KBUILD_VERBOSE={1|full} (was BUILD_QUIET, BUILD_VERBOSE, BUILD_DEBUG).

  • Property svn:keywords set to Id
File size: 12.4 KB
Line 
1# $Id: XGCCAMD64LINUX.kmk 696 2006-12-10 07:16:02Z 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
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 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
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 $(call 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 $(call 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 $(call 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 = $(filter %.a %.lib,$(othersrc))
195TOOL_XGCCAMD64LINUX_LINK_LIBRARY_DEPORD =
196define 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
205endef
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.
221TOOL_XGCCAMD64LINUX_LINK_PROGRAM_OUTPUT = $(outbase).map
222TOOL_XGCCAMD64LINUX_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
223TOOL_XGCCAMD64LINUX_LINK_PROGRAM_DEPORD =
224define 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)
229endef
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.
245TOOL_XGCCAMD64LINUX_LINK_DLL_OUTPUT = $(outbase).map
246TOOL_XGCCAMD64LINUX_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
247TOOL_XGCCAMD64LINUX_LINK_DLL_DEPORD =
248define 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)
255endef
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.
271TOOL_XGCCAMD64LINUX_LINK_SYSMOD_OUTPUT = $(outbase).map
272TOOL_XGCCAMD64LINUX_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
273TOOL_XGCCAMD64LINUX_LINK_SYSMOD_DEPORD =
274define 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)
279endef
280
Note: See TracBrowser for help on using the repository browser.