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

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

Based on GCC3.kmk

File size: 9.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 := as$(HOSTSUFF_EXE)
49TOOL_GCC32_ASFLAGS := -m32
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 := -m elf_i386
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
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## Link library
134# @param $(target) Normalized main target name.
135# @param $(out) Library name.
136# @param $(objs) Object files to put in the library.
137# @param $(flags) Flags.
138# @param $(dirdep) Directory creation dependency.
139# @param $(deps) Other dependencies.
140# @param $(othersrc) Unhandled sources.
141# @param $(outbase) Output basename (full). Use this for list files and such.
142TOOL_GCC32_LINK_LIBRARY_OUTPUT = $(out).ar-script
143TOOL_GCC32_LINK_LIBRARY_DEPEND = $(filter %.a %.lib,$(othersrc))
144TOOL_GCC32_LINK_LIBRARY_DEPORD =
145define TOOL_GCC32_LINK_LIBRARY_CMDS
146 $(APPEND) $(out).ar-script "CREATE $(out)"
147 $(foreach o, $(objs)\
148 ,$(NL)$(TAB)$(APPEND) $(out).ar-script "ADDMOD $(o)")
149 $(foreach srclib, $(filter %.a %.lib,$(othersrc))\
150 ,$(NL)$(TAB)$(APPEND) $(out).ar-script "ADDLIB $(srclib)")
151 $(APPEND) $(out).ar-script "SAVE"
152 $(APPEND) $(out).ar-script "END"
153 $(TOOL_GCC32_AR) -M < $(out).ar-script
154endef
155
156
157## Link program
158# @param $(target) Normalized main target name.
159# @param $(out) Program name.
160# @param $(objs) Object files to link together.
161# @param $(libs) Libraries to search.
162# @param $(libpath) Library search paths.
163# @param $(flags) Flags.
164# @param $(dirdep) Directory creation dependency.
165# @param $(deps) Other dependencies.
166# @param $(othersrc) Unhandled sources.
167# @param $(custom_pre) Custom step invoked before linking.
168# @param $(custom_post) Custom step invoked after linking.
169# @param $(outbase) Output basename (full). Use this for list files and such.
170TOOL_GCC32_LINK_PROGRAM_OUTPUT = $(outbase).map
171TOOL_GCC32_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
172TOOL_GCC32_LINK_PROGRAM_DEPORD =
173define TOOL_GCC32_LINK_PROGRAM_CMDS
174 $(TOOL_GCC32_LD) $(flags) -o $(out) $(objs)\
175 $(foreach p,$(libpath), -L$(p))\
176 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
177 $(call TOOL_GCC32_LD_MAP,$(outbase).map)
178endef
179
180
181## Link DLL
182# @param $(target) Normalized main target name.
183# @param $(out) Program name.
184# @param $(objs) Object files to link together.
185# @param $(libs) Libraries to search.
186# @param $(libpath) Library search paths.
187# @param $(flags) Flags.
188# @param $(dirdep) Directory creation dependency.
189# @param $(deps) Other dependencies.
190# @param $(othersrc) Unhandled sources.
191# @param $(custom_pre) Custom step invoked before linking.
192# @param $(custom_post) Custom step invoked after linking.
193# @param $(outbase) Output basename (full). Use this for list files and such.
194TOOL_GCC32_LINK_DLL_OUTPUT = $(outbase).map
195TOOL_GCC32_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
196TOOL_GCC32_LINK_DLL_DEPORD =
197define TOOL_GCC32_LINK_DLL_CMDS
198 $(TOOL_GCC32_LD) $(TOOL_GCC32_LDFLAGS.dll) $(flags) -o $(out)\
199 $(if $(filter-out win32 os2, $(BUILD_TARGET)),$(call TOOL_GCC32_LD_SONAME,$(target),$(out)))\
200 $(objs)\
201 $(foreach p,$(libpath), -L$(p))\
202 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
203 $(call TOOL_GCC32_LD_MAP,$(outbase).map)
204endef
205
206
207## Link system module (windows aka driver, linux aka kernel module)
208# @param $(target) Normalized main target name.
209# @param $(out) System module name.
210# @param $(objs) Object files to link together.
211# @param $(libs) Libraries to search.
212# @param $(libpath) Library search paths.
213# @param $(flags) Flags.
214# @param $(dirdep) Directory creation dependency.
215# @param $(deps) Other dependencies.
216# @param $(othersrc) Unhandled sources.
217# @param $(custom_pre) Custom step invoked before linking.
218# @param $(custom_post) Custom step invoked after linking.
219# @param $(outbase) Output basename (full). Use this for list files and such.
220TOOL_GCC32_LINK_SYSMOD_OUTPUT = $(outbase).map
221TOOL_GCC32_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
222TOOL_GCC32_LINK_SYSMOD_DEPORD =
223define TOOL_GCC32_LINK_SYSMOD_CMDS
224 $(TOOL_GCC32_LD_SYSMOD) $(TOOL_GCC32_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
225 $(foreach p,$(libpath), -L$(p))\
226 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
227 $(call TOOL_GCC32_LD_SYSMOD_MAP,$(outbase).map)
228endef
229
Note: See TracBrowser for help on using the repository browser.