source: trunk/kBuild/tools/GCC64.kmk@ 2246

Last change on this file since 2246 was 2246, checked in by bird, 17 years ago

GXX32,GCC32,GXX64,GCC64: FreeBSD ld doesn't do standard elf_<arch> but elf_<arch>_fbsd. (sysmod linking)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.6 KB
Line 
1# $Id: GCC64.kmk 2246 2009-01-18 02:08:37Z bird $
2## @file
3# kBuild Tool Config - Generic 64-bit GCC v3.2.x or later Using The System GCC.
4#
5
6#
7# Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@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_GCC64 := Generic 64-bit GCC v3.2.x or later Using The System GCC. \
35 More or less Linux/ELF specfic.
36
37# Tool Specific Properties
38TOOL_GCC64_CC ?= gcc$(HOSTSUFF_EXE) -m64
39TOOL_GCC64_CXX ?= g++$(HOSTSUFF_EXE) -m64
40TOOL_GCC64_AS ?= gcc$(HOSTSUFF_EXE) -m64
41TOOL_GCC64_AR ?= ar$(HOSTSUFF_EXE)
42TOOL_GCC64_LD ?= gcc$(HOSTSUFF_EXE) -m64
43TOOL_GCC64_LD_SYSMOD ?= ld$(HOSTSUFF_EXE)
44ifndef TOOL_GCC64_LDFLAGS.$(KBUILD_TARGET)
45TOOL_GCC64_LDFLAGS.dll ?= -shared
46else
47TOOL_GCC64_LDFLAGS.dll ?= $(TOOL_GCC64_LDFLAGS.$(KBUILD_TARGET))
48endif
49TOOL_GCC64_LDFLAGS.sysmod ?= -r -m elf_x86_64$(if-expr "$(KBUILD_TARGET)" == "freebsd",_fbsd,)
50TOOL_GCC64_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_GCC64_LD_MAP ?= -Zmap=$(1)
53else
54TOOL_GCC64_LD_MAP ?=
55endif
56ifeq ($(KBUILD_TARGET),os2)
57TOOL_GCC64_LD_SYSMOD_MAP ?= -Zmap=$(1)
58else
59TOOL_GCC64_LD_SYSMOD_MAP ?=
60endif
61ifdef SLKRUNS
62TOOL_GCC64_CC += -fmessage-length=0
63TOOL_GCC64_CXX += -fmessage-length=0
64endif
65
66# General Properties used by kBuild
67TOOL_GCC64_COBJSUFF ?= .o
68TOOL_GCC64_CFLAGS ?=
69TOOL_GCC64_CFLAGS.debug ?= -g
70TOOL_GCC64_CFLAGS.profile ?= -O2 #-g -pg
71TOOL_GCC64_CFLAGS.release ?= -O2
72TOOL_GCC64_CINCS ?=
73TOOL_GCC64_CDEFS ?=
74
75TOOL_GCC64_CXXOBJSUFF ?= .o
76TOOL_GCC64_CXXOBJSUFF ?= .o
77TOOL_GCC64_CXXFLAGS ?=
78TOOL_GCC64_CXXFLAGS.debug ?= -g
79TOOL_GCC64_CXXFLAGS.profile ?= -O2 #-g -pg
80TOOL_GCC64_CXXFLAGS.release ?= -O2
81TOOL_GCC64_CXXINCS ?=
82TOOL_GCC64_CXXDEFS ?=
83
84TOOL_GCC64_ASFLAGS ?= -x assembler-with-cpp
85TOOL_GCC64_ASFLAGS.debug ?= -g
86TOOL_GCC64_ASFLAGS.profile ?= -g
87TOOL_GCC64_ASOBJSUFF ?= .o
88
89TOOL_GCC64_ARFLAGS ?= cr
90TOOL_GCC64_ARLIBSUFF ?= .a
91
92TOOL_GCC64_LDFLAGS ?=
93TOOL_GCC64_LDFLAGS.debug ?= -g
94TOOL_GCC64_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_GCC64_COMPILE_C_DEPEND =
111TOOL_GCC64_COMPILE_C_DEPORD =
112ifdef KBUILD_USE_KOBJCACHE
113TOOL_GCC64_COMPILE_C_USES_KOBJCACHE = 1
114TOOL_GCC64_COMPILE_C_OUTPUT = $(outbase).i
115define TOOL_GCC64_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_GCC64_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_GCC64_CC) -c\
124 $(flags) -fpreprocessed -x c\
125 -o $(obj)\
126 -
127endef
128else # !KBUILD_USE_KOBJCACHE
129TOOL_GCC64_COMPILE_C_OUTPUT =
130define TOOL_GCC64_COMPILE_C_CMDS
131 $(QUIET)$(TOOL_GCC64_CC) -c\
132 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
133 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
134 -o $(obj)\
135 $(abspath $(source))
136endef
137endif # !KBUILD_USE_KOBJCACHE
138
139
140## Compile C++ source.
141# @param $(target) Normalized main target name.
142# @param $(source) Source filename (relative).
143# @param $(obj) Object file name. This shall be (re)created by the compilation.
144# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
145# @param $(flags) Flags.
146# @param $(defs) Definitions. No -D or something.
147# @param $(incs) Includes. No -I or something.
148# @param $(dirdep) Directory creation dependency.
149# @param $(deps) Other dependencies.
150# @param $(outbase) Output basename (full). Use this for list files and such.
151# @param $(objsuff) Object suffix.
152TOOL_GCC64_COMPILE_CXX_DEPEND =
153TOOL_GCC64_COMPILE_CXX_DEPORD =
154ifdef KBUILD_USE_KOBJCACHE
155TOOL_GCC64_COMPILE_CXX_USES_KOBJCACHE = 1
156TOOL_GCC64_COMPILE_CXX_OUTPUT = $(outbase).ii
157define TOOL_GCC64_COMPILE_CXX_CMDS
158 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
159 --kObjCache-cpp $(outbase).ii\
160 $(TOOL_GCC64_CXX) -E -o -\
161 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
162 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
163 $(abspath $(source))\
164 --kObjCache-cc $(obj)\
165 $(TOOL_GCC64_CXX) -c\
166 $(flags) -fpreprocessed -x c++\
167 -o $(obj)\
168 -
169endef
170else # !KBUILD_USE_KOBJCACHE
171
172TOOL_GCC64_COMPILE_CXX_OUTPUT =
173define TOOL_GCC64_COMPILE_CXX_CMDS
174 $(QUIET)$(TOOL_GCC64_CXX) -c\
175 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
176 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
177 -o $(obj)\
178 $(abspath $(source))
179endef
180endif # !KBUILD_USE_KOBJCACHE
181
182
183## Compile Assembly source.
184# @param $(target) Normalized main target name.
185# @param $(source) Source filename (relative).
186# @param $(obj) Object file name. This shall be (re)created by the compilation.
187# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
188# @param $(flags) Flags.
189# @param $(defs) Definitions. No -D or something.
190# @param $(incs) Includes. No -I or something.
191# @param $(dirdep) Directory creation dependency.
192# @param $(deps) Other dependencies.
193# @param $(outbase) Output basename (full). Use this for list files and such.
194# @param $(objsuff) Object suffix.
195#
196TOOL_GCC64_COMPILE_AS_OUTPUT =
197TOOL_GCC64_COMPILE_AS_DEPEND =
198TOOL_GCC64_COMPILE_AS_DEPORD =
199define TOOL_GCC64_COMPILE_AS_CMDS
200 $(QUIET)$(TOOL_GCC64_AS) -c\
201 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
202 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
203 -o $(obj)\
204 $(abspath $(source))
205endef
206
207
208## Link library
209# @param $(target) Normalized main target name.
210# @param $(out) Library name.
211# @param $(objs) Object files to put in the library.
212# @param $(flags) Flags.
213# @param $(dirdep) Directory creation dependency.
214# @param $(deps) Other dependencies.
215# @param $(othersrc) Unhandled sources.
216# @param $(outbase) Output basename (full). Use this for list files and such.
217TOOL_GCC64_LINK_LIBRARY_OUTPUT = $(out).ar-script
218TOOL_GCC64_LINK_LIBRARY_DEPEND = $(othersrc)
219TOOL_GCC64_LINK_LIBRARY_DEPORD =
220define TOOL_GCC64_LINK_LIBRARY_CMDS
221 $(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)'
222 $(QUIET)$(APPEND) -n $(out).ar-script \
223 $(foreach o,$(objs), 'ADDMOD $(o)') \
224 $(foreach o,$(othersrc), 'ADDLIB $(o)')
225 $(QUIET)$(APPEND) $(out).ar-script 'SAVE'
226 $(QUIET)$(APPEND) $(out).ar-script 'END'
227 $(QUIET)$(REDIRECT) -rti $(out).ar-script -- $(TOOL_GCC64_AR) -M
228endef
229
230
231## Link program
232# @param $(target) Normalized main target name.
233# @param $(out) Program name.
234# @param $(objs) Object files to link together.
235# @param $(libs) Libraries to search.
236# @param $(libpath) Library search paths.
237# @param $(flags) Flags.
238# @param $(dirdep) Directory creation dependency.
239# @param $(deps) Other dependencies.
240# @param $(othersrc) Unhandled sources.
241# @param $(custom_pre) Custom step invoked before linking.
242# @param $(custom_post) Custom step invoked after linking.
243# @param $(outbase) Output basename (full). Use this for list files and such.
244TOOL_GCC64_LINK_PROGRAM_OUTPUT =
245TOOL_GCC64_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map
246TOOL_GCC64_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
247TOOL_GCC64_LINK_PROGRAM_DEPORD =
248define TOOL_GCC64_LINK_PROGRAM_CMDS
249 $(QUIET)$(TOOL_GCC64_LD) $(flags) -o $(out) $(objs)\
250 $(foreach p,$(libpath), -L$(p))\
251 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
252 $(call TOOL_GCC64_LD_MAP,$(outbase).map)
253endef
254
255
256## Link DLL
257# @param $(target) Normalized main target name.
258# @param $(out) Program name.
259# @param $(objs) Object files to link together.
260# @param $(libs) Libraries to search.
261# @param $(libpath) Library search paths.
262# @param $(flags) Flags.
263# @param $(dirdep) Directory creation dependency.
264# @param $(deps) Other dependencies.
265# @param $(othersrc) Unhandled sources.
266# @param $(custom_pre) Custom step invoked before linking.
267# @param $(custom_post) Custom step invoked after linking.
268# @param $(outbase) Output basename (full). Use this for list files and such.
269TOOL_GCC64_LINK_DLL_OUTPUT =
270TOOL_GCC64_LINK_DLL_OUTPUT_MAYBE = $(outbase).map
271TOOL_GCC64_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
272TOOL_GCC64_LINK_DLL_DEPORD =
273define TOOL_GCC64_LINK_DLL_CMDS
274 $(QUIET)$(TOOL_GCC64_LD) $(TOOL_GCC64_LDFLAGS.dll) $(flags) -o $(out)\
275 $(if $(filter-out win os2, $(KBUILD_TARGET)),$(call TOOL_GCC64_LD_SONAME,$(target),$(out)))\
276 $(objs)\
277 $(foreach p,$(libpath), -L$(p))\
278 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
279 $(call TOOL_GCC64_LD_MAP,$(outbase).map)
280endef
281
282
283## Link system module (windows aka driver, linux aka kernel module)
284# @param $(target) Normalized main target name.
285# @param $(out) System module name.
286# @param $(objs) Object files to link together.
287# @param $(libs) Libraries to search.
288# @param $(libpath) Library search paths.
289# @param $(flags) Flags.
290# @param $(dirdep) Directory creation dependency.
291# @param $(deps) Other dependencies.
292# @param $(othersrc) Unhandled sources.
293# @param $(custom_pre) Custom step invoked before linking.
294# @param $(custom_post) Custom step invoked after linking.
295# @param $(outbase) Output basename (full). Use this for list files and such.
296TOOL_GCC64_LINK_SYSMOD_OUTPUT =
297TOOL_GCC64_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map
298TOOL_GCC64_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
299TOOL_GCC64_LINK_SYSMOD_DEPORD =
300define TOOL_GCC64_LINK_SYSMOD_CMDS
301 $(QUIET)$(TOOL_GCC64_LD_SYSMOD) $(TOOL_GCC64_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
302 $(foreach p,$(libpath), -L$(p))\
303 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
304 $(call TOOL_GCC64_LD_SYSMOD_MAP,$(outbase).map)
305endef
306
Note: See TracBrowser for help on using the repository browser.