source: trunk/kBuild/tools/GXX64.kmk@ 1083

Last change on this file since 1083 was 1064, checked in by bird, 18 years ago

64-bit variations on the GXX32/GCC32 tools.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 11.7 KB
Line 
1# $Id: GXX64.kmk 1064 2007-07-10 15:06:17Z bird $
2## @file
3#
4# kBuild Tool Config - Generic 64-bit GCC v3.2.x or later using the system GCC, for building C++ code.
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_GXX64 := Generic 64-bit GCC v3.2.x or later using the system GCC, for building C++ code. \
28 More or less Linux/ELF specfic.
29
30# Tool Specific Properties
31TOOL_GXX64_CC ?= gcc$(HOSTSUFF_EXE) -m64
32TOOL_GXX64_CXX ?= g++$(HOSTSUFF_EXE) -m64
33TOOL_GXX64_AS ?= gcc$(HOSTSUFF_EXE) -m64
34TOOL_GXX64_AR ?= ar$(HOSTSUFF_EXE)
35TOOL_GXX64_LD ?= g++$(HOSTSUFF_EXE) -m64
36TOOL_GXX64_LD_SYSMOD ?= ld$(HOSTSUFF_EXE)
37ifndef TOOL_GXX64_LDFLAGS.$(BUILD_TARGET)
38TOOL_GXX64_LDFLAGS.dll ?= -shared
39else
40TOOL_GXX64_LDFLAGS.dll ?= $(TOOL_GXX64_LDFLAGS.$(BUILD_TARGET))
41endif
42TOOL_GXX64_LDFLAGS.sysmod ?= -r -m elf_x86_64
43TOOL_GXX64_LD_SONAME ?= -Wl,-soname=$(firstword $($(1)_SONAME.$(BUILD_TARGET).$(BUILD_TYPE)) $($(1)_SONAME.$(BUILD_TARGET)) $($(1)_SONAME.$(BUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
44ifeq ($(BUILD_TARGET),os2)
45TOOL_GXX64_LD_MAP ?= -Zmap=$(1)
46else
47TOOL_GXX64_LD_MAP ?= -Wl,-Map -Wl,$(1) -Wl,--cref
48endif
49ifeq ($(BUILD_TARGET),os2)
50TOOL_GXX64_LD_SYSMOD_MAP ?= -Zmap=$(1)
51else
52TOOL_GXX64_LD_SYSMOD_MAP ?= -Map $(1) --cref
53endif
54ifdef SLKRUNS
55TOOL_GXX64_CC += -fmessage-length=0
56TOOL_GXX64_CXX += -fmessage-length=0
57endif
58
59# General Properties used by kBuild
60TOOL_GXX64_COBJSUFF ?= .o
61TOOL_GXX64_CFLAGS ?=
62TOOL_GXX64_CFLAGS.debug ?= -g
63TOOL_GXX64_CFLAGS.profile ?= -O2 #-g -pg
64TOOL_GXX64_CFLAGS.release ?= -O2
65TOOL_GXX64_CINCS ?=
66TOOL_GXX64_CDEFS ?=
67
68TOOL_GXX64_CXXOBJSUFF ?= .o
69TOOL_GXX64_CXXOBJSUFF ?= .o
70TOOL_GXX64_CXXFLAGS ?=
71TOOL_GXX64_CXXFLAGS.debug ?= -g
72TOOL_GXX64_CXXFLAGS.profile ?= -O2 #-g -pg
73TOOL_GXX64_CXXFLAGS.release ?= -O2
74TOOL_GXX64_CXXINCS ?=
75TOOL_GXX64_CXXDEFS ?=
76
77TOOL_GXX64_ASFLAGS ?= -x assembler-with-cpp
78TOOL_GXX64_ASFLAGS.debug ?= -g
79TOOL_GXX64_ASFLAGS.profile ?= -g
80TOOL_GXX64_ASOBJSUFF ?= .o
81
82TOOL_GXX64_ARFLAGS ?= cr
83TOOL_GXX64_ARLIBSUFF ?= .a
84
85TOOL_GXX64_LDFLAGS ?=
86TOOL_GXX64_LDFLAGS.debug ?= -g
87TOOL_GXX64_LDFLAGS.profile ?= -g
88
89
90## Compile C source.
91# @param $(target) Normalized main target name.
92# @param $(source) Source filename (relative).
93# @param $(obj) Object file name. This shall be (re)created by the compilation.
94# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
95# @param $(flags) Flags.
96# @param $(defs) Definitions. No -D or something.
97# @param $(incs) Includes. No -I or something.
98# @param $(dirdep) Directory creation dependency.
99# @param $(deps) Other dependencies.
100#
101# @param $(outbase) Output basename (full). Use this for list files and such.
102# @param $(objsuff) Object suffix.
103TOOL_GXX64_COMPILE_C_DEPEND =
104TOOL_GXX64_COMPILE_C_DEPORD =
105ifdef USE_KOBJCACHE
106TOOL_GXX64_COMPILE_C_USES_KOBJCACHE = 1
107TOOL_GXX64_COMPILE_C_OUTPUT = $(outbase).i
108define TOOL_GXX64_COMPILE_C_CMDS
109 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
110 --kObjCache-cpp $(outbase).i\
111 $(TOOL_GXX64_CC) -E -o -\
112 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
113 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
114 $(abspath $(source))\
115 --kObjCache-cc $(obj)\
116 $(TOOL_GXX64_CC) -c\
117 $(flags) -fpreprocessed -x c\
118 -o $(obj)\
119 -
120endef
121else # !USE_KOBJCACHE
122TOOL_GXX64_COMPILE_C_OUTPUT =
123define TOOL_GXX64_COMPILE_C_CMDS
124 $(QUIET)$(TOOL_GXX64_CC) -c\
125 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
126 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
127 -o $(obj)\
128 $(abspath $(source))
129endef
130endif # !USE_KOBJCACHE
131
132
133## Compile C++ source.
134# @param $(target) Normalized main target name.
135# @param $(source) Source filename (relative).
136# @param $(obj) Object file name. This shall be (re)created by the compilation.
137# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
138# @param $(flags) Flags.
139# @param $(defs) Definitions. No -D or something.
140# @param $(incs) Includes. No -I or something.
141# @param $(dirdep) Directory creation dependency.
142# @param $(deps) Other dependencies.
143# @param $(outbase) Output basename (full). Use this for list files and such.
144# @param $(objsuff) Object suffix.
145TOOL_GXX64_COMPILE_CXX_DEPEND =
146TOOL_GXX64_COMPILE_CXX_DEPORD =
147ifdef USE_KOBJCACHE
148TOOL_GXX64_COMPILE_CXX_USES_KOBJCACHE = 1
149TOOL_GXX64_COMPILE_CXX_OUTPUT = $(outbase).ii
150define TOOL_GXX64_COMPILE_CXX_CMDS
151 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
152 --kObjCache-cpp $(outbase).ii\
153 $(TOOL_GXX64_CXX) -E -o -\
154 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
155 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
156 $(abspath $(source))\
157 --kObjCache-cc $(obj)\
158 $(TOOL_GXX64_CXX) -c\
159 $(flags) -fpreprocessed -x c++\
160 -o $(obj)\
161 -
162endef
163else # !USE_KOBJCACHE
164TOOL_GXX64_COMPILE_CXX_OUTPUT =
165define TOOL_GXX64_COMPILE_CXX_CMDS
166 $(QUIET)$(TOOL_GXX64_CXX) -c\
167 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
168 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
169 -o $(obj)\
170 $(abspath $(source))
171endef
172endif # !USE_KOBJCACHE
173
174
175## Compile Assembly source.
176# @param $(target) Normalized main target name.
177# @param $(source) Source filename (relative).
178# @param $(obj) Object file name. This shall be (re)created by the compilation.
179# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
180# @param $(flags) Flags.
181# @param $(defs) Definitions. No -D or something.
182# @param $(incs) Includes. No -I or something.
183# @param $(dirdep) Directory creation dependency.
184# @param $(deps) Other dependencies.
185# @param $(outbase) Output basename (full). Use this for list files and such.
186# @param $(objsuff) Object suffix.
187#
188TOOL_GXX64_COMPILE_AS_OUTPUT =
189TOOL_GXX64_COMPILE_AS_DEPEND =
190TOOL_GXX64_COMPILE_AS_DEPORD =
191define TOOL_GXX64_COMPILE_AS_CMDS
192 $(QUIET)$(TOOL_GXX64_AS) -c\
193 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
194 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
195 -o $(obj)\
196 $(abspath $(source))
197endef
198
199
200## Link library
201# @param $(target) Normalized main target name.
202# @param $(out) Library name.
203# @param $(objs) Object files to put in the library.
204# @param $(flags) Flags.
205# @param $(dirdep) Directory creation dependency.
206# @param $(deps) Other dependencies.
207# @param $(othersrc) Unhandled sources.
208# @param $(outbase) Output basename (full). Use this for list files and such.
209TOOL_GXX64_LINK_LIBRARY_OUTPUT = $(out).ar-script
210TOOL_GXX64_LINK_LIBRARY_DEPEND = $(othersrc)
211TOOL_GXX64_LINK_LIBRARY_DEPORD =
212ifeq ($(filter append-dash-n,$(KMK_FEATURES)),append-dash-n)
213define TOOL_GXX64_LINK_LIBRARY_CMDS
214 $(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)'
215 $(QUIET)$(APPEND) -n $(out).ar-script \
216 $(foreach o,$(objs), 'ADDMOD $(o)') \
217 $(foreach o,$(othersrc), 'ADDLIB $(o)')
218 $(QUIET)$(APPEND) $(out).ar-script 'SAVE'
219 $(QUIET)$(APPEND) $(out).ar-script 'END'
220 $(QUIET)$(TOOL_GXX64_AR) -M < $(out).ar-script
221endef
222else
223define TOOL_GXX64_LINK_LIBRARY_CMDS
224 $(QUIET)$(APPEND) $(out).ar-script "CREATE $(out)"
225 $(foreach o, $(objs)\
226 ,$(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script "ADDMOD $(o)")
227 $(foreach srclib,$(othersrc)\
228 ,$(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script "ADDLIB $(srclib)")
229 $(QUIET)$(APPEND) $(out).ar-script "SAVE"
230 $(QUIET)$(APPEND) $(out).ar-script "END"
231 $(QUIET)$(TOOL_GXX64_AR) -M < $(out).ar-script
232endef
233endif
234
235
236## Link program
237# @param $(target) Normalized main target name.
238# @param $(out) Program name.
239# @param $(objs) Object files to link together.
240# @param $(libs) Libraries to search.
241# @param $(libpath) Library search paths.
242# @param $(flags) Flags.
243# @param $(dirdep) Directory creation dependency.
244# @param $(deps) Other dependencies.
245# @param $(othersrc) Unhandled sources.
246# @param $(custom_pre) Custom step invoked before linking.
247# @param $(custom_post) Custom step invoked after linking.
248# @param $(outbase) Output basename (full). Use this for list files and such.
249TOOL_GXX64_LINK_PROGRAM_OUTPUT =
250TOOL_GXX64_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map
251TOOL_GXX64_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
252TOOL_GXX64_LINK_PROGRAM_DEPORD =
253define TOOL_GXX64_LINK_PROGRAM_CMDS
254 $(QUIET)$(TOOL_GXX64_LD) $(flags) -o $(out) $(objs)\
255 $(foreach p,$(libpath), -L$(p))\
256 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
257 $(call TOOL_GXX64_LD_MAP,$(outbase).map)
258endef
259
260
261## Link DLL
262# @param $(target) Normalized main target name.
263# @param $(out) Program name.
264# @param $(objs) Object files to link together.
265# @param $(libs) Libraries to search.
266# @param $(libpath) Library search paths.
267# @param $(flags) Flags.
268# @param $(dirdep) Directory creation dependency.
269# @param $(deps) Other dependencies.
270# @param $(othersrc) Unhandled sources.
271# @param $(custom_pre) Custom step invoked before linking.
272# @param $(custom_post) Custom step invoked after linking.
273# @param $(outbase) Output basename (full). Use this for list files and such.
274TOOL_GXX64_LINK_DLL_OUTPUT =
275TOOL_GXX64_LINK_DLL_OUTPUT_MAYBE = $(outbase).map
276TOOL_GXX64_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
277TOOL_GXX64_LINK_DLL_DEPORD =
278define TOOL_GXX64_LINK_DLL_CMDS
279 $(QUIET)$(TOOL_GXX64_LD) $(TOOL_GXX64_LDFLAGS.dll) $(flags) -o $(out)\
280 $(if $(filter-out win os2, $(BUILD_TARGET)),$(call TOOL_GXX64_LD_SONAME,$(target),$(out)))\
281 $(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_GXX64_LD_MAP,$(outbase).map)
285endef
286
287
288## Link system module (windows aka driver, linux aka kernel module)
289# @param $(target) Normalized main target name.
290# @param $(out) System module name.
291# @param $(objs) Object files to link together.
292# @param $(libs) Libraries to search.
293# @param $(libpath) Library search paths.
294# @param $(flags) Flags.
295# @param $(dirdep) Directory creation dependency.
296# @param $(deps) Other dependencies.
297# @param $(othersrc) Unhandled sources.
298# @param $(custom_pre) Custom step invoked before linking.
299# @param $(custom_post) Custom step invoked after linking.
300# @param $(outbase) Output basename (full). Use this for list files and such.
301TOOL_GXX64_LINK_SYSMOD_OUTPUT =
302TOOL_GXX64_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map
303TOOL_GXX64_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
304TOOL_GXX64_LINK_SYSMOD_DEPORD =
305define TOOL_GXX64_LINK_SYSMOD_CMDS
306 $(QUIET)$(TOOL_GXX64_LD_SYSMOD) $(TOOL_GXX64_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
307 $(foreach p,$(libpath), -L$(p))\
308 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
309 $(call TOOL_GXX64_LD_SYSMOD_MAP,$(outbase).map)
310endef
311
Note: See TracBrowser for help on using the repository browser.