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

Last change on this file since 1351 was 1349, checked in by bird, 18 years ago

Use $(REDIRECT) for the ar script.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 11.8 KB
Line 
1# $Id: GXX32.kmk 1349 2007-12-03 00:58:51Z bird $
2## @file
3#
4# kBuild Tool Config - Generic 32-bit GCC v3.2.x or later using the system GCC, for building C++ code.
5#
6# Copyright (c) 2004-2007 knut st. osmundsen <bird-kBuild-spam@anduin.net>
7#
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
27TOOL_GXX32 := Generic 32-bit GCC v3.2.x or later using the system GCC, for building C++ code. \
28 More or less Linux/ELF specfic.
29
30# Tool Specific Properties
31TOOL_GXX32_CC ?= gcc$(HOSTSUFF_EXE) -m32
32TOOL_GXX32_CXX ?= g++$(HOSTSUFF_EXE) -m32
33TOOL_GXX32_AS ?= gcc$(HOSTSUFF_EXE) -m32
34TOOL_GXX32_AR ?= ar$(HOSTSUFF_EXE)
35TOOL_GXX32_LD ?= g++$(HOSTSUFF_EXE) -m32
36TOOL_GXX32_LD_SYSMOD ?= ld$(HOSTSUFF_EXE)
37ifndef TOOL_GXX32_LDFLAGS.$(BUILD_TARGET)
38TOOL_GXX32_LDFLAGS.dll ?= -shared
39else
40TOOL_GXX32_LDFLAGS.dll ?= $(TOOL_GXX32_LDFLAGS.$(BUILD_TARGET))
41endif
42TOOL_GXX32_LDFLAGS.sysmod ?= -r -m elf_i386
43TOOL_GXX32_LD_SONAME ?= -Wl,-soname=$(firstword $($(1)_SONAME.$(BUILD_TARGET).$(BUILD_TYPE)) $($(1)_SONAME.$(BUILD_TARGET)) $($(1)_SONAME.$(BUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
44ifeq ($(BUILD_TARGET),os2)
45TOOL_GXX32_LD_MAP ?= -Zmap=$(1)
46else
47TOOL_GXX32_LD_MAP ?= -Wl,-Map -Wl,$(1) -Wl,--cref
48endif
49ifeq ($(BUILD_TARGET),os2)
50TOOL_GXX32_LD_SYSMOD_MAP ?= -Zmap=$(1)
51else
52TOOL_GXX32_LD_SYSMOD_MAP ?= -Map $(1) --cref
53endif
54ifdef SLKRUNS
55TOOL_GXX32_CC += -fmessage-length=0
56TOOL_GXX32_CXX += -fmessage-length=0
57endif
58
59# General Properties used by kBuild
60TOOL_GXX32_COBJSUFF ?= .o
61TOOL_GXX32_CFLAGS ?=
62TOOL_GXX32_CFLAGS.debug ?= -g
63TOOL_GXX32_CFLAGS.profile ?= -O2 #-g -pg
64TOOL_GXX32_CFLAGS.release ?= -O2
65TOOL_GXX32_CINCS ?=
66TOOL_GXX32_CDEFS ?=
67
68TOOL_GXX32_CXXOBJSUFF ?= .o
69TOOL_GXX32_CXXOBJSUFF ?= .o
70TOOL_GXX32_CXXFLAGS ?=
71TOOL_GXX32_CXXFLAGS.debug ?= -g
72TOOL_GXX32_CXXFLAGS.profile ?= -O2 #-g -pg
73TOOL_GXX32_CXXFLAGS.release ?= -O2
74TOOL_GXX32_CXXINCS ?=
75TOOL_GXX32_CXXDEFS ?=
76
77TOOL_GXX32_ASFLAGS ?= -x assembler-with-cpp
78TOOL_GXX32_ASFLAGS.debug ?= -g
79TOOL_GXX32_ASFLAGS.profile ?= -g
80TOOL_GXX32_ASOBJSUFF ?= .o
81
82TOOL_GXX32_ARFLAGS ?= cr
83TOOL_GXX32_ARLIBSUFF ?= .a
84
85TOOL_GXX32_LDFLAGS ?=
86TOOL_GXX32_LDFLAGS.debug ?= -g
87TOOL_GXX32_LDFLAGS.profile ?= -g
88
89
90## Compile C source.
91# @param $(target) Normalized main target name.
92# @param $(source) Source filename (relative).
93# @param $(obj) Object file name. This shall be (re)created by the compilation.
94# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
95# @param $(flags) Flags.
96# @param $(defs) Definitions. No -D or something.
97# @param $(incs) Includes. No -I or something.
98# @param $(dirdep) Directory creation dependency.
99# @param $(deps) Other dependencies.
100#
101# @param $(outbase) Output basename (full). Use this for list files and such.
102# @param $(objsuff) Object suffix.
103TOOL_GXX32_COMPILE_C_DEPEND =
104TOOL_GXX32_COMPILE_C_DEPORD =
105ifdef USE_KOBJCACHE
106TOOL_GXX32_COMPILE_C_USES_KOBJCACHE = 1
107TOOL_GXX32_COMPILE_C_OUTPUT = $(outbase).i
108define TOOL_GXX32_COMPILE_C_CMDS
109 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
110 --kObjCache-cpp $(outbase).i\
111 $(TOOL_GXX32_CC) -E -o -\
112 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
113 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
114 $(abspath $(source))\
115 --kObjCache-cc $(obj)\
116 $(TOOL_GXX32_CC) -c\
117 $(flags) -fpreprocessed -x c\
118 -o $(obj)\
119 -
120endef
121else # !USE_KOBJCACHE
122TOOL_GXX32_COMPILE_C_OUTPUT =
123define TOOL_GXX32_COMPILE_C_CMDS
124 $(QUIET)$(TOOL_GXX32_CC) -c\
125 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
126 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
127 -o $(obj)\
128 $(abspath $(source))
129endef
130endif # !USE_KOBJCACHE
131
132
133## Compile C++ source.
134# @param $(target) Normalized main target name.
135# @param $(source) Source filename (relative).
136# @param $(obj) Object file name. This shall be (re)created by the compilation.
137# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
138# @param $(flags) Flags.
139# @param $(defs) Definitions. No -D or something.
140# @param $(incs) Includes. No -I or something.
141# @param $(dirdep) Directory creation dependency.
142# @param $(deps) Other dependencies.
143# @param $(outbase) Output basename (full). Use this for list files and such.
144# @param $(objsuff) Object suffix.
145TOOL_GXX32_COMPILE_CXX_DEPEND =
146TOOL_GXX32_COMPILE_CXX_DEPORD =
147ifdef USE_KOBJCACHE
148TOOL_GXX32_COMPILE_CXX_USES_KOBJCACHE = 1
149TOOL_GXX32_COMPILE_CXX_OUTPUT = $(outbase).ii
150define TOOL_GXX32_COMPILE_CXX_CMDS
151 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
152 --kObjCache-cpp $(outbase).ii\
153 $(TOOL_GXX32_CXX) -E -o -\
154 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
155 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
156 $(abspath $(source))\
157 --kObjCache-cc $(obj)\
158 $(TOOL_GXX32_CXX) -c\
159 $(flags) -fpreprocessed -x c++\
160 -o $(obj)\
161 -
162endef
163else # !USE_KOBJCACHE
164TOOL_GXX32_COMPILE_CXX_OUTPUT =
165define TOOL_GXX32_COMPILE_CXX_CMDS
166 $(QUIET)$(TOOL_GXX32_CXX) -c\
167 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
168 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
169 -o $(obj)\
170 $(abspath $(source))
171endef
172endif # !USE_KOBJCACHE
173
174
175## Compile Assembly source.
176# @param $(target) Normalized main target name.
177# @param $(source) Source filename (relative).
178# @param $(obj) Object file name. This shall be (re)created by the compilation.
179# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
180# @param $(flags) Flags.
181# @param $(defs) Definitions. No -D or something.
182# @param $(incs) Includes. No -I or something.
183# @param $(dirdep) Directory creation dependency.
184# @param $(deps) Other dependencies.
185# @param $(outbase) Output basename (full). Use this for list files and such.
186# @param $(objsuff) Object suffix.
187#
188TOOL_GXX32_COMPILE_AS_OUTPUT =
189TOOL_GXX32_COMPILE_AS_DEPEND =
190TOOL_GXX32_COMPILE_AS_DEPORD =
191define TOOL_GXX32_COMPILE_AS_CMDS
192 $(QUIET)$(TOOL_GXX32_AS) -c\
193 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
194 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
195 -o $(obj)\
196 $(abspath $(source))
197endef
198
199
200## Link library
201# @param $(target) Normalized main target name.
202# @param $(out) Library name.
203# @param $(objs) Object files to put in the library.
204# @param $(flags) Flags.
205# @param $(dirdep) Directory creation dependency.
206# @param $(deps) Other dependencies.
207# @param $(othersrc) Unhandled sources.
208# @param $(outbase) Output basename (full). Use this for list files and such.
209TOOL_GXX32_LINK_LIBRARY_OUTPUT = $(out).ar-script
210TOOL_GXX32_LINK_LIBRARY_DEPEND = $(othersrc)
211TOOL_GXX32_LINK_LIBRARY_DEPORD =
212ifeq ($(filter append-dash-n,$(KMK_FEATURES)),append-dash-n)
213define TOOL_GXX32_LINK_LIBRARY_CMDS
214 $(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)'
215 $(QUIET)$(APPEND) -n $(out).ar-script \
216 $(foreach o,$(objs), 'ADDMOD $(o)') \
217 $(foreach o,$(othersrc), 'ADDLIB $(o)')
218 $(QUIET)$(APPEND) $(out).ar-script 'SAVE'
219 $(QUIET)$(APPEND) $(out).ar-script 'END'
220ifdef KMK_USE_REDIRECT
221 $(QUIET)$(REDIRECT) -rti $(out).ar-script -- $(TOOL_GXX32_AR) -M
222else
223 $(QUIET)$(TOOL_GXX32_AR) -M < $(out).ar-script
224endif
225endef
226else
227define TOOL_GXX32_LINK_LIBRARY_CMDS
228 $(QUIET)$(APPEND) $(out).ar-script "CREATE $(out)"
229 $(foreach o, $(objs)\
230 ,$(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script "ADDMOD $(o)")
231 $(foreach srclib,$(othersrc)\
232 ,$(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script "ADDLIB $(srclib)")
233 $(QUIET)$(APPEND) $(out).ar-script "SAVE"
234 $(QUIET)$(APPEND) $(out).ar-script "END"
235 $(QUIET)$(REDIRECT) -rti $(out).ar-script -- $(TOOL_GXX32_AR) -M
236endef
237endif
238
239
240## Link program
241# @param $(target) Normalized main target name.
242# @param $(out) Program name.
243# @param $(objs) Object files to link together.
244# @param $(libs) Libraries to search.
245# @param $(libpath) Library search paths.
246# @param $(flags) Flags.
247# @param $(dirdep) Directory creation dependency.
248# @param $(deps) Other dependencies.
249# @param $(othersrc) Unhandled sources.
250# @param $(custom_pre) Custom step invoked before linking.
251# @param $(custom_post) Custom step invoked after linking.
252# @param $(outbase) Output basename (full). Use this for list files and such.
253TOOL_GXX32_LINK_PROGRAM_OUTPUT =
254TOOL_GXX32_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map
255TOOL_GXX32_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
256TOOL_GXX32_LINK_PROGRAM_DEPORD =
257define TOOL_GXX32_LINK_PROGRAM_CMDS
258 $(QUIET)$(TOOL_GXX32_LD) $(flags) -o $(out) $(objs)\
259 $(foreach p,$(libpath), -L$(p))\
260 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
261 $(call TOOL_GXX32_LD_MAP,$(outbase).map)
262endef
263
264
265## Link DLL
266# @param $(target) Normalized main target name.
267# @param $(out) Program name.
268# @param $(objs) Object files to link together.
269# @param $(libs) Libraries to search.
270# @param $(libpath) Library search paths.
271# @param $(flags) Flags.
272# @param $(dirdep) Directory creation dependency.
273# @param $(deps) Other dependencies.
274# @param $(othersrc) Unhandled sources.
275# @param $(custom_pre) Custom step invoked before linking.
276# @param $(custom_post) Custom step invoked after linking.
277# @param $(outbase) Output basename (full). Use this for list files and such.
278TOOL_GXX32_LINK_DLL_OUTPUT =
279TOOL_GXX32_LINK_DLL_OUTPUT_MAYBE = $(outbase).map
280TOOL_GXX32_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
281TOOL_GXX32_LINK_DLL_DEPORD =
282define TOOL_GXX32_LINK_DLL_CMDS
283 $(QUIET)$(TOOL_GXX32_LD) $(TOOL_GXX32_LDFLAGS.dll) $(flags) -o $(out)\
284 $(if $(filter-out win os2, $(BUILD_TARGET)),$(call TOOL_GXX32_LD_SONAME,$(target),$(out)))\
285 $(objs)\
286 $(foreach p,$(libpath), -L$(p))\
287 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
288 $(call TOOL_GXX32_LD_MAP,$(outbase).map)
289endef
290
291
292## Link system module (windows aka driver, linux aka kernel module)
293# @param $(target) Normalized main target name.
294# @param $(out) System module name.
295# @param $(objs) Object files to link together.
296# @param $(libs) Libraries to search.
297# @param $(libpath) Library search paths.
298# @param $(flags) Flags.
299# @param $(dirdep) Directory creation dependency.
300# @param $(deps) Other dependencies.
301# @param $(othersrc) Unhandled sources.
302# @param $(custom_pre) Custom step invoked before linking.
303# @param $(custom_post) Custom step invoked after linking.
304# @param $(outbase) Output basename (full). Use this for list files and such.
305TOOL_GXX32_LINK_SYSMOD_OUTPUT =
306TOOL_GXX32_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map
307TOOL_GXX32_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
308TOOL_GXX32_LINK_SYSMOD_DEPORD =
309define TOOL_GXX32_LINK_SYSMOD_CMDS
310 $(QUIET)$(TOOL_GXX32_LD_SYSMOD) $(TOOL_GXX32_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
311 $(foreach p,$(libpath), -L$(p))\
312 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
313 $(call TOOL_GXX32_LD_SYSMOD_MAP,$(outbase).map)
314endef
315
Note: See TracBrowser for help on using the repository browser.