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