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

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

Cleaned up the -s and -g usage.

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