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

Last change on this file since 3062 was 3062, checked in by bird, 8 years ago

netbsd patches from Uwe. Messing around on arm (arm -> arm32, adding arm64); Adding GNU/kFreeBSD and GNU/kNetBSD to the OS list. Added SuperH to archs. Recognize ppc64le as ppc64 in env.sh. Misc.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.1 KB
Line 
1# $Id: GCC64.kmk 3062 2017-09-30 11:26:21Z 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-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_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" || "$(KBUILD_TARGET)" == "gnukfbsd",_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
61if1of ($(KBUILD_HOST), solaris)
62 TOOL_GCC64_OBJCOPY ?= gobjcopy$(HOSTSUFF_EXE)
63else
64 TOOL_GCC64_OBJCOPY ?= objcopy$(HOSTSUFF_EXE)
65endif
66
67ifdef SLKRUNS
68 TOOL_GCC64_CC += -fmessage-length=0
69 TOOL_GCC64_CXX += -fmessage-length=0
70endif
71
72# General Properties used by kBuild
73TOOL_GCC64_COBJSUFF ?= .o
74TOOL_GCC64_CFLAGS ?=
75TOOL_GCC64_CFLAGS.debug ?= -g
76TOOL_GCC64_CFLAGS.profile ?= -O2 #-g -pg
77TOOL_GCC64_CFLAGS.release ?= -O2
78TOOL_GCC64_CINCS ?=
79TOOL_GCC64_CDEFS ?=
80
81TOOL_GCC64_CXXOBJSUFF ?= .o
82TOOL_GCC64_CXXOBJSUFF ?= .o
83TOOL_GCC64_CXXFLAGS ?=
84TOOL_GCC64_CXXFLAGS.debug ?= -g
85TOOL_GCC64_CXXFLAGS.profile ?= -O2 #-g -pg
86TOOL_GCC64_CXXFLAGS.release ?= -O2
87TOOL_GCC64_CXXINCS ?=
88TOOL_GCC64_CXXDEFS ?=
89
90TOOL_GCC64_ASFLAGS ?= -x assembler-with-cpp
91TOOL_GCC64_ASFLAGS.debug ?= -g
92TOOL_GCC64_ASFLAGS.profile ?= -g
93TOOL_GCC64_ASOBJSUFF ?= .o
94
95TOOL_GCC64_ARFLAGS ?= cr
96TOOL_GCC64_ARLIBSUFF ?= .a
97
98TOOL_GCC64_LDFLAGS ?=
99TOOL_GCC64_LDFLAGS.debug ?= -g
100TOOL_GCC64_LDFLAGS.profile ?= -g
101
102
103## Compile C source.
104# @param $(target) Normalized main target name.
105# @param $(source) Source filename (relative).
106# @param $(obj) Object file name. This shall be (re)created by the compilation.
107# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
108# @param $(flags) Flags.
109# @param $(defs) Definitions. No -D or something.
110# @param $(incs) Includes. No -I or something.
111# @param $(dirdep) Directory creation dependency.
112# @param $(deps) Other dependencies.
113#
114# @param $(outbase) Output basename (full). Use this for list files and such.
115# @param $(objsuff) Object suffix.
116TOOL_GCC64_COMPILE_C_DEPEND =
117TOOL_GCC64_COMPILE_C_DEPORD =
118ifdef KBUILD_USE_KOBJCACHE
119TOOL_GCC64_COMPILE_C_USES_KOBJCACHE = 1
120TOOL_GCC64_COMPILE_C_OUTPUT = $(outbase).i
121define TOOL_GCC64_COMPILE_C_CMDS
122 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
123 --kObjCache-cpp $(outbase).i\
124 $(TOOL_GCC64_CC) -E -o -\
125 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
126 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
127 $(abspath $(source))\
128 --kObjCache-cc $(obj)\
129 $(TOOL_GCC64_CC) -c\
130 $(flags) -fpreprocessed -x c\
131 -o $(obj)\
132 -
133 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
134endef
135else # !KBUILD_USE_KOBJCACHE
136TOOL_GCC64_COMPILE_C_OUTPUT =
137define TOOL_GCC64_COMPILE_C_CMDS
138 $(QUIET)$(TOOL_GCC64_CC) -c\
139 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
140 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
141 -o $(obj)\
142 $(abspath $(source))
143 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
144endef
145endif # !KBUILD_USE_KOBJCACHE
146
147
148## Compile C++ source.
149# @param $(target) Normalized main target name.
150# @param $(source) Source filename (relative).
151# @param $(obj) Object file name. This shall be (re)created by the compilation.
152# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
153# @param $(flags) Flags.
154# @param $(defs) Definitions. No -D or something.
155# @param $(incs) Includes. No -I or something.
156# @param $(dirdep) Directory creation dependency.
157# @param $(deps) Other dependencies.
158# @param $(outbase) Output basename (full). Use this for list files and such.
159# @param $(objsuff) Object suffix.
160TOOL_GCC64_COMPILE_CXX_DEPEND =
161TOOL_GCC64_COMPILE_CXX_DEPORD =
162ifdef KBUILD_USE_KOBJCACHE
163TOOL_GCC64_COMPILE_CXX_USES_KOBJCACHE = 1
164TOOL_GCC64_COMPILE_CXX_OUTPUT = $(outbase).ii
165define TOOL_GCC64_COMPILE_CXX_CMDS
166 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
167 --kObjCache-cpp $(outbase).ii\
168 $(TOOL_GCC64_CXX) -E -o -\
169 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
170 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
171 $(abspath $(source))\
172 --kObjCache-cc $(obj)\
173 $(TOOL_GCC64_CXX) -c\
174 $(flags) -fpreprocessed -x c++\
175 -o $(obj)\
176 -
177 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
178endef
179else # !KBUILD_USE_KOBJCACHE
180TOOL_GCC64_COMPILE_CXX_OUTPUT =
181define TOOL_GCC64_COMPILE_CXX_CMDS
182 $(QUIET)$(TOOL_GCC64_CXX) -c\
183 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
184 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
185 -o $(obj)\
186 $(abspath $(source))
187 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
188endef
189endif # !KBUILD_USE_KOBJCACHE
190
191
192## Compile Assembly source.
193# @param $(target) Normalized main target name.
194# @param $(source) Source filename (relative).
195# @param $(obj) Object file name. This shall be (re)created by the compilation.
196# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
197# @param $(flags) Flags.
198# @param $(defs) Definitions. No -D or something.
199# @param $(incs) Includes. No -I or something.
200# @param $(dirdep) Directory creation dependency.
201# @param $(deps) Other dependencies.
202# @param $(outbase) Output basename (full). Use this for list files and such.
203# @param $(objsuff) Object suffix.
204#
205TOOL_GCC64_COMPILE_AS_OUTPUT =
206TOOL_GCC64_COMPILE_AS_DEPEND =
207TOOL_GCC64_COMPILE_AS_DEPORD =
208define TOOL_GCC64_COMPILE_AS_CMDS
209 $(QUIET)$(TOOL_GCC64_AS) -c\
210 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
211 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
212 -o $(obj)\
213 $(abspath $(source))
214 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
215endef
216
217
218## Link library
219# @param $(target) Normalized main target name.
220# @param $(out) Library name.
221# @param $(objs) Object files to put in the library.
222# @param $(flags) Flags.
223# @param $(dirdep) Directory creation dependency.
224# @param $(deps) Other dependencies.
225# @param $(othersrc) Unhandled sources.
226# @param $(outbase) Output basename (full). Use this for list files and such.
227TOOL_GCC64_LINK_LIBRARY_OUTPUT = $(out).ar-script
228TOOL_GCC64_LINK_LIBRARY_DEPEND = $(othersrc)
229TOOL_GCC64_LINK_LIBRARY_DEPORD =
230define TOOL_GCC64_LINK_LIBRARY_CMDS
231 $(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)'
232 $(QUIET)$(APPEND) -n $(out).ar-script \
233 $(foreach o,$(objs), 'ADDMOD $(o)') \
234 $(foreach o,$(othersrc), 'ADDLIB $(o)')
235 $(QUIET)$(APPEND) $(out).ar-script 'SAVE'
236 $(QUIET)$(APPEND) $(out).ar-script 'END'
237 $(QUIET)$(REDIRECT) -rti $(out).ar-script -- $(TOOL_GCC64_AR) -M
238endef
239
240
241## Link program
242# @param $(target) Normalized main target name.
243# @param $(out) Program name.
244# @param $(objs) Object files to link together.
245# @param $(libs) Libraries to search.
246# @param $(libpath) Library search paths.
247# @param $(flags) Flags.
248# @param $(dirdep) Directory creation dependency.
249# @param $(deps) Other dependencies.
250# @param $(othersrc) Unhandled sources.
251# @param $(custom_pre) Custom step invoked before linking.
252# @param $(custom_post) Custom step invoked after linking.
253# @param $(outbase) Output basename (full). Use this for list files and such.
254TOOL_GCC64_LINK_PROGRAM_OUTPUT =
255TOOL_GCC64_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map
256TOOL_GCC64_LINK_PROGRAM_OUTPUT_DEBUG = $(outbase).debug
257TOOL_GCC64_LINK_PROGRAM_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug
258TOOL_GCC64_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
259TOOL_GCC64_LINK_PROGRAM_DEPORD =
260define TOOL_GCC64_LINK_PROGRAM_CMDS
261 $(QUIET)$(TOOL_GCC64_LD) $(flags) -o $(out) $(objs)\
262 $(foreach p,$(libpath), -L$(p))\
263 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
264 $(call TOOL_GCC64_LD_MAP,$(outbase).map)
265 ifeq ($(ld_debug),split)
266 $(QUIET)$(TOOL_GCC64_OBJCOPY) --only-keep-debug $(out) $(outbase).debug
267 $(QUIET)$(CHMOD) a-x $(outbase).debug
268 $(QUIET)$(TOOL_GCC64_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out)
269 endif
270endef
271
272
273## Link DLL
274# @param $(target) Normalized main target name.
275# @param $(out) Program name.
276# @param $(objs) Object files to link together.
277# @param $(libs) Libraries to search.
278# @param $(libpath) Library search paths.
279# @param $(flags) Flags.
280# @param $(dirdep) Directory creation dependency.
281# @param $(deps) Other dependencies.
282# @param $(othersrc) Unhandled sources.
283# @param $(custom_pre) Custom step invoked before linking.
284# @param $(custom_post) Custom step invoked after linking.
285# @param $(outbase) Output basename (full). Use this for list files and such.
286TOOL_GCC64_LINK_DLL_OUTPUT =
287TOOL_GCC64_LINK_DLL_OUTPUT_MAYBE = $(outbase).map
288TOOL_GCC64_LINK_DLL_OUTPUT_DEBUG = $(outbase).debug
289TOOL_GCC64_LINK_DLL_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug
290TOOL_GCC64_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
291TOOL_GCC64_LINK_DLL_DEPORD =
292define TOOL_GCC64_LINK_DLL_CMDS
293 $(QUIET)$(TOOL_GCC64_LD) $(TOOL_GCC64_LDFLAGS.dll) $(flags) -o $(out)\
294 $(if $(filter-out win os2, $(KBUILD_TARGET)),$(call TOOL_GCC64_LD_SONAME,$(target),$(out)))\
295 $(objs)\
296 $(foreach p,$(libpath), -L$(p))\
297 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
298 $(call TOOL_GCC64_LD_MAP,$(outbase).map)
299 ifeq ($(ld_debug),split)
300 $(QUIET)$(TOOL_GCC64_OBJCOPY) --only-keep-debug $(out) $(outbase).debug
301 $(QUIET)$(CHMOD) a-x $(outbase).debug
302 $(QUIET)$(TOOL_GCC64_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out)
303 endif
304endef
305
306
307## Link system module (windows aka driver, linux aka kernel module)
308# @param $(target) Normalized main target name.
309# @param $(out) System module name.
310# @param $(objs) Object files to link together.
311# @param $(libs) Libraries to search.
312# @param $(libpath) Library search paths.
313# @param $(flags) Flags.
314# @param $(dirdep) Directory creation dependency.
315# @param $(deps) Other dependencies.
316# @param $(othersrc) Unhandled sources.
317# @param $(custom_pre) Custom step invoked before linking.
318# @param $(custom_post) Custom step invoked after linking.
319# @param $(outbase) Output basename (full). Use this for list files and such.
320TOOL_GCC64_LINK_SYSMOD_OUTPUT =
321TOOL_GCC64_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map
322TOOL_GCC64_LINK_SYSMOD_OUTPUT_DEBUG = $(outbase).debug
323TOOL_GCC64_LINK_SYSMOD_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug
324TOOL_GCC64_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
325TOOL_GCC64_LINK_SYSMOD_DEPORD =
326define TOOL_GCC64_LINK_SYSMOD_CMDS
327 $(QUIET)$(TOOL_GCC64_LD_SYSMOD) $(TOOL_GCC64_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
328 $(foreach p,$(libpath), -L$(p))\
329 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
330 $(call TOOL_GCC64_LD_SYSMOD_MAP,$(outbase).map)
331 ifeq ($(ld_debug),split)
332 $(QUIET)$(TOOL_GCC64_OBJCOPY) --only-keep-debug $(out) $(outbase).debug
333 $(QUIET)$(CHMOD) a-x $(outbase).debug
334 $(QUIET)$(TOOL_GCC64_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out)
335 endif
336endef
337
Note: See TracBrowser for help on using the repository browser.