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

Last change on this file since 1418 was 1418, checked in by bird, 17 years ago

USE_KOBJCACHE -> KBUILD_USE_KOBJCACHE.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 11.3 KB
Line 
1# $Id: GXX32.kmk 1418 2008-03-18 22:52:45Z 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 KBUILD_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 # !KBUILD_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 # !KBUILD_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 KBUILD_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 # !KBUILD_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 # !KBUILD_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 =
212define TOOL_GXX32_LINK_LIBRARY_CMDS
213 $(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)'
214 $(QUIET)$(APPEND) -n $(out).ar-script \
215 $(foreach o,$(objs), 'ADDMOD $(o)') \
216 $(foreach o,$(othersrc), 'ADDLIB $(o)')
217 $(QUIET)$(APPEND) $(out).ar-script 'SAVE'
218 $(QUIET)$(APPEND) $(out).ar-script 'END'
219 $(QUIET)$(REDIRECT) -rti $(out).ar-script -- $(TOOL_GXX32_AR) -M
220endef
221
222
223## Link program
224# @param $(target) Normalized main target name.
225# @param $(out) Program name.
226# @param $(objs) Object files to link together.
227# @param $(libs) Libraries to search.
228# @param $(libpath) Library search paths.
229# @param $(flags) Flags.
230# @param $(dirdep) Directory creation dependency.
231# @param $(deps) Other dependencies.
232# @param $(othersrc) Unhandled sources.
233# @param $(custom_pre) Custom step invoked before linking.
234# @param $(custom_post) Custom step invoked after linking.
235# @param $(outbase) Output basename (full). Use this for list files and such.
236TOOL_GXX32_LINK_PROGRAM_OUTPUT =
237TOOL_GXX32_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map
238TOOL_GXX32_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
239TOOL_GXX32_LINK_PROGRAM_DEPORD =
240define TOOL_GXX32_LINK_PROGRAM_CMDS
241 $(QUIET)$(TOOL_GXX32_LD) $(flags) -o $(out) $(objs)\
242 $(foreach p,$(libpath), -L$(p))\
243 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
244 $(call TOOL_GXX32_LD_MAP,$(outbase).map)
245endef
246
247
248## Link DLL
249# @param $(target) Normalized main target name.
250# @param $(out) Program name.
251# @param $(objs) Object files to link together.
252# @param $(libs) Libraries to search.
253# @param $(libpath) Library search paths.
254# @param $(flags) Flags.
255# @param $(dirdep) Directory creation dependency.
256# @param $(deps) Other dependencies.
257# @param $(othersrc) Unhandled sources.
258# @param $(custom_pre) Custom step invoked before linking.
259# @param $(custom_post) Custom step invoked after linking.
260# @param $(outbase) Output basename (full). Use this for list files and such.
261TOOL_GXX32_LINK_DLL_OUTPUT =
262TOOL_GXX32_LINK_DLL_OUTPUT_MAYBE = $(outbase).map
263TOOL_GXX32_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
264TOOL_GXX32_LINK_DLL_DEPORD =
265define TOOL_GXX32_LINK_DLL_CMDS
266 $(QUIET)$(TOOL_GXX32_LD) $(TOOL_GXX32_LDFLAGS.dll) $(flags) -o $(out)\
267 $(if $(filter-out win os2, $(BUILD_TARGET)),$(call TOOL_GXX32_LD_SONAME,$(target),$(out)))\
268 $(objs)\
269 $(foreach p,$(libpath), -L$(p))\
270 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
271 $(call TOOL_GXX32_LD_MAP,$(outbase).map)
272endef
273
274
275## Link system module (windows aka driver, linux aka kernel module)
276# @param $(target) Normalized main target name.
277# @param $(out) System module 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_SYSMOD_OUTPUT =
289TOOL_GXX32_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map
290TOOL_GXX32_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
291TOOL_GXX32_LINK_SYSMOD_DEPORD =
292define TOOL_GXX32_LINK_SYSMOD_CMDS
293 $(QUIET)$(TOOL_GXX32_LD_SYSMOD) $(TOOL_GXX32_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
294 $(foreach p,$(libpath), -L$(p))\
295 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
296 $(call TOOL_GXX32_LD_SYSMOD_MAP,$(outbase).map)
297endef
298
Note: See TracBrowser for help on using the repository browser.