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

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

kBuild: svn attributes and some minor file header adjustments and corrections (still GPLv2 w/ big fat exception).

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