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

Last change on this file since 596 was 584, checked in by bird, 19 years ago

Cleaned up the -s and -g usage.

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