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

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

ABSPATH -> abspath.

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