source: trunk/kBuild/tools/GXX32.kmk@ 2535

Last change on this file since 2535 was 2534, checked in by bird, 14 years ago

tools/G*: split debug info - work in progress.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.4 KB
Line 
1# $Id: GXX32.kmk 2534 2011-08-02 14:13:06Z bird $
2## @file
3# kBuild Tool Config - Generic 32-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_GXX32 := Generic 32-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_GXX32_CC ?= gcc$(HOSTSUFF_EXE) -m32
39TOOL_GXX32_CXX ?= g++$(HOSTSUFF_EXE) -m32
40TOOL_GXX32_AS ?= gcc$(HOSTSUFF_EXE) -m32
41TOOL_GXX32_AR ?= ar$(HOSTSUFF_EXE)
42TOOL_GXX32_LD ?= g++$(HOSTSUFF_EXE) -m32
43TOOL_GXX32_LD_SYSMOD ?= ld$(HOSTSUFF_EXE)
44ifndef TOOL_GXX32_LDFLAGS.$(KBUILD_TARGET)
45TOOL_GXX32_LDFLAGS.dll ?= -shared
46else
47TOOL_GXX32_LDFLAGS.dll ?= $(TOOL_GXX32_LDFLAGS.$(KBUILD_TARGET))
48endif
49TOOL_GXX32_LDFLAGS.sysmod ?= -r -m elf_i386$(if-expr "$(KBUILD_TARGET)" == "freebsd",_fbsd,)
50TOOL_GXX32_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_GXX32_LD_MAP ?= -Zmap=$(1)
53else
54TOOL_GXX32_LD_MAP ?=
55endif
56ifeq ($(KBUILD_TARGET),os2)
57TOOL_GXX32_LD_SYSMOD_MAP ?= -Zmap=$(1)
58else
59TOOL_GXX32_LD_SYSMOD_MAP ?=
60endif
61if1of ($(KBUILD_HOST), solaris)
62 TOOL_GXX32_OBJCOPY ?= gobjcopy$(HOSTSUFF_EXE)
63else
64 TOOL_GXX32_OBJCOPY ?= objcopy$(HOSTSUFF_EXE)
65endif
66
67ifdef SLKRUNS
68 TOOL_GXX32_CC += -fmessage-length=0
69 TOOL_GXX32_CXX += -fmessage-length=0
70endif
71
72# General Properties used by kBuild
73TOOL_GXX32_COBJSUFF ?= .o
74TOOL_GXX32_CFLAGS ?=
75TOOL_GXX32_CFLAGS.debug ?= -g
76TOOL_GXX32_CFLAGS.profile ?= -O2 #-g -pg
77TOOL_GXX32_CFLAGS.release ?= -O2
78TOOL_GXX32_CINCS ?=
79TOOL_GXX32_CDEFS ?=
80
81TOOL_GXX32_CXXOBJSUFF ?= .o
82TOOL_GXX32_CXXOBJSUFF ?= .o
83TOOL_GXX32_CXXFLAGS ?=
84TOOL_GXX32_CXXFLAGS.debug ?= -g
85TOOL_GXX32_CXXFLAGS.profile ?= -O2 #-g -pg
86TOOL_GXX32_CXXFLAGS.release ?= -O2
87TOOL_GXX32_CXXINCS ?=
88TOOL_GXX32_CXXDEFS ?=
89
90TOOL_GXX32_ASFLAGS ?= -x assembler-with-cpp
91TOOL_GXX32_ASFLAGS.debug ?= -g
92TOOL_GXX32_ASFLAGS.profile ?= -g
93TOOL_GXX32_ASOBJSUFF ?= .o
94
95TOOL_GXX32_ARFLAGS ?= cr
96TOOL_GXX32_ARLIBSUFF ?= .a
97
98TOOL_GXX32_LDFLAGS ?=
99TOOL_GXX32_LDFLAGS.debug ?= -g
100TOOL_GXX32_LDFLAGS.profile ?= -g
101
102
103
104## Compile C source.
105# @param $(target) Normalized main target name.
106# @param $(source) Source filename (relative).
107# @param $(obj) Object file name. This shall be (re)created by the compilation.
108# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
109# @param $(flags) Flags.
110# @param $(defs) Definitions. No -D or something.
111# @param $(incs) Includes. No -I or something.
112# @param $(dirdep) Directory creation dependency.
113# @param $(deps) Other dependencies.
114#
115# @param $(outbase) Output basename (full). Use this for list files and such.
116# @param $(objsuff) Object suffix.
117TOOL_GXX32_COMPILE_C_DEPEND =
118TOOL_GXX32_COMPILE_C_DEPORD =
119ifdef KBUILD_USE_KOBJCACHE
120TOOL_GXX32_COMPILE_C_USES_KOBJCACHE = 1
121TOOL_GXX32_COMPILE_C_OUTPUT = $(outbase).i
122define TOOL_GXX32_COMPILE_C_CMDS
123 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
124 --kObjCache-cpp $(outbase).i\
125 $(TOOL_GXX32_CC) -E -o -\
126 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
127 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
128 $(abspath $(source))\
129 --kObjCache-cc $(obj)\
130 $(TOOL_GXX32_CC) -c\
131 $(flags) -fpreprocessed -x c\
132 -o $(obj)\
133 -
134 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
135endef
136else # !KBUILD_USE_KOBJCACHE
137TOOL_GXX32_COMPILE_C_OUTPUT =
138define TOOL_GXX32_COMPILE_C_CMDS
139 $(QUIET)$(TOOL_GXX32_CC) -c\
140 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
141 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
142 -o $(obj)\
143 $(abspath $(source))
144 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
145endef
146endif # !KBUILD_USE_KOBJCACHE
147
148
149## Compile C++ source.
150# @param $(target) Normalized main target name.
151# @param $(source) Source filename (relative).
152# @param $(obj) Object file name. This shall be (re)created by the compilation.
153# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
154# @param $(flags) Flags.
155# @param $(defs) Definitions. No -D or something.
156# @param $(incs) Includes. No -I or something.
157# @param $(dirdep) Directory creation dependency.
158# @param $(deps) Other dependencies.
159# @param $(outbase) Output basename (full). Use this for list files and such.
160# @param $(objsuff) Object suffix.
161TOOL_GXX32_COMPILE_CXX_DEPEND =
162TOOL_GXX32_COMPILE_CXX_DEPORD =
163ifdef KBUILD_USE_KOBJCACHE
164TOOL_GXX32_COMPILE_CXX_USES_KOBJCACHE = 1
165TOOL_GXX32_COMPILE_CXX_OUTPUT = $(outbase).ii
166define TOOL_GXX32_COMPILE_CXX_CMDS
167 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
168 --kObjCache-cpp $(outbase).ii\
169 $(TOOL_GXX32_CXX) -E -o -\
170 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
171 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
172 $(abspath $(source))\
173 --kObjCache-cc $(obj)\
174 $(TOOL_GXX32_CXX) -c\
175 $(flags) -fpreprocessed -x c++\
176 -o $(obj)\
177 -
178 $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
179endef
180else # !KBUILD_USE_KOBJCACHE
181TOOL_GXX32_COMPILE_CXX_OUTPUT =
182define TOOL_GXX32_COMPILE_CXX_CMDS
183 $(QUIET)$(TOOL_GXX32_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_GXX32_COMPILE_AS_OUTPUT =
207TOOL_GXX32_COMPILE_AS_DEPEND =
208TOOL_GXX32_COMPILE_AS_DEPORD =
209define TOOL_GXX32_COMPILE_AS_CMDS
210 $(QUIET)$(TOOL_GXX32_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_GXX32_LINK_LIBRARY_OUTPUT = $(out).ar-script
229TOOL_GXX32_LINK_LIBRARY_DEPEND = $(othersrc)
230TOOL_GXX32_LINK_LIBRARY_DEPORD =
231define TOOL_GXX32_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,$(othersrc), 'ADDLIB $(o)')
236 $(QUIET)$(APPEND) $(out).ar-script 'SAVE'
237 $(QUIET)$(APPEND) $(out).ar-script 'END'
238 $(QUIET)$(REDIRECT) -rti $(out).ar-script -- $(TOOL_GXX32_AR) -M
239endef
240
241
242## Link program
243# @param $(target) Normalized main target name.
244# @param $(out) Program name.
245# @param $(objs) Object files to link together.
246# @param $(libs) Libraries to search.
247# @param $(libpath) Library search paths.
248# @param $(flags) Flags.
249# @param $(dirdep) Directory creation dependency.
250# @param $(deps) Other dependencies.
251# @param $(othersrc) Unhandled sources.
252# @param $(custom_pre) Custom step invoked before linking.
253# @param $(custom_post) Custom step invoked after linking.
254# @param $(outbase) Output basename (full). Use this for list files and such.
255TOOL_GXX32_LINK_PROGRAM_OUTPUT =
256TOOL_GXX32_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map
257TOOL_GXX32_LINK_PROGRAM_OUTPUT_DEBUG = $(outbase).debug
258TOOL_GXX32_LINK_PROGRAM_DEBUG_INSTALL_FN = $(2).debug=>$(basename $(3)).debug
259TOOL_GXX32_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
260TOOL_GXX32_LINK_PROGRAM_DEPORD =
261define TOOL_GXX32_LINK_PROGRAM_CMDS
262 $(QUIET)$(TOOL_GXX32_LD) $(flags) -o $(out) $(objs)\
263 $(foreach p,$(libpath), -L$(p))\
264 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
265 $(call TOOL_GXX32_LD_MAP,$(outbase).map)
266 ifeq ($(ld_debug),split)
267 $(TOOL_GXX32_OBJCOPY) --only-keep-debug $(out) $(outbase).debug
268 $(CHMOD) a-x $(outbase).debug
269 $(TOOL_GXX32_OBJCOPY) --strip-debug $(out)
270 $(TOOL_GXX32_OBJCOPY) --add-gnu-debuglink=$(outbase).debug $(out)
271 endif
272endef
273
274
275## Link DLL
276# @param $(target) Normalized main target name.
277# @param $(out) Program name.
278# @param $(objs) Object files to link together.
279# @param $(libs) Libraries to search.
280# @param $(libpath) Library search paths.
281# @param $(flags) Flags.
282# @param $(dirdep) Directory creation dependency.
283# @param $(deps) Other dependencies.
284# @param $(othersrc) Unhandled sources.
285# @param $(custom_pre) Custom step invoked before linking.
286# @param $(custom_post) Custom step invoked after linking.
287# @param $(outbase) Output basename (full). Use this for list files and such.
288TOOL_GXX32_LINK_DLL_OUTPUT =
289TOOL_GXX32_LINK_DLL_OUTPUT_MAYBE = $(outbase).map
290TOOL_GXX32_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
291TOOL_GXX32_LINK_DLL_DEPORD =
292define TOOL_GXX32_LINK_DLL_CMDS
293 $(QUIET)$(TOOL_GXX32_LD) $(TOOL_GXX32_LDFLAGS.dll) $(flags) -o $(out)\
294 $(if $(filter-out win os2, $(KBUILD_TARGET)),$(call TOOL_GXX32_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_GXX32_LD_MAP,$(outbase).map)
299endef
300
301
302## Link system module (windows aka driver, linux aka kernel module)
303# @param $(target) Normalized main target name.
304# @param $(out) System module name.
305# @param $(objs) Object files to link together.
306# @param $(libs) Libraries to search.
307# @param $(libpath) Library search paths.
308# @param $(flags) Flags.
309# @param $(dirdep) Directory creation dependency.
310# @param $(deps) Other dependencies.
311# @param $(othersrc) Unhandled sources.
312# @param $(custom_pre) Custom step invoked before linking.
313# @param $(custom_post) Custom step invoked after linking.
314# @param $(outbase) Output basename (full). Use this for list files and such.
315TOOL_GXX32_LINK_SYSMOD_OUTPUT =
316TOOL_GXX32_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map
317TOOL_GXX32_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
318TOOL_GXX32_LINK_SYSMOD_DEPORD =
319define TOOL_GXX32_LINK_SYSMOD_CMDS
320 $(QUIET)$(TOOL_GXX32_LD_SYSMOD) $(TOOL_GXX32_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
321 $(foreach p,$(libpath), -L$(p))\
322 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
323 $(call TOOL_GXX32_LD_SYSMOD_MAP,$(outbase).map)
324endef
325
Note: See TracBrowser for help on using the repository browser.