source: trunk/kBuild/tools/GCC3.kmk@ 1034

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

MAYBE output. removed some obsolete stuff.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 11.5 KB
Line 
1# $Id: GCC3.kmk 1034 2007-06-04 02:05:30Z bird $
2## @file
3#
4# kBuild Tool Config - Generic GCC v3.2.x or later Using The System GCC and Binutils.
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_GCC3 := Generic GCC v3.2.x or later Using The System GCC and Binutils.
28
29# Tool Specific Properties
30TOOL_GCC3_CC ?= gcc$(HOSTSUFF_EXE)
31TOOL_GCC3_CXX ?= g++$(HOSTSUFF_EXE)
32TOOL_GCC3_AS ?= gcc$(HOSTSUFF_EXE)
33ifeq ($(BUILD_TARGET),solaris) ## @todo drop the MRI script!
34 TOOL_GCC3_AR ?= gar$(HOSTSUFF_EXE)
35else
36 TOOL_GCC3_AR ?= ar$(HOSTSUFF_EXE)
37endif
38ifeq ($(BUILD_TARGET),os2)
39 TOOL_GCC3_AR_IMP ?= emximp$(HOSTSTUFF_EXE)
40else
41 TOOL_GCC3_AR_IMP ?= $(ECHO) not supported!
42endif
43TOOL_GCC3_LD ?= gcc$(HOSTSUFF_EXE)
44TOOL_GCC3_LD_SYSMOD ?= ld$(HOSTSUFF_EXE)
45ifndef TOOL_GCC3_LDFLAGS.$(BUILD_TARGET)
46 TOOL_GCC3_LDFLAGS.dll ?= -shared
47else
48 TOOL_GCC3_LDFLAGS.dll ?= $(TOOL_GCC3_LDFLAGS.$(BUILD_TARGET))
49endif
50TOOL_GCC3_LDFLAGS.sysmod ?= -r
51TOOL_GCC3_LD_SONAME ?= -Wl,-soname=$(firstword $($(1)_SONAME.$(BUILD_TARGET).$(BUILD_TYPE)) $($(1)_SONAME.$(BUILD_TARGET)) $($(1)_SONAME.$(BUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
52ifeq ($(BUILD_TARGET),os2)
53 TOOL_GCC3_LD_MAP ?= -Zmap=$(1)
54 TOOL_GCC3_LD_SYSMOD_MAP ?= -Zmap=$(1)
55endif
56ifdef SLKRUNS
57 TOOL_GCC3_CC += -fmessage-length=0
58 TOOL_GCC3_CXX += -fmessage-length=0
59endif
60
61# General Properties used by kBuild
62TOOL_GCC3_COBJSUFF ?= .o
63TOOL_GCC3_CFLAGS ?=
64TOOL_GCC3_CFLAGS.debug ?= -g
65TOOL_GCC3_CFLAGS.profile ?= -g -O2 #-pg
66TOOL_GCC3_CFLAGS.release ?= -O2
67TOOL_GCC3_CINCS ?=
68TOOL_GCC3_CDEFS ?=
69
70TOOL_GCC3_CXXOBJSUFF ?= .o
71TOOL_GCC3_CXXOBJSUFF ?= .o
72TOOL_GCC3_CXXFLAGS ?=
73TOOL_GCC3_CXXFLAGS.debug ?= -g
74TOOL_GCC3_CXXFLAGS.profile ?= -g -O2 #-pg
75TOOL_GCC3_CXXFLAGS.release ?= -O2
76TOOL_GCC3_CXXINCS ?=
77TOOL_GCC3_CXXDEFS ?=
78
79TOOL_GCC3_ASFLAGS ?= -x assembler-with-cpp
80TOOL_GCC3_ASFLAGS.debug ?= -g
81TOOL_GCC3_ASFLAGS.profile ?= -g
82TOOL_GCC3_ASOBJSUFF ?= .o
83
84TOOL_GCC3_ARFLAGS ?= cr
85TOOL_GCC3_ARLIBSUFF ?= .a
86
87TOOL_GCC3_LDFLAGS ?=
88TOOL_GCC3_LDFLAGS.debug ?= -g
89TOOL_GCC3_LDFLAGS.profile ?= -g
90
91
92## Compile C source.
93# @param $(target) Normalized main target name.
94# @param $(source) Source filename (relative).
95# @param $(obj) Object file name. This shall be (re)created by the compilation.
96# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
97# @param $(flags) Flags.
98# @param $(defs) Definitions. No -D or something.
99# @param $(incs) Includes. No -I or something.
100# @param $(dirdep) Directory creation dependency.
101# @param $(deps) Other dependencies.
102#
103# @param $(outbase) Output basename (full). Use this for list files and such.
104# @param $(objsuff) Object suffix.
105TOOL_GCC3_COMPILE_C_DEPEND =
106TOOL_GCC3_COMPILE_C_DEPORD =
107ifdef USE_KOBJCACHE
108TOOL_GCC3_COMPILE_C_USES_KOBJCACHE = 1
109TOOL_GCC3_COMPILE_C_OUTPUT = $(outbase).i
110define TOOL_GCC3_COMPILE_C_CMDS
111 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -r --kObjCache-cpp $(outbase).i \
112 $(TOOL_GCC3_CC) -E -o -\
113 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
114 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
115 $(abspath $(source)) \
116 --kObjCache-cc $(obj) \
117 $(TOOL_GCC3_CC) -c\
118 $(flags)\
119 -o $(obj)\
120 $(outbase).i
121endef
122else # !USE_KOBJCACHE
123TOOL_GCC3_COMPILE_C_OUTPUT =
124define TOOL_GCC3_COMPILE_C_CMDS
125 $(QUIET)$(TOOL_GCC3_CC) -c\
126 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
127 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
128 -o $(obj)\
129 $(abspath $(source))
130endef
131endif # !USE_KOBJCACHE
132
133
134## Compile C++ source.
135# @param $(target) Normalized main target name.
136# @param $(source) Source filename (relative).
137# @param $(obj) Object file name. This shall be (re)created by the compilation.
138# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
139# @param $(flags) Flags.
140# @param $(defs) Definitions. No -D or something.
141# @param $(incs) Includes. No -I or something.
142# @param $(dirdep) Directory creation dependency.
143# @param $(deps) Other dependencies.
144# @param $(outbase) Output basename (full). Use this for list files and such.
145# @param $(objsuff) Object suffix.
146TOOL_GCC3_COMPILE_CXX_DEPEND =
147TOOL_GCC3_COMPILE_CXX_DEPORD =
148ifdef USE_KOBJCACHE
149TOOL_GCC3_COMPILE_CXX_USES_KOBJCACHE = 1
150TOOL_GCC3_COMPILE_CXX_OUTPUT = $(outbase).ii
151define TOOL_GCC3_COMPILE_CXX_CMDS
152 $(QUIET)$(KOBJCACHE) -f $(outbase).koc -r --kObjCache-cpp $(outbase).ii \
153 $(TOOL_GCC3_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_GCC3_CXX) -c\
159 $(flags)\
160 -o $(obj)\
161 $(outbase).ii
162endef
163else # !USE_KOBJCACHE
164TOOL_GCC3_COMPILE_CXX_OUTPUT =
165define TOOL_GCC3_COMPILE_CXX_CMDS
166 $(QUIET)$(TOOL_GCC3_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_GCC3_COMPILE_AS_OUTPUT =
189TOOL_GCC3_COMPILE_AS_DEPEND =
190TOOL_GCC3_COMPILE_AS_DEPORD =
191define TOOL_GCC3_COMPILE_AS_CMDS
192 $(QUIET)$(TOOL_GCC3_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_GCC3_LINK_LIBRARY_OUTPUT = $(out).ar-script
210TOOL_GCC3_LINK_LIBRARY_OUTPUT_MAYBE = $(outbase).imp.a
211TOOL_GCC3_LINK_LIBRARY_DEPEND = $(othersrc)
212TOOL_GCC3_LINK_LIBRARY_DEPORD =
213define TOOL_GCC3_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,$(filter-out %.def %.imp,$(othersrc)), 'ADDLIB $(o)')
218 $(if $(filter %.def %.imp,$(othersrc))\
219 ,$(TOOL_GCC3_AR_IMP) -o $(outbase).imp.a $(filter %.def %.imp,$(othersrc))\
220 $(NL)$(TAB)$(QUIET)$(APPEND) $(out).ar-script 'ADDLIB $(outbase).imp.a')
221 $(QUIET)$(APPEND) $(out).ar-script 'SAVE'
222 $(QUIET)$(APPEND) $(out).ar-script 'END'
223 $(QUIET)$(TOOL_GCC3_AR) -M < $(out).ar-script
224endef
225
226
227## Link program
228# @param $(target) Normalized main target name.
229# @param $(out) Program name.
230# @param $(objs) Object files to link together.
231# @param $(libs) Libraries to search.
232# @param $(libpath) Library search paths.
233# @param $(flags) Flags.
234# @param $(dirdep) Directory creation dependency.
235# @param $(deps) Other dependencies.
236# @param $(othersrc) Unhandled sources.
237# @param $(custom_pre) Custom step invoked before linking.
238# @param $(custom_post) Custom step invoked after linking.
239# @param $(outbase) Output basename (full). Use this for list files and such.
240TOOL_GCC3_LINK_PROGRAM_OUTPUT =
241TOOL_GCC3_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map
242TOOL_GCC3_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
243 $(filter %.def, $(othersrc))
244TOOL_GCC3_LINK_PROGRAM_DEPORD =
245define TOOL_GCC3_LINK_PROGRAM_CMDS
246 $(QUIET)$(TOOL_GCC3_LD) $(flags) -o $(out) $(objs)\
247 $(filter %.def, $(othersrc))\
248 $(foreach p,$(libpath), -L$(p))\
249 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
250 $(call TOOL_GCC3_LD_MAP,$(outbase).map)
251endef
252
253
254## Link DLL
255# @param $(target) Normalized main target name.
256# @param $(out) Program name.
257# @param $(objs) Object files to link together.
258# @param $(libs) Libraries to search.
259# @param $(libpath) Library search paths.
260# @param $(flags) Flags.
261# @param $(dirdep) Directory creation dependency.
262# @param $(deps) Other dependencies.
263# @param $(othersrc) Unhandled sources.
264# @param $(custom_pre) Custom step invoked before linking.
265# @param $(custom_post) Custom step invoked after linking.
266# @param $(outbase) Output basename (full). Use this for list files and such.
267TOOL_GCC3_LINK_DLL_OUTPUT =
268TOOL_GCC3_LINK_DLL_OUTPUT_MAYBE = $(outbase).map
269TOOL_GCC3_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
270 $(filter %.def, $(othersrc))
271TOOL_GCC3_LINK_DLL_DEPORD =
272define TOOL_GCC3_LINK_DLL_CMDS
273 $(QUIET)$(TOOL_GCC3_LD) $(TOOL_GCC3_LDFLAGS.dll) $(flags) -o $(out)\
274 $(if $(filter-out win32 os2, $(BUILD_TARGET)),$(call TOOL_GCC3_LD_SONAME,$(target),$(out)))\
275 $(objs)\
276 $(filter %.def, $(othersrc))\
277 $(foreach p,$(libpath), -L$(p))\
278 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
279 $(call TOOL_GCC3_LD_MAP,$(outbase).map)
280endef
281
282
283## Link system module (windows aka driver, linux aka kernel module)
284# @param $(target) Normalized main target name.
285# @param $(out) System module name.
286# @param $(objs) Object files to link together.
287# @param $(libs) Libraries to search.
288# @param $(libpath) Library search paths.
289# @param $(flags) Flags.
290# @param $(dirdep) Directory creation dependency.
291# @param $(deps) Other dependencies.
292# @param $(othersrc) Unhandled sources.
293# @param $(custom_pre) Custom step invoked before linking.
294# @param $(custom_post) Custom step invoked after linking.
295# @param $(outbase) Output basename (full). Use this for list files and such.
296TOOL_GCC3_LINK_SYSMOD_OUTPUT =
297TOOL_GCC3_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map
298TOOL_GCC3_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
299 $(filter %.def, $(othersrc))
300TOOL_GCC3_LINK_SYSMOD_DEPORD =
301define TOOL_GCC3_LINK_SYSMOD_CMDS
302 $(QUIET)$(TOOL_GCC3_LD_SYSMOD) $(TOOL_GCC3_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
303 $(filter %.def, $(othersrc))\
304 $(foreach p,$(libpath), -L$(p))\
305 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
306 $(call TOOL_GCC3_LD_SYSMOD_MAP,$(outbase).map)
307endef
308
Note: See TracBrowser for help on using the repository browser.