source: trunk/kBuild/tools/GXX3PLAIN.kmk@ 1058

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

Updated to new cache code. Also dropped -g from the profile cflags and cxxflags to improve cache hits.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 10.8 KB
Line 
1# $Id: GXX3PLAIN.kmk 1058 2007-06-11 11:22:43Z bird $
2## @file
3#
4# kBuild Tool Config - Generic GCC v3.2.x or later using the system GCC, any Unix linker and Unix archiver to build 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_GXX3PLAIN := Generic GCC v3.2.x or later using the system GCC, any Unix linker and Unix archiver to build C++ code.
28
29# Tool Specific Properties
30TOOL_GXX3PLAIN_CC ?= gcc$(HOSTSUFF_EXE)
31TOOL_GXX3PLAIN_CXX ?= g++$(HOSTSUFF_EXE)
32TOOL_GXX3PLAIN_AS ?= gcc$(HOSTSUFF_EXE)
33TOOL_GXX3PLAIN_AR ?= ar$(HOSTSUFF_EXE)
34TOOL_GXX3PLAIN_RANLIB ?= ranlib$(HOSTSUFF_EXE)
35TOOL_GXX3PLAIN_LD ?= g++$(HOSTSUFF_EXE)
36TOOL_GXX3PLAIN_LDFLAGS.dll.os2 ?= -Zdll
37TOOL_GXX3PLAIN_LDFLAGS.dll.darwin ?= -dynamiclib
38ifndef TOOL_GXX3PLAIN_LDFLAGS.$(BUILD_TARGET)
39 TOOL_GXX3PLAIN_LDFLAGS.dll ?= -shared
40else
41 TOOL_GXX3PLAIN_LDFLAGS.dll ?= $(TOOL_GXX3PLAIN_LDFLAGS.$(BUILD_TARGET))
42endif
43TOOL_GXX3PLAIN_LD_SONAME.darwin ?= $(NO_SUCH_VARIABLE)
44TOOL_GXX3PLAIN_LD_SONAME.os2 ?= $(NO_SUCH_VARIABLE)
45TOOL_GXX3PLAIN_LD_SONAME.win ?= $(NO_SUCH_VARIABLE)
46ifndef TOOL_GXX3PLAIN_LD_SONAME.$(BUILD_TARGET)
47 TOOL_GXX3PLAIN_LD_SONAME ?= -Wl,-soname=$(firstword $($(1)_SONAME.$(BUILD_TARGET).$(BUILD_TYPE)) $($(1)_SONAME.$(BUILD_TARGET)) $($(1)_SONAME.$(BUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
48else
49 TOOL_GXX3PLAIN_LD_SONAME ?= $(TOOL_GXX3PLAIN_LD_SONAME.$(BUILD_TARGET))
50endif
51ifdef SLKRUNS
52 TOOL_GXX3PLAIN_CC += -fmessage-length=0
53 TOOL_GXX3PLAIN_CXX += -fmessage-length=0
54endif
55
56# General Properties used by kBuild
57TOOL_GXX3PLAIN_COBJSUFF ?= .o
58TOOL_GXX3PLAIN_CFLAGS ?=
59TOOL_GXX3PLAIN_CFLAGS.debug ?= -g
60TOOL_GXX3PLAIN_CFLAGS.profile ?= -O2 #-g -pg
61TOOL_GXX3PLAIN_CFLAGS.release ?= -O2
62TOOL_GXX3PLAIN_CINCS ?=
63TOOL_GXX3PLAIN_CDEFS ?=
64
65TOOL_GXX3PLAIN_CXXOBJSUFF ?= .o
66TOOL_GXX3PLAIN_CXXOBJSUFF ?= .o
67TOOL_GXX3PLAIN_CXXFLAGS ?=
68TOOL_GXX3PLAIN_CXXFLAGS.debug ?= -g
69TOOL_GXX3PLAIN_CXXFLAGS.profile ?= -O2 #-g -pg
70TOOL_GXX3PLAIN_CXXFLAGS.release ?= -O2
71TOOL_GXX3PLAIN_CXXINCS ?=
72TOOL_GXX3PLAIN_CXXDEFS ?=
73
74TOOL_GXX3PLAIN_ASFLAGS ?= -x assembler-with-cpp
75TOOL_GXX3PLAIN_ASFLAGS.debug ?= -g
76TOOL_GXX3PLAIN_ASFLAGS.profile ?= -g
77TOOL_GXX3PLAIN_ASOBJSUFF ?= .o
78
79TOOL_GXX3PLAIN_ARFLAGS ?= cr
80TOOL_GXX3PLAIN_ARLIBSUFF ?= .a
81
82TOOL_GXX3PLAIN_LDFLAGS ?=
83TOOL_GXX3PLAIN_LDFLAGS.debug ?= -g
84TOOL_GXX3PLAIN_LDFLAGS.profile ?= -g
85
86
87## Compile C source.
88# @param $(target) Normalized main target name.
89# @param $(source) Source filename (relative).
90# @param $(obj) Object file name. This shall be (re)created by the compilation.
91# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
92# @param $(flags) Flags.
93# @param $(defs) Definitions. No -D or something.
94# @param $(incs) Includes. No -I or something.
95# @param $(dirdep) Directory creation dependency.
96# @param $(deps) Other dependencies.
97#
98# @param $(outbase) Output basename (full). Use this for list files and such.
99# @param $(objsuff) Object suffix.
100TOOL_GXX3PLAIN_COMPILE_C_DEPEND =
101ifdef USE_KOBJCACHE
102TOOL_GXX3PLAIN_COMPILE_C_USES_KOBJCACHE = 1
103TOOL_GXX3PLAIN_COMPILE_C_OUTPUT = $(outbase).i
104define TOOL_GXX3PLAIN_COMPILE_C_CMDS
105 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
106 --kObjCache-cpp $(outbase).i\
107 $(TOOL_GXX3PLAIN_CC) -E -o -\
108 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
109 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
110 $(abspath $(source))\
111 --kObjCache-cc $(obj)\
112 $(TOOL_GXX3PLAIN_CC) -c\
113 $(flags) -fpreprocessed -x c\
114 -o $(obj)\
115 -
116endef
117else # !USE_KOBJCACHE
118TOOL_GXX3PLAIN_COMPILE_C_DEPORD =
119TOOL_GXX3PLAIN_COMPILE_C_OUTPUT =
120define TOOL_GXX3PLAIN_COMPILE_C_CMDS
121 $(QUIET)$(TOOL_GXX3PLAIN_CC) -c\
122 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
123 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
124 -o $(obj)\
125 $(abspath $(source))
126endef
127endif # !USE_KOBJCACHE
128
129
130## Compile C++ source.
131# @param $(target) Normalized main target name.
132# @param $(source) Source filename (relative).
133# @param $(obj) Object file name. This shall be (re)created by the compilation.
134# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
135# @param $(flags) Flags.
136# @param $(defs) Definitions. No -D or something.
137# @param $(incs) Includes. No -I or something.
138# @param $(dirdep) Directory creation dependency.
139# @param $(deps) Other dependencies.
140# @param $(outbase) Output basename (full). Use this for list files and such.
141# @param $(objsuff) Object suffix.
142TOOL_GXX3PLAIN_COMPILE_CXX_DEPEND =
143TOOL_GXX3PLAIN_COMPILE_CXX_DEPORD =
144ifdef USE_KOBJCACHE
145TOOL_GXX3PLAIN_COMPILE_CXX_USES_KOBJCACHE = 1
146TOOL_GXX3PLAIN_COMPILE_CXX_OUTPUT = $(outbase).ii
147define TOOL_GXX3PLAIN_COMPILE_CXX_CMDS
148 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
149 --kObjCache-cpp $(outbase).ii\
150 $(TOOL_GXX3PLAIN_CXX) -E -o -\
151 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
152 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
153 $(abspath $(source))\
154 --kObjCache-cc $(obj)\
155 $(TOOL_GXX3PLAIN_CXX) -c\
156 $(flags) -fpreprocessed -x c++\
157 -o $(obj)\
158 -
159endef
160else # !USE_KOBJCACHE
161TOOL_GXX3PLAIN_COMPILE_CXX_OUTPUT =
162define TOOL_GXX3PLAIN_COMPILE_CXX_CMDS
163 $(QUIET)$(TOOL_GXX3PLAIN_CXX) -c\
164 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
165 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
166 -o $(obj)\
167 $(abspath $(source))
168endef
169endif # !USE_KOBJCACHE
170
171
172## Compile Assembly source.
173# @param $(target) Normalized main target name.
174# @param $(source) Source filename (relative).
175# @param $(obj) Object file name. This shall be (re)created by the compilation.
176# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
177# @param $(flags) Flags.
178# @param $(defs) Definitions. No -D or something.
179# @param $(incs) Includes. No -I or something.
180# @param $(dirdep) Directory creation dependency.
181# @param $(deps) Other dependencies.
182# @param $(outbase) Output basename (full). Use this for list files and such.
183# @param $(objsuff) Object suffix.
184#
185TOOL_GXX3PLAIN_COMPILE_AS_OUTPUT =
186TOOL_GXX3PLAIN_COMPILE_AS_DEPEND =
187TOOL_GXX3PLAIN_COMPILE_AS_DEPORD =
188define TOOL_GXX3PLAIN_COMPILE_AS_CMDS
189 $(QUIET)$(TOOL_GXX3PLAIN_AS) -c\
190 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
191 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
192 -o $(obj)\
193 $(abspath $(source))
194endef
195
196
197## Link library
198# @param $(target) Normalized main target name.
199# @param $(out) Library name.
200# @param $(objs) Object files to put in the library.
201# @param $(flags) Flags.
202# @param $(dirdep) Directory creation dependency.
203# @param $(deps) Other dependencies.
204# @param $(othersrc) Unhandled sources.
205# @param $(outbase) Output basename (full). Use this for list files and such.
206TOOL_GXX3PLAIN_LINK_LIBRARY_OUTPUT = $(out).ar-script
207TOOL_GXX3PLAIN_LINK_LIBRARY_DEPEND = $(othersrc)
208TOOL_GXX3PLAIN_LINK_LIBRARY_DEPORD =
209define TOOL_GXX3PLAIN_LINK_LIBRARY_CMDS
210 $(call xargs,$(QUIET)$(TOOL_GXX3PLAIN_AR) $(flags) $(out),$(objs))
211 $(foreach lib,$(othersrc)\
212 ,$(NL)$(TAB)$(call MSG_AR_MERGE,$(target),$(out),$(lib)) \
213 $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))ar.tmp.dir/* \
214 $(NL)$(TAB)$(QUIET)$(MKDIR) -p $(dir $(outbase))/ar.tmp.dir/ \
215 $(NL)$(TAB)$(QUIET)(cd $(dir $(outbase))ar.tmp.dir/ \
216 && $(TOOL_GXX3PLAIN_AR) x $(abspath $(lib)) \
217 && $(TOOL_GXX3PLAIN_AR) $(flags) $(out) *) \
218 $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))/ar.tmp.dir/* \
219 $(NL)$(TAB)$(QUIET)$(RMDIR) $(dir $(outbase))ar.tmp.dir/)
220 $(QUIET)$(TOOL_GXX3PLAIN_RANLIB) $(out)
221endef
222
223
224## Link program
225# @param $(target) Normalized main target name.
226# @param $(out) Program name.
227# @param $(objs) Object files to link together.
228# @param $(libs) Libraries to search.
229# @param $(libpath) Library search paths.
230# @param $(flags) Flags.
231# @param $(dirdep) Directory creation dependency.
232# @param $(deps) Other dependencies.
233# @param $(othersrc) Unhandled sources.
234# @param $(custom_pre) Custom step invoked before linking.
235# @param $(custom_post) Custom step invoked after linking.
236# @param $(outbase) Output basename (full). Use this for list files and such.
237TOOL_GXX3PLAIN_LINK_PROGRAM_OUTPUT =
238TOOL_GXX3PLAIN_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map
239TOOL_GXX3PLAIN_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
240 $(filter %.def, $(othersrc))
241TOOL_GXX3PLAIN_LINK_PROGRAM_DEPORD =
242define TOOL_GXX3PLAIN_LINK_PROGRAM_CMDS
243 $(QUIET)$(TOOL_GXX3PLAIN_LD) $(flags) -o $(out) $(objs)\
244 $(filter %.def, $(othersrc))\
245 $(foreach p,$(libpath), -L$(p))\
246 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
247endef
248
249
250## Link DLL
251# @param $(target) Normalized main target name.
252# @param $(out) Program name.
253# @param $(objs) Object files to link together.
254# @param $(libs) Libraries to search.
255# @param $(libpath) Library search paths.
256# @param $(flags) Flags.
257# @param $(dirdep) Directory creation dependency.
258# @param $(deps) Other dependencies.
259# @param $(othersrc) Unhandled sources.
260# @param $(custom_pre) Custom step invoked before linking.
261# @param $(custom_post) Custom step invoked after linking.
262# @param $(outbase) Output basename (full). Use this for list files and such.
263TOOL_GXX3PLAIN_LINK_DLL_OUTPUT =
264TOOL_GXX3PLAIN_LINK_DLL_OUTPUT_MAYBE = $(outbase).map
265TOOL_GXX3PLAIN_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
266 $(filter %.def, $(othersrc))
267TOOL_GXX3PLAIN_LINK_DLL_DEPORD =
268define TOOL_GXX3PLAIN_LINK_DLL_CMDS
269 $(QUIET)$(TOOL_GXX3PLAIN_LD) $(TOOL_GXX3PLAIN_LDFLAGS.dll) $(flags) -o $(out)\
270 $(if $(filter-out win32 os2, $(BUILD_TARGET)),$(call TOOL_GXX3PLAIN_LD_SONAME,$(target),$(out)))\
271 $(objs)\
272 $(filter %.def, $(othersrc))\
273 $(foreach p,$(libpath), -L$(p))\
274 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
275endef
276
Note: See TracBrowser for help on using the repository browser.