source: trunk/kBuild/tools/GCC32.kmk@ 3393

Last change on this file since 3393 was 3393, checked in by bird, 5 years ago

tools/*GCC|GXX*: More prefix/suffix stuff. Separate for gcc/g++, binutils and other stuff.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.0 KB
Line 
1# $Id: GCC32.kmk 3393 2020-06-30 17:11:42Z bird $
2## @file
3# kBuild Tool Config - Generic 32-bit GCC v3.2.x or later Using The System GCC.
4#
5
6#
7# Copyright (c) 2004-2017 knut st. osmundsen <bird-kBuild-spam-xviiv@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_GCC32 := Generic 32-bit GCC v3.2.x or later Using The System GCC. \
35 More or less Linux/ELF specfic.
36
37# Tool Specific Properties
38ifndef TOOL_GCC32_PREFIX
39 TOOL_GCC32_PREFIX :=
40endif
41ifndef TOOL_GCC32_SUFFIX
42 TOOL_GCC32_SUFFIX := $(HOSTSUFF_EXE)
43endif
44if1of ($(KBUILD_HOST), solaris)
45 TOOL_GCC32_PREFIX2 ?= g
46else
47 TOOL_GCC32_PREFIX2 ?=
48endif
49TOOL_GCC32_SUFFIX2 ?= $(HOSTSUFF_EXE)
50TOOL_GCC32_PREFIX3 ?=
51TOOL_GCC32_SUFFIX3 ?= $(HOSTSUFF_EXE)
52
53TOOL_GCC32_CC ?= $(TOOL_GCC32_PREFIX)gcc$(TOOL_GCC32_SUFFIX) -m32
54TOOL_GCC32_CXX ?= $(TOOL_GCC32_PREFIX)g++$(TOOL_GCC32_SUFFIX) -m32
55TOOL_GCC32_AS ?= $(TOOL_GCC32_PREFIX)gcc$(TOOL_GCC32_SUFFIX) -m32
56TOOL_GCC32_AR ?= $(TOOL_GCC32_PREFIX2)ar$(TOOL_GCC32_SUFFIX2)
57TOOL_GCC32_LD ?= $(TOOL_GCC32_PREFIX)gcc$(TOOL_GCC32_SUFFIX) -m32
58if1of ($(KBUILD_HOST), solaris)
59 TOOL_GCC32_LD_SYSMOD ?= $(TOOL_GCC32_PREFIX3)ld$(TOOL_GCC32_SUFFIX3)
60else
61 TOOL_GCC32_LD_SYSMOD ?= $(TOOL_GCC32_PREFIX2)ld$(TOOL_GCC32_SUFFIX2)
62endif
63ifndef TOOL_GCC32_LDFLAGS.$(KBUILD_TARGET)
64TOOL_GCC32_LDFLAGS.dll ?= -shared
65else
66TOOL_GCC32_LDFLAGS.dll ?= $(TOOL_GCC32_LDFLAGS.$(KBUILD_TARGET))
67endif
68TOOL_GCC32_LDFLAGS.sysmod ?= -r -m elf_i386$(if-expr "$(KBUILD_TARGET)" == "freebsd" || "$(KBUILD_TARGET)" == "gnukfbsd",_fbsd,)
69TOOL_GCC32_LD_SONAME ?= -Wl,-soname=$(firstword $($(1)_SONAME.$(KBUILD_TARGET).$(KBUILD_TYPE)) $($(1)_SONAME.$(KBUILD_TARGET)) $($(1)_SONAME.$(KBUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
70ifeq ($(KBUILD_TARGET),os2)
71TOOL_GCC32_LD_MAP ?= -Zmap=$(1)
72else
73TOOL_GCC32_LD_MAP ?=
74endif
75ifeq ($(KBUILD_TARGET),os2)
76TOOL_GCC32_LD_SYSMOD_MAP ?= -Zmap=$(1)
77else
78TOOL_GCC32_LD_SYSMOD_MAP ?=
79endif
80TOOL_GCC32_OBJCOPY ?= $(TOOL_GCC32_PREFIX2)objcopy$(TOOL_GCC32_SUFFIX2)
81
82ifdef SLKRUNS
83 TOOL_GCC32_CC += -fmessage-length=0
84 TOOL_GCC32_CXX += -fmessage-length=0
85endif
86
87# General Properties used by kBuild
88TOOL_GCC32_COBJSUFF ?= .o
89TOOL_GCC32_CFLAGS ?=
90TOOL_GCC32_CFLAGS.debug ?= -g
91TOOL_GCC32_CFLAGS.profile ?= -O2 #-g -pg
92TOOL_GCC32_CFLAGS.release ?= -O2
93TOOL_GCC32_CINCS ?=
94TOOL_GCC32_CDEFS ?=
95
96TOOL_GCC32_CXXOBJSUFF ?= .o
97TOOL_GCC32_CXXOBJSUFF ?= .o
98TOOL_GCC32_CXXFLAGS ?=
99TOOL_GCC32_CXXFLAGS.debug ?= -g
100TOOL_GCC32_CXXFLAGS.profile ?= -O2 #-g -pg
101TOOL_GCC32_CXXFLAGS.release ?= -O2
102TOOL_GCC32_CXXINCS ?=
103TOOL_GCC32_CXXDEFS ?=
104
105TOOL_GCC32_ASFLAGS ?= -x assembler-with-cpp
106TOOL_GCC32_ASFLAGS.debug ?= -g
107TOOL_GCC32_ASFLAGS.profile ?= -g
108TOOL_GCC32_ASOBJSUFF ?= .o
109
110TOOL_GCC32_ARFLAGS ?= cr
111TOOL_GCC32_ARLIBSUFF ?= .a
112
113TOOL_GCC32_LDFLAGS ?=
114TOOL_GCC32_LDFLAGS.debug ?= -g
115TOOL_GCC32_LDFLAGS.profile ?= -g
116
117
118## Compile C source.
119# @param $(target) Normalized main target name.
120# @param $(source) Source filename (relative).
121# @param $(obj) Object file name. This shall be (re)created by the compilation.
122# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
123# @param $(flags) Flags.
124# @param $(defs) Definitions. No -D or something.
125# @param $(incs) Includes. No -I or something.
126# @param $(dirdep) Directory creation dependency.
127# @param $(deps) Other dependencies.
128#
129# @param $(outbase) Output basename (full). Use this for list files and such.
130# @param $(objsuff) Object suffix.
131TOOL_GCC32_COMPILE_C_DEPEND =
132TOOL_GCC32_COMPILE_C_DEPORD =
133ifdef KBUILD_USE_KOBJCACHE
134TOOL_GCC32_COMPILE_C_USES_KOBJCACHE = 1
135TOOL_GCC32_COMPILE_C_OUTPUT = $(outbase).i
136define TOOL_GCC32_COMPILE_C_CMDS
137 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
138 --kObjCache-cpp $(outbase).i\
139 $(TOOL_GCC32_CC) -E -o -\
140 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
141 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
142 $(abspath $(source))\
143 --kObjCache-cc $(obj)\
144 $(TOOL_GCC32_CC) -c\
145 $(flags) -fpreprocessed -x c\
146 -o $(obj)\
147 -
148 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
149endef
150else # !KBUILD_USE_KOBJCACHE
151TOOL_GCC32_COMPILE_C_OUTPUT =
152define TOOL_GCC32_COMPILE_C_CMDS
153 $(QUIET)$(TOOL_GCC32_CC) -c\
154 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
155 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
156 -o $(obj)\
157 $(abspath $(source))
158 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
159endef
160endif # !KBUILD_USE_KOBJCACHE
161
162
163## Compile C++ source.
164# @param $(target) Normalized main target name.
165# @param $(source) Source filename (relative).
166# @param $(obj) Object file name. This shall be (re)created by the compilation.
167# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
168# @param $(flags) Flags.
169# @param $(defs) Definitions. No -D or something.
170# @param $(incs) Includes. No -I or something.
171# @param $(dirdep) Directory creation dependency.
172# @param $(deps) Other dependencies.
173# @param $(outbase) Output basename (full). Use this for list files and such.
174# @param $(objsuff) Object suffix.
175TOOL_GCC32_COMPILE_CXX_DEPEND =
176TOOL_GCC32_COMPILE_CXX_DEPORD =
177ifdef KBUILD_USE_KOBJCACHE
178TOOL_GCC32_COMPILE_CXX_USES_KOBJCACHE = 1
179TOOL_GCC32_COMPILE_CXX_OUTPUT = $(outbase).ii
180define TOOL_GCC32_COMPILE_CXX_CMDS
181 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
182 --kObjCache-cpp $(outbase).ii\
183 $(TOOL_GCC32_CXX) -E -o -\
184 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
185 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
186 $(abspath $(source))\
187 --kObjCache-cc $(obj)\
188 $(TOOL_GCC32_CXX) -c\
189 $(flags) -fpreprocessed -x c++\
190 -o $(obj)\
191 -
192 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
193endef
194else # !KBUILD_USE_KOBJCACHE
195
196TOOL_GCC32_COMPILE_CXX_OUTPUT =
197define TOOL_GCC32_COMPILE_CXX_CMDS
198 $(QUIET)$(TOOL_GCC32_CXX) -c\
199 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
200 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
201 -o $(obj)\
202 $(abspath $(source))
203 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
204endef
205endif # !KBUILD_USE_KOBJCACHE
206
207
208## Compile Assembly source.
209# @param $(target) Normalized main target name.
210# @param $(source) Source filename (relative).
211# @param $(obj) Object file name. This shall be (re)created by the compilation.
212# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
213# @param $(flags) Flags.
214# @param $(defs) Definitions. No -D or something.
215# @param $(incs) Includes. No -I or something.
216# @param $(dirdep) Directory creation dependency.
217# @param $(deps) Other dependencies.
218# @param $(outbase) Output basename (full). Use this for list files and such.
219# @param $(objsuff) Object suffix.
220#
221TOOL_GCC32_COMPILE_AS_OUTPUT =
222TOOL_GCC32_COMPILE_AS_DEPEND =
223TOOL_GCC32_COMPILE_AS_DEPORD =
224define TOOL_GCC32_COMPILE_AS_CMDS
225 $(QUIET)$(TOOL_GCC32_AS) -c\
226 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
227 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
228 -o $(obj)\
229 $(abspath $(source))
230 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
231endef
232
233
234## Link library
235# @param $(target) Normalized main target name.
236# @param $(out) Library name.
237# @param $(objs) Object files to put in the library.
238# @param $(flags) Flags.
239# @param $(dirdep) Directory creation dependency.
240# @param $(deps) Other dependencies.
241# @param $(othersrc) Unhandled sources.
242# @param $(outbase) Output basename (full). Use this for list files and such.
243TOOL_GCC32_LINK_LIBRARY_OUTPUT = $(out).ar-script
244TOOL_GCC32_LINK_LIBRARY_DEPEND = $(othersrc)
245TOOL_GCC32_LINK_LIBRARY_DEPORD =
246define TOOL_GCC32_LINK_LIBRARY_CMDS
247 $(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)'
248 $(QUIET)$(APPEND) -n $(out).ar-script \
249 $(foreach o,$(objs), 'ADDMOD $(o)') \
250 $(foreach o,$(filter-out %.def %.imp %.dll,$(othersrc)), 'ADDLIB $(o)')
251 $(if $(filter %.def %.imp %.dll,$(othersrc))\
252 ,$(TOOL_GCC32_AR_IMP) -o $(outbase).imp.a $(filter %.def %.imp %.dll,$(othersrc))\
253 $(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script 'ADDLIB $(outbase).imp.a')
254 $(QUIET)$(APPEND) $(out).ar-script 'SAVE'
255 $(QUIET)$(APPEND) $(out).ar-script 'END'
256 $(QUIET)$(REDIRECT) -rti $(out).ar-script -- $(TOOL_GCC32_AR) -M
257endef
258
259
260## Link program
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_GCC32_LINK_PROGRAM_OUTPUT =
274TOOL_GCC32_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map
275TOOL_GCC32_LINK_PROGRAM_OUTPUT_DEBUG = $(outbase).debug
276TOOL_GCC32_LINK_PROGRAM_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug
277TOOL_GCC32_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
278 $(filter %.def, $(othersrc))
279TOOL_GCC32_LINK_PROGRAM_DEPORD =
280define TOOL_GCC32_LINK_PROGRAM_CMDS
281 $(QUIET)$(TOOL_GCC32_LD) $(flags) -o $(out) $(objs)\
282 $(foreach p,$(libpath), -L$(p))\
283 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
284 $(call TOOL_GCC32_LD_MAP,$(outbase).map)
285 ifeq ($(ld_debug),split)
286 $(QUIET)$(TOOL_GCC32_OBJCOPY) --only-keep-debug $(out) $(outbase).debug
287 $(QUIET)$(CHMOD) a-x $(outbase).debug
288 $(QUIET)$(TOOL_GCC32_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out)
289 endif
290endef
291
292
293## Link DLL
294# @param $(target) Normalized main target name.
295# @param $(out) Program name.
296# @param $(objs) Object files to link together.
297# @param $(libs) Libraries to search.
298# @param $(libpath) Library search paths.
299# @param $(flags) Flags.
300# @param $(dirdep) Directory creation dependency.
301# @param $(deps) Other dependencies.
302# @param $(othersrc) Unhandled sources.
303# @param $(custom_pre) Custom step invoked before linking.
304# @param $(custom_post) Custom step invoked after linking.
305# @param $(outbase) Output basename (full). Use this for list files and such.
306TOOL_GCC32_LINK_DLL_OUTPUT =
307TOOL_GCC32_LINK_DLL_OUTPUT_MAYBE = $(outbase).map
308TOOL_GCC32_LINK_DLL_OUTPUT_DEBUG = $(outbase).debug
309TOOL_GCC32_LINK_DLL_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug
310TOOL_GCC32_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
311 $(filter %.def, $(othersrc))
312TOOL_GCC32_LINK_DLL_DEPORD =
313define TOOL_GCC32_LINK_DLL_CMDS
314 $(QUIET)$(TOOL_GCC32_LD) $(TOOL_GCC32_LDFLAGS.dll) $(flags) -o $(out)\
315 $(if $(filter-out win os2, $(KBUILD_TARGET)),$(call TOOL_GCC32_LD_SONAME,$(target),$(out)))\
316 $(objs)\
317 $(foreach p,$(libpath), -L$(p))\
318 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
319 $(call TOOL_GCC32_LD_MAP,$(outbase).map)
320 ifeq ($(ld_debug),split)
321 $(QUIET)$(TOOL_GCC32_OBJCOPY) --only-keep-debug $(out) $(outbase).debug
322 $(QUIET)$(CHMOD) a-x $(outbase).debug
323 $(QUIET)$(TOOL_GCC32_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out)
324 endif
325endef
326
327
328## Link system module (windows aka driver, linux aka kernel module)
329# @param $(target) Normalized main target name.
330# @param $(out) System module name.
331# @param $(objs) Object files to link together.
332# @param $(libs) Libraries to search.
333# @param $(libpath) Library search paths.
334# @param $(flags) Flags.
335# @param $(dirdep) Directory creation dependency.
336# @param $(deps) Other dependencies.
337# @param $(othersrc) Unhandled sources.
338# @param $(custom_pre) Custom step invoked before linking.
339# @param $(custom_post) Custom step invoked after linking.
340# @param $(outbase) Output basename (full). Use this for list files and such.
341TOOL_GCC32_LINK_SYSMOD_OUTPUT =
342TOOL_GCC32_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map
343TOOL_GCC32_LINK_SYSMOD_OUTPUT_DEBUG = $(outbase).debug
344TOOL_GCC32_LINK_SYSMOD_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug
345TOOL_GCC32_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
346 $(filter %.def, $(othersrc))
347TOOL_GCC32_LINK_SYSMOD_DEPORD =
348define TOOL_GCC32_LINK_SYSMOD_CMDS
349 $(QUIET)$(TOOL_GCC32_LD_SYSMOD) $(TOOL_GCC32_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
350 $(filter %.def, $(othersrc))\
351 $(foreach p,$(libpath), -L$(p))\
352 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
353 $(call TOOL_GCC32_LD_SYSMOD_MAP,$(outbase).map)
354 ifeq ($(ld_debug),split)
355 $(QUIET)$(TOOL_GCC32_OBJCOPY) --only-keep-debug $(out) $(outbase).debug
356 $(QUIET)$(CHMOD) a-x $(outbase).debug
357 $(QUIET)$(TOOL_GCC32_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out)
358 endif
359endef
360
Note: See TracBrowser for help on using the repository browser.