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

Last change on this file since 2487 was 2431, checked in by bird, 15 years ago

tools/G*.kmk: Add dummy source rule/dep to the gcc generated dependency files to make it less painful to move a source file without changing the target names. Fixes #101.

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