source: trunk/kBuild/tools/GCC32.kmk@ 524

Last change on this file since 524 was 471, checked in by bird, 19 years ago

assembler-with-cpp by default.

File size: 10.0 KB
Line 
1# $Id: GCC3.kmk 380 2005-12-18 13:52:47Z bird $
2## @file
3#
4# kBuild Tool Config - 32-bit GCC, elf.
5#
6# Copyright (c) 2004-2006 knut st. osmundsen <bird-srcspam@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_GCC32 := Generic GCC v3 32-bit
28
29TOOL_GCC32_CC := gcc32$(HOSTSUFF_EXE)
30TOOL_GCC32_COBJSUFF := .o
31TOOL_GCC32_CFLAGS := -g
32TOOL_GCC32_CFLAGS.debug := -O0
33TOOL_GCC32_CFLAGS.release := -O2
34TOOL_GCC32_CFLAGS.profile := -O2 #-pg
35TOOL_GCC32_CINCS :=
36TOOL_GCC32_CDEFS :=
37
38TOOL_GCC32_CXX := g++32$(HOSTSUFF_EXE)
39TOOL_GCC32_CXXOBJSUFF := .o
40TOOL_GCC32_CXXOBJSUFF := .o
41TOOL_GCC32_CXXFLAGS := -g
42TOOL_GCC32_CXXFLAGS.debug := -O0
43TOOL_GCC32_CXXFLAGS.release := -O2
44TOOL_GCC32_CXXFLAGS.profile := -O2 #-pg
45TOOL_GCC32_CXXINCS :=
46TOOL_GCC32_CXXDEFS :=
47
48TOOL_GCC32_AS := gcc32$(HOSTSUFF_EXE)
49TOOL_GCC32_ASFLAGS := -g -x assembler-with-cpp
50TOOL_GCC32_ASOBJSUFF := .o
51
52TOOL_GCC32_AR := ar$(HOSTSUFF_EXE)
53TOOL_GCC32_ARFLAGS := cr
54TOOL_GCC32_ARLIBSUFF := .a
55
56TOOL_GCC32_LD := g++32$(HOSTSUFF_EXE)
57TOOL_GCC32_LD_SYSMOD := ld$(HOSTSUFF_EXE)
58TOOL_GCC32_LDFLAGS :=
59TOOL_GCC32_LDFLAGS.debug := -g
60TOOL_GCC32_LDFLAGS.release := -s
61ifndef TOOL_GCC32_LDFLAGS.$(BUILD_TARGET)
62TOOL_GCC32_LDFLAGS.dll := -shared
63else
64TOOL_GCC32_LDFLAGS.dll := $(TOOL_GCC32_LDFLAGS.$(BUILD_TARGET))
65endif
66TOOL_GCC32_LDFLAGS.sysmod := -r -m elf_i386
67TOOL_GCC32_LD_SONAME = -Wl,-soname=$(firstword $($(1)_SONAME.$(BUILD_TARGET).$(BUILD_TYPE)) $($(1)_SONAME.$(BUILD_TARGET)) $($(1)_SONAME.$(BUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
68ifeq ($(BUILD_TARGET),os2)
69TOOL_GCC32_LD_MAP = -Zmap=$(1)
70else
71TOOL_GCC32_LD_MAP = -Wl,-Map -Wl,$(1) -Wl,--cref
72endif
73ifeq ($(BUILD_TARGET),os2)
74TOOL_GCC32_LD_SYSMOD_MAP = -Zmap=$(1)
75else
76TOOL_GCC32_LD_SYSMOD_MAP = -Map $(1) --cref
77endif
78ifdef SLKRUNS
79TOOL_GCC32_CC += -fmessage-length=0
80TOOL_GCC32_CXX += -fmessage-length=0
81endif
82
83
84## Compile C source.
85# @param $(target) Normalized main target name.
86# @param $(source) Source filename (relative).
87# @param $(obj) Object file name. This shall be (re)created by the compilation.
88# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
89# @param $(flags) Flags.
90# @param $(defs) Definitions. No -D or something.
91# @param $(incs) Includes. No -I or something.
92# @param $(dirdep) Directory creation dependency.
93# @param $(deps) Other dependencies.
94#
95# @param $(outbase) Output basename (full). Use this for list files and such.
96# @param $(objsuff) Object suffix.
97TOOL_GCC32_COMPILE_C_OUTPUT =
98TOOL_GCC32_COMPILE_C_DEPEND =
99TOOL_GCC32_COMPILE_C_DEPORD =
100define TOOL_GCC32_COMPILE_C_CMDS
101 $(TOOL_GCC32_CC) -c\
102 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
103 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
104 -o $(obj)\
105 $(call ABSPATH,$(source))
106endef
107
108
109## Compile C++ source.
110# @param $(target) Normalized main target name.
111# @param $(source) Source filename (relative).
112# @param $(obj) Object file name. This shall be (re)created by the compilation.
113# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
114# @param $(flags) Flags.
115# @param $(defs) Definitions. No -D or something.
116# @param $(incs) Includes. No -I or something.
117# @param $(dirdep) Directory creation dependency.
118# @param $(deps) Other dependencies.
119# @param $(outbase) Output basename (full). Use this for list files and such.
120# @param $(objsuff) Object suffix.
121TOOL_GCC32_COMPILE_CXX_OUTPUT =
122TOOL_GCC32_COMPILE_CXX_DEPEND =
123TOOL_GCC32_COMPILE_CXX_DEPORD =
124define TOOL_GCC32_COMPILE_CXX_CMDS
125 $(TOOL_GCC32_CXX) -c\
126 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
127 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
128 -o $(obj)\
129 $(call ABSPATH,$(source))
130endef
131
132
133## Compile Assembly 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.
145#
146TOOL_GCC32_COMPILE_AS_OUTPUT =
147TOOL_GCC32_COMPILE_AS_DEPEND =
148TOOL_GCC32_COMPILE_AS_DEPORD =
149define TOOL_GCC32_COMPILE_AS_CMDS
150 $(TOOL_GCC32_AS) -c\
151 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
152 -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
153 -o $(obj)\
154 $(call ABSPATH,$(source))
155endef
156
157
158## Link library
159# @param $(target) Normalized main target name.
160# @param $(out) Library name.
161# @param $(objs) Object files to put in the library.
162# @param $(flags) Flags.
163# @param $(dirdep) Directory creation dependency.
164# @param $(deps) Other dependencies.
165# @param $(othersrc) Unhandled sources.
166# @param $(outbase) Output basename (full). Use this for list files and such.
167TOOL_GCC32_LINK_LIBRARY_OUTPUT = $(out).ar-script
168TOOL_GCC32_LINK_LIBRARY_DEPEND = $(filter %.a %.lib,$(othersrc))
169TOOL_GCC32_LINK_LIBRARY_DEPORD =
170define TOOL_GCC32_LINK_LIBRARY_CMDS
171 $(APPEND) $(out).ar-script "CREATE $(out)"
172 $(foreach o, $(objs)\
173 ,$(NL)$(TAB)$(APPEND) $(out).ar-script "ADDMOD $(o)")
174 $(foreach srclib, $(filter %.a %.lib,$(othersrc))\
175 ,$(NL)$(TAB)$(APPEND) $(out).ar-script "ADDLIB $(srclib)")
176 $(APPEND) $(out).ar-script "SAVE"
177 $(APPEND) $(out).ar-script "END"
178 $(TOOL_GCC32_AR) -M < $(out).ar-script
179endef
180
181
182## Link program
183# @param $(target) Normalized main target name.
184# @param $(out) Program name.
185# @param $(objs) Object files to link together.
186# @param $(libs) Libraries to search.
187# @param $(libpath) Library search paths.
188# @param $(flags) Flags.
189# @param $(dirdep) Directory creation dependency.
190# @param $(deps) Other dependencies.
191# @param $(othersrc) Unhandled sources.
192# @param $(custom_pre) Custom step invoked before linking.
193# @param $(custom_post) Custom step invoked after linking.
194# @param $(outbase) Output basename (full). Use this for list files and such.
195TOOL_GCC32_LINK_PROGRAM_OUTPUT = $(outbase).map
196TOOL_GCC32_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
197TOOL_GCC32_LINK_PROGRAM_DEPORD =
198define TOOL_GCC32_LINK_PROGRAM_CMDS
199 $(TOOL_GCC32_LD) $(flags) -o $(out) $(objs)\
200 $(foreach p,$(libpath), -L$(p))\
201 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
202 $(call TOOL_GCC32_LD_MAP,$(outbase).map)
203endef
204
205
206## Link DLL
207# @param $(target) Normalized main target name.
208# @param $(out) Program name.
209# @param $(objs) Object files to link together.
210# @param $(libs) Libraries to search.
211# @param $(libpath) Library search paths.
212# @param $(flags) Flags.
213# @param $(dirdep) Directory creation dependency.
214# @param $(deps) Other dependencies.
215# @param $(othersrc) Unhandled sources.
216# @param $(custom_pre) Custom step invoked before linking.
217# @param $(custom_post) Custom step invoked after linking.
218# @param $(outbase) Output basename (full). Use this for list files and such.
219TOOL_GCC32_LINK_DLL_OUTPUT = $(outbase).map
220TOOL_GCC32_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
221TOOL_GCC32_LINK_DLL_DEPORD =
222define TOOL_GCC32_LINK_DLL_CMDS
223 $(TOOL_GCC32_LD) $(TOOL_GCC32_LDFLAGS.dll) $(flags) -o $(out)\
224 $(if $(filter-out win32 os2, $(BUILD_TARGET)),$(call TOOL_GCC32_LD_SONAME,$(target),$(out)))\
225 $(objs)\
226 $(foreach p,$(libpath), -L$(p))\
227 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
228 $(call TOOL_GCC32_LD_MAP,$(outbase).map)
229endef
230
231
232## Link system module (windows aka driver, linux aka kernel module)
233# @param $(target) Normalized main target name.
234# @param $(out) System module name.
235# @param $(objs) Object files to link together.
236# @param $(libs) Libraries to search.
237# @param $(libpath) Library search paths.
238# @param $(flags) Flags.
239# @param $(dirdep) Directory creation dependency.
240# @param $(deps) Other dependencies.
241# @param $(othersrc) Unhandled sources.
242# @param $(custom_pre) Custom step invoked before linking.
243# @param $(custom_post) Custom step invoked after linking.
244# @param $(outbase) Output basename (full). Use this for list files and such.
245TOOL_GCC32_LINK_SYSMOD_OUTPUT = $(outbase).map
246TOOL_GCC32_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
247TOOL_GCC32_LINK_SYSMOD_DEPORD =
248define TOOL_GCC32_LINK_SYSMOD_CMDS
249 $(TOOL_GCC32_LD_SYSMOD) $(TOOL_GCC32_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
250 $(foreach p,$(libpath), -L$(p))\
251 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
252 $(call TOOL_GCC32_LD_SYSMOD_MAP,$(outbase).map)
253endef
254
Note: See TracBrowser for help on using the repository browser.