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

Last change on this file since 2605 was 2541, checked in by bird, 14 years ago

tools/G*: debug splitting.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.4 KB
Line 
1# $Id: GCC32.kmk 2541 2011-08-03 09:51:30Z 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-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_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
38TOOL_GCC32_CC ?= gcc$(HOSTSUFF_EXE) -m32
39TOOL_GCC32_CXX ?= g++$(HOSTSUFF_EXE) -m32
40TOOL_GCC32_AS ?= gcc$(HOSTSUFF_EXE) -m32
41TOOL_GCC32_AR ?= ar$(HOSTSUFF_EXE)
42TOOL_GCC32_LD ?= gcc$(HOSTSUFF_EXE) -m32
43TOOL_GCC32_LD_SYSMOD ?= ld$(HOSTSUFF_EXE)
44ifndef TOOL_GCC32_LDFLAGS.$(KBUILD_TARGET)
45TOOL_GCC32_LDFLAGS.dll ?= -shared
46else
47TOOL_GCC32_LDFLAGS.dll ?= $(TOOL_GCC32_LDFLAGS.$(KBUILD_TARGET))
48endif
49TOOL_GCC32_LDFLAGS.sysmod ?= -r -m elf_i386$(if-expr "$(KBUILD_TARGET)" == "freebsd",_fbsd,)
50TOOL_GCC32_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_GCC32_LD_MAP ?= -Zmap=$(1)
53else
54TOOL_GCC32_LD_MAP ?=
55endif
56ifeq ($(KBUILD_TARGET),os2)
57TOOL_GCC32_LD_SYSMOD_MAP ?= -Zmap=$(1)
58else
59TOOL_GCC32_LD_SYSMOD_MAP ?=
60endif
61if1of ($(KBUILD_HOST), solaris)
62 TOOL_GCC32_OBJCOPY ?= gobjcopy$(HOSTSUFF_EXE)
63else
64 TOOL_GCC32_OBJCOPY ?= objcopy$(HOSTSUFF_EXE)
65endif
66
67ifdef SLKRUNS
68 TOOL_GCC32_CC += -fmessage-length=0
69 TOOL_GCC32_CXX += -fmessage-length=0
70endif
71
72# General Properties used by kBuild
73TOOL_GCC32_COBJSUFF ?= .o
74TOOL_GCC32_CFLAGS ?=
75TOOL_GCC32_CFLAGS.debug ?= -g
76TOOL_GCC32_CFLAGS.profile ?= -O2 #-g -pg
77TOOL_GCC32_CFLAGS.release ?= -O2
78TOOL_GCC32_CINCS ?=
79TOOL_GCC32_CDEFS ?=
80
81TOOL_GCC32_CXXOBJSUFF ?= .o
82TOOL_GCC32_CXXOBJSUFF ?= .o
83TOOL_GCC32_CXXFLAGS ?=
84TOOL_GCC32_CXXFLAGS.debug ?= -g
85TOOL_GCC32_CXXFLAGS.profile ?= -O2 #-g -pg
86TOOL_GCC32_CXXFLAGS.release ?= -O2
87TOOL_GCC32_CXXINCS ?=
88TOOL_GCC32_CXXDEFS ?=
89
90TOOL_GCC32_ASFLAGS ?= -x assembler-with-cpp
91TOOL_GCC32_ASFLAGS.debug ?= -g
92TOOL_GCC32_ASFLAGS.profile ?= -g
93TOOL_GCC32_ASOBJSUFF ?= .o
94
95TOOL_GCC32_ARFLAGS ?= cr
96TOOL_GCC32_ARLIBSUFF ?= .a
97
98TOOL_GCC32_LDFLAGS ?=
99TOOL_GCC32_LDFLAGS.debug ?= -g
100TOOL_GCC32_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_GCC32_COMPILE_C_DEPEND =
117TOOL_GCC32_COMPILE_C_DEPORD =
118ifdef KBUILD_USE_KOBJCACHE
119TOOL_GCC32_COMPILE_C_USES_KOBJCACHE = 1
120TOOL_GCC32_COMPILE_C_OUTPUT = $(outbase).i
121define TOOL_GCC32_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_GCC32_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_GCC32_CC) -c\
130 $(flags) -fpreprocessed -x c\
131 -o $(obj)\
132 -
133 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
134endef
135else # !KBUILD_USE_KOBJCACHE
136TOOL_GCC32_COMPILE_C_OUTPUT =
137define TOOL_GCC32_COMPILE_C_CMDS
138 $(QUIET)$(TOOL_GCC32_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_GCC32_COMPILE_CXX_DEPEND =
161TOOL_GCC32_COMPILE_CXX_DEPORD =
162ifdef KBUILD_USE_KOBJCACHE
163TOOL_GCC32_COMPILE_CXX_USES_KOBJCACHE = 1
164TOOL_GCC32_COMPILE_CXX_OUTPUT = $(outbase).ii
165define TOOL_GCC32_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_GCC32_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_GCC32_CXX) -c\
174 $(flags) -fpreprocessed -x c++\
175 -o $(obj)\
176 -
177 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
178endef
179else # !KBUILD_USE_KOBJCACHE
180
181TOOL_GCC32_COMPILE_CXX_OUTPUT =
182define TOOL_GCC32_COMPILE_CXX_CMDS
183 $(QUIET)$(TOOL_GCC32_CXX) -c\
184 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
185 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
186 -o $(obj)\
187 $(abspath $(source))
188 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
189endef
190endif # !KBUILD_USE_KOBJCACHE
191
192
193## Compile Assembly source.
194# @param $(target) Normalized main target name.
195# @param $(source) Source filename (relative).
196# @param $(obj) Object file name. This shall be (re)created by the compilation.
197# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
198# @param $(flags) Flags.
199# @param $(defs) Definitions. No -D or something.
200# @param $(incs) Includes. No -I or something.
201# @param $(dirdep) Directory creation dependency.
202# @param $(deps) Other dependencies.
203# @param $(outbase) Output basename (full). Use this for list files and such.
204# @param $(objsuff) Object suffix.
205#
206TOOL_GCC32_COMPILE_AS_OUTPUT =
207TOOL_GCC32_COMPILE_AS_DEPEND =
208TOOL_GCC32_COMPILE_AS_DEPORD =
209define TOOL_GCC32_COMPILE_AS_CMDS
210 $(QUIET)$(TOOL_GCC32_AS) -c\
211 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
212 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
213 -o $(obj)\
214 $(abspath $(source))
215 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
216endef
217
218
219## Link library
220# @param $(target) Normalized main target name.
221# @param $(out) Library name.
222# @param $(objs) Object files to put in the library.
223# @param $(flags) Flags.
224# @param $(dirdep) Directory creation dependency.
225# @param $(deps) Other dependencies.
226# @param $(othersrc) Unhandled sources.
227# @param $(outbase) Output basename (full). Use this for list files and such.
228TOOL_GCC32_LINK_LIBRARY_OUTPUT = $(out).ar-script
229TOOL_GCC32_LINK_LIBRARY_DEPEND = $(othersrc)
230TOOL_GCC32_LINK_LIBRARY_DEPORD =
231define TOOL_GCC32_LINK_LIBRARY_CMDS
232 $(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)'
233 $(QUIET)$(APPEND) -n $(out).ar-script \
234 $(foreach o,$(objs), 'ADDMOD $(o)') \
235 $(foreach o,$(filter-out %.def %.imp,$(othersrc)), 'ADDLIB $(o)')
236 $(if $(filter %.def %.imp,$(othersrc))\
237 ,$(TOOL_GCC32_AR_IMP) -o $(outbase).imp.a $(filter %.def %.imp,$(othersrc))\
238 $(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script 'ADDLIB $(outbase).imp.a')
239 $(QUIET)$(APPEND) $(out).ar-script 'SAVE'
240 $(QUIET)$(APPEND) $(out).ar-script 'END'
241 $(QUIET)$(REDIRECT) -rti $(out).ar-script -- $(TOOL_GCC32_AR) -M
242endef
243
244
245## Link program
246# @param $(target) Normalized main target name.
247# @param $(out) Program name.
248# @param $(objs) Object files to link together.
249# @param $(libs) Libraries to search.
250# @param $(libpath) Library search paths.
251# @param $(flags) Flags.
252# @param $(dirdep) Directory creation dependency.
253# @param $(deps) Other dependencies.
254# @param $(othersrc) Unhandled sources.
255# @param $(custom_pre) Custom step invoked before linking.
256# @param $(custom_post) Custom step invoked after linking.
257# @param $(outbase) Output basename (full). Use this for list files and such.
258TOOL_GCC32_LINK_PROGRAM_OUTPUT =
259TOOL_GCC32_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map
260TOOL_GCC32_LINK_PROGRAM_OUTPUT_DEBUG = $(outbase).debug
261TOOL_GCC32_LINK_PROGRAM_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug
262TOOL_GCC32_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
263 $(filter %.def, $(othersrc))
264TOOL_GCC32_LINK_PROGRAM_DEPORD =
265define TOOL_GCC32_LINK_PROGRAM_CMDS
266 $(QUIET)$(TOOL_GCC32_LD) $(flags) -o $(out) $(objs)\
267 $(foreach p,$(libpath), -L$(p))\
268 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
269 $(call TOOL_GCC32_LD_MAP,$(outbase).map)
270 ifeq ($(ld_debug),split)
271 $(TOOL_GCC32_OBJCOPY) --only-keep-debug $(out) $(outbase).debug
272 $(CHMOD) a-x $(outbase).debug
273 $(TOOL_GCC32_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out)
274 endif
275endef
276
277
278## Link DLL
279# @param $(target) Normalized main target name.
280# @param $(out) Program name.
281# @param $(objs) Object files to link together.
282# @param $(libs) Libraries to search.
283# @param $(libpath) Library search paths.
284# @param $(flags) Flags.
285# @param $(dirdep) Directory creation dependency.
286# @param $(deps) Other dependencies.
287# @param $(othersrc) Unhandled sources.
288# @param $(custom_pre) Custom step invoked before linking.
289# @param $(custom_post) Custom step invoked after linking.
290# @param $(outbase) Output basename (full). Use this for list files and such.
291TOOL_GCC32_LINK_DLL_OUTPUT =
292TOOL_GCC32_LINK_DLL_OUTPUT_MAYBE = $(outbase).map
293TOOL_GCC32_LINK_DLL_OUTPUT_DEBUG = $(outbase).debug
294TOOL_GCC32_LINK_DLL_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug
295TOOL_GCC32_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
296 $(filter %.def, $(othersrc))
297TOOL_GCC32_LINK_DLL_DEPORD =
298define TOOL_GCC32_LINK_DLL_CMDS
299 $(QUIET)$(TOOL_GCC32_LD) $(TOOL_GCC32_LDFLAGS.dll) $(flags) -o $(out)\
300 $(if $(filter-out win os2, $(KBUILD_TARGET)),$(call TOOL_GCC32_LD_SONAME,$(target),$(out)))\
301 $(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_GCC32_LD_MAP,$(outbase).map)
305 ifeq ($(ld_debug),split)
306 $(TOOL_GCC32_OBJCOPY) --only-keep-debug $(out) $(outbase).debug
307 $(CHMOD) a-x $(outbase).debug
308 $(TOOL_GCC32_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out)
309 endif
310endef
311
312
313## Link system module (windows aka driver, linux aka kernel module)
314# @param $(target) Normalized main target name.
315# @param $(out) System module name.
316# @param $(objs) Object files to link together.
317# @param $(libs) Libraries to search.
318# @param $(libpath) Library search paths.
319# @param $(flags) Flags.
320# @param $(dirdep) Directory creation dependency.
321# @param $(deps) Other dependencies.
322# @param $(othersrc) Unhandled sources.
323# @param $(custom_pre) Custom step invoked before linking.
324# @param $(custom_post) Custom step invoked after linking.
325# @param $(outbase) Output basename (full). Use this for list files and such.
326TOOL_GCC32_LINK_SYSMOD_OUTPUT =
327TOOL_GCC32_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map
328TOOL_GCC32_LINK_SYSMOD_OUTPUT_DEBUG = $(outbase).debug
329TOOL_GCC32_LINK_SYSMOD_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug
330TOOL_GCC32_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
331 $(filter %.def, $(othersrc))
332TOOL_GCC32_LINK_SYSMOD_DEPORD =
333define TOOL_GCC32_LINK_SYSMOD_CMDS
334 $(QUIET)$(TOOL_GCC32_LD_SYSMOD) $(TOOL_GCC32_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
335 $(filter %.def, $(othersrc))\
336 $(foreach p,$(libpath), -L$(p))\
337 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
338 $(call TOOL_GCC32_LD_SYSMOD_MAP,$(outbase).map)
339 ifeq ($(ld_debug),split)
340 $(TOOL_GCC32_OBJCOPY) --only-keep-debug $(out) $(outbase).debug
341 $(CHMOD) a-x $(outbase).debug
342 $(TOOL_GCC32_OBJCOPY) --strip-debug --strip-unneeded --add-gnu-debuglink=$(outbase).debug $(out)
343 endif
344endef
345
Note: See TracBrowser for help on using the repository browser.