1 | # $Id: GCC32.kmk 1063 2007-07-10 15:04:17Z 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-2007 knut st. osmundsen <bird-kBuild-spam@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_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
|
---|
31 | TOOL_GCC32_CC ?= gcc$(HOSTSUFF_EXE) -m32
|
---|
32 | TOOL_GCC32_CXX ?= g++$(HOSTSUFF_EXE) -m32
|
---|
33 | TOOL_GCC32_AS ?= gcc$(HOSTSUFF_EXE) -m32
|
---|
34 | TOOL_GCC32_AR ?= ar$(HOSTSUFF_EXE)
|
---|
35 | TOOL_GCC32_LD ?= gcc$(HOSTSUFF_EXE) -m32
|
---|
36 | TOOL_GCC32_LD_SYSMOD ?= ld$(HOSTSUFF_EXE)
|
---|
37 | ifndef TOOL_GCC32_LDFLAGS.$(BUILD_TARGET)
|
---|
38 | TOOL_GCC32_LDFLAGS.dll ?= -shared
|
---|
39 | else
|
---|
40 | TOOL_GCC32_LDFLAGS.dll ?= $(TOOL_GCC32_LDFLAGS.$(BUILD_TARGET))
|
---|
41 | endif
|
---|
42 | TOOL_GCC32_LDFLAGS.sysmod ?= -r -m elf_i386
|
---|
43 | TOOL_GCC32_LD_SONAME ?= -Wl,-soname=$(firstword $($(1)_SONAME.$(BUILD_TARGET).$(BUILD_TYPE)) $($(1)_SONAME.$(BUILD_TARGET)) $($(1)_SONAME.$(BUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
|
---|
44 | ifeq ($(BUILD_TARGET),os2)
|
---|
45 | TOOL_GCC32_LD_MAP ?= -Zmap=$(1)
|
---|
46 | else
|
---|
47 | TOOL_GCC32_LD_MAP ?= -Wl,-Map -Wl,$(1) -Wl,--cref
|
---|
48 | endif
|
---|
49 | ifeq ($(BUILD_TARGET),os2)
|
---|
50 | TOOL_GCC32_LD_SYSMOD_MAP ?= -Zmap=$(1)
|
---|
51 | else
|
---|
52 | TOOL_GCC32_LD_SYSMOD_MAP ?= -Map $(1) --cref
|
---|
53 | endif
|
---|
54 | ifdef SLKRUNS
|
---|
55 | TOOL_GCC32_CC += -fmessage-length=0
|
---|
56 | TOOL_GCC32_CXX += -fmessage-length=0
|
---|
57 | endif
|
---|
58 |
|
---|
59 | # General Properties used by kBuild
|
---|
60 | TOOL_GCC32_COBJSUFF ?= .o
|
---|
61 | TOOL_GCC32_CFLAGS ?=
|
---|
62 | TOOL_GCC32_CFLAGS.debug ?= -g
|
---|
63 | TOOL_GCC32_CFLAGS.profile ?= -O2 #-g -pg
|
---|
64 | TOOL_GCC32_CFLAGS.release ?= -O2
|
---|
65 | TOOL_GCC32_CINCS ?=
|
---|
66 | TOOL_GCC32_CDEFS ?=
|
---|
67 |
|
---|
68 | TOOL_GCC32_CXXOBJSUFF ?= .o
|
---|
69 | TOOL_GCC32_CXXOBJSUFF ?= .o
|
---|
70 | TOOL_GCC32_CXXFLAGS ?=
|
---|
71 | TOOL_GCC32_CXXFLAGS.debug ?= -g
|
---|
72 | TOOL_GCC32_CXXFLAGS.profile ?= -O2 #-g -pg
|
---|
73 | TOOL_GCC32_CXXFLAGS.release ?= -O2
|
---|
74 | TOOL_GCC32_CXXINCS ?=
|
---|
75 | TOOL_GCC32_CXXDEFS ?=
|
---|
76 |
|
---|
77 | TOOL_GCC32_ASFLAGS ?= -x assembler-with-cpp
|
---|
78 | TOOL_GCC32_ASFLAGS.debug ?= -g
|
---|
79 | TOOL_GCC32_ASFLAGS.profile ?= -g
|
---|
80 | TOOL_GCC32_ASOBJSUFF ?= .o
|
---|
81 |
|
---|
82 | TOOL_GCC32_ARFLAGS ?= cr
|
---|
83 | TOOL_GCC32_ARLIBSUFF ?= .a
|
---|
84 |
|
---|
85 | TOOL_GCC32_LDFLAGS ?=
|
---|
86 | TOOL_GCC32_LDFLAGS.debug ?= -g
|
---|
87 | TOOL_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.
|
---|
103 | TOOL_GCC32_COMPILE_C_DEPEND =
|
---|
104 | TOOL_GCC32_COMPILE_C_DEPORD =
|
---|
105 | ifdef USE_KOBJCACHE
|
---|
106 | TOOL_GCC32_COMPILE_C_USES_KOBJCACHE = 1
|
---|
107 | TOOL_GCC32_COMPILE_C_OUTPUT = $(outbase).i
|
---|
108 | define TOOL_GCC32_COMPILE_C_CMDS
|
---|
109 | $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
|
---|
110 | --kObjCache-cpp $(outbase).i\
|
---|
111 | $(TOOL_GCC32_CC) -E -o -\
|
---|
112 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
---|
113 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
---|
114 | $(abspath $(source))\
|
---|
115 | --kObjCache-cc $(obj)\
|
---|
116 | $(TOOL_GCC32_CC) -c\
|
---|
117 | $(flags) -fpreprocessed -x c\
|
---|
118 | -o $(obj)\
|
---|
119 | -
|
---|
120 | endef
|
---|
121 | else # !USE_KOBJCACHE
|
---|
122 | TOOL_GCC32_COMPILE_C_OUTPUT =
|
---|
123 | define TOOL_GCC32_COMPILE_C_CMDS
|
---|
124 | $(QUIET)$(TOOL_GCC32_CC) -c\
|
---|
125 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
---|
126 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
---|
127 | -o $(obj)\
|
---|
128 | $(abspath $(source))
|
---|
129 | endef
|
---|
130 | endif # !USE_KOBJCACHE
|
---|
131 |
|
---|
132 |
|
---|
133 | ## Compile C++ source.
|
---|
134 | # @param $(target) Normalized main target name.
|
---|
135 | # @param $(source) Source filename (relative).
|
---|
136 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
---|
137 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
---|
138 | # @param $(flags) Flags.
|
---|
139 | # @param $(defs) Definitions. No -D or something.
|
---|
140 | # @param $(incs) Includes. No -I or something.
|
---|
141 | # @param $(dirdep) Directory creation dependency.
|
---|
142 | # @param $(deps) Other dependencies.
|
---|
143 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
144 | # @param $(objsuff) Object suffix.
|
---|
145 | TOOL_GCC32_COMPILE_CXX_DEPEND =
|
---|
146 | TOOL_GCC32_COMPILE_CXX_DEPORD =
|
---|
147 | ifdef USE_KOBJCACHE
|
---|
148 | TOOL_GCC32_COMPILE_CXX_USES_KOBJCACHE = 1
|
---|
149 | TOOL_GCC32_COMPILE_CXX_OUTPUT = $(outbase).ii
|
---|
150 | define TOOL_GCC32_COMPILE_CXX_CMDS
|
---|
151 | $(QUIET)$(KOBJCACHE) -f $(outbase).koc -d $(PATH_OBJCACHE) -t $(bld_trg).$(bld_trg_arch) -p\
|
---|
152 | --kObjCache-cpp $(outbase).ii\
|
---|
153 | $(TOOL_GCC32_CXX) -E -o -\
|
---|
154 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
---|
155 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
---|
156 | $(abspath $(source))\
|
---|
157 | --kObjCache-cc $(obj)\
|
---|
158 | $(TOOL_GCC32_CXX) -c\
|
---|
159 | $(flags) -fpreprocessed -x c++\
|
---|
160 | -o $(obj)\
|
---|
161 | -
|
---|
162 | endef
|
---|
163 | else # !USE_KOBJCACHE
|
---|
164 |
|
---|
165 | TOOL_GCC32_COMPILE_CXX_OUTPUT =
|
---|
166 | define TOOL_GCC32_COMPILE_CXX_CMDS
|
---|
167 | $(QUIET)$(TOOL_GCC32_CXX) -c\
|
---|
168 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
---|
169 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
---|
170 | -o $(obj)\
|
---|
171 | $(abspath $(source))
|
---|
172 | endef
|
---|
173 | endif # !USE_KOBJCACHE
|
---|
174 |
|
---|
175 |
|
---|
176 | ## Compile Assembly source.
|
---|
177 | # @param $(target) Normalized main target name.
|
---|
178 | # @param $(source) Source filename (relative).
|
---|
179 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
---|
180 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
---|
181 | # @param $(flags) Flags.
|
---|
182 | # @param $(defs) Definitions. No -D or something.
|
---|
183 | # @param $(incs) Includes. No -I or something.
|
---|
184 | # @param $(dirdep) Directory creation dependency.
|
---|
185 | # @param $(deps) Other dependencies.
|
---|
186 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
187 | # @param $(objsuff) Object suffix.
|
---|
188 | #
|
---|
189 | TOOL_GCC32_COMPILE_AS_OUTPUT =
|
---|
190 | TOOL_GCC32_COMPILE_AS_DEPEND =
|
---|
191 | TOOL_GCC32_COMPILE_AS_DEPORD =
|
---|
192 | define TOOL_GCC32_COMPILE_AS_CMDS
|
---|
193 | $(QUIET)$(TOOL_GCC32_AS) -c\
|
---|
194 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
---|
195 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
---|
196 | -o $(obj)\
|
---|
197 | $(abspath $(source))
|
---|
198 | endef
|
---|
199 |
|
---|
200 |
|
---|
201 | ## Link library
|
---|
202 | # @param $(target) Normalized main target name.
|
---|
203 | # @param $(out) Library name.
|
---|
204 | # @param $(objs) Object files to put in the library.
|
---|
205 | # @param $(flags) Flags.
|
---|
206 | # @param $(dirdep) Directory creation dependency.
|
---|
207 | # @param $(deps) Other dependencies.
|
---|
208 | # @param $(othersrc) Unhandled sources.
|
---|
209 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
210 | TOOL_GCC32_LINK_LIBRARY_OUTPUT = $(out).ar-script
|
---|
211 | TOOL_GCC32_LINK_LIBRARY_DEPEND = $(othersrc)
|
---|
212 | TOOL_GCC32_LINK_LIBRARY_DEPORD =
|
---|
213 | define TOOL_GCC32_LINK_LIBRARY_CMDS
|
---|
214 | $(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)'
|
---|
215 | $(QUIET)$(APPEND) -n $(out).ar-script \
|
---|
216 | $(foreach o,$(objs), 'ADDMOD $(o)') \
|
---|
217 | $(foreach o,$(othersrc), 'ADDLIB $(o)')
|
---|
218 | $(QUIET)$(APPEND) $(out).ar-script 'SAVE'
|
---|
219 | $(QUIET)$(APPEND) $(out).ar-script 'END'
|
---|
220 | $(QUIET)$(TOOL_GCC32_AR) -M < $(out).ar-script
|
---|
221 | endef
|
---|
222 |
|
---|
223 |
|
---|
224 | ## Link program
|
---|
225 | # @param $(target) Normalized main target name.
|
---|
226 | # @param $(out) Program name.
|
---|
227 | # @param $(objs) Object files to link together.
|
---|
228 | # @param $(libs) Libraries to search.
|
---|
229 | # @param $(libpath) Library search paths.
|
---|
230 | # @param $(flags) Flags.
|
---|
231 | # @param $(dirdep) Directory creation dependency.
|
---|
232 | # @param $(deps) Other dependencies.
|
---|
233 | # @param $(othersrc) Unhandled sources.
|
---|
234 | # @param $(custom_pre) Custom step invoked before linking.
|
---|
235 | # @param $(custom_post) Custom step invoked after linking.
|
---|
236 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
237 | TOOL_GCC32_LINK_PROGRAM_OUTPUT =
|
---|
238 | TOOL_GCC32_LINK_PROGRAM_OUTPUT_MAYBE = $(outbase).map
|
---|
239 | TOOL_GCC32_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
|
---|
240 | TOOL_GCC32_LINK_PROGRAM_DEPORD =
|
---|
241 | define TOOL_GCC32_LINK_PROGRAM_CMDS
|
---|
242 | $(QUIET)$(TOOL_GCC32_LD) $(flags) -o $(out) $(objs)\
|
---|
243 | $(foreach p,$(libpath), -L$(p))\
|
---|
244 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
|
---|
245 | $(call TOOL_GCC32_LD_MAP,$(outbase).map)
|
---|
246 | endef
|
---|
247 |
|
---|
248 |
|
---|
249 | ## Link DLL
|
---|
250 | # @param $(target) Normalized main target name.
|
---|
251 | # @param $(out) Program name.
|
---|
252 | # @param $(objs) Object files to link together.
|
---|
253 | # @param $(libs) Libraries to search.
|
---|
254 | # @param $(libpath) Library search paths.
|
---|
255 | # @param $(flags) Flags.
|
---|
256 | # @param $(dirdep) Directory creation dependency.
|
---|
257 | # @param $(deps) Other dependencies.
|
---|
258 | # @param $(othersrc) Unhandled sources.
|
---|
259 | # @param $(custom_pre) Custom step invoked before linking.
|
---|
260 | # @param $(custom_post) Custom step invoked after linking.
|
---|
261 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
262 | TOOL_GCC32_LINK_DLL_OUTPUT =
|
---|
263 | TOOL_GCC32_LINK_DLL_OUTPUT_MAYBE = $(outbase).map
|
---|
264 | TOOL_GCC32_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
|
---|
265 | TOOL_GCC32_LINK_DLL_DEPORD =
|
---|
266 | define TOOL_GCC32_LINK_DLL_CMDS
|
---|
267 | $(QUIET)$(TOOL_GCC32_LD) $(TOOL_GCC32_LDFLAGS.dll) $(flags) -o $(out)\
|
---|
268 | $(if $(filter-out win os2, $(BUILD_TARGET)),$(call TOOL_GCC32_LD_SONAME,$(target),$(out)))\
|
---|
269 | $(objs)\
|
---|
270 | $(foreach p,$(libpath), -L$(p))\
|
---|
271 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
|
---|
272 | $(call TOOL_GCC32_LD_MAP,$(outbase).map)
|
---|
273 | endef
|
---|
274 |
|
---|
275 |
|
---|
276 | ## Link system module (windows aka driver, linux aka kernel module)
|
---|
277 | # @param $(target) Normalized main target name.
|
---|
278 | # @param $(out) System module name.
|
---|
279 | # @param $(objs) Object files to link together.
|
---|
280 | # @param $(libs) Libraries to search.
|
---|
281 | # @param $(libpath) Library search paths.
|
---|
282 | # @param $(flags) Flags.
|
---|
283 | # @param $(dirdep) Directory creation dependency.
|
---|
284 | # @param $(deps) Other dependencies.
|
---|
285 | # @param $(othersrc) Unhandled sources.
|
---|
286 | # @param $(custom_pre) Custom step invoked before linking.
|
---|
287 | # @param $(custom_post) Custom step invoked after linking.
|
---|
288 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
289 | TOOL_GCC32_LINK_SYSMOD_OUTPUT =
|
---|
290 | TOOL_GCC32_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map
|
---|
291 | TOOL_GCC32_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
|
---|
292 | TOOL_GCC32_LINK_SYSMOD_DEPORD =
|
---|
293 | define TOOL_GCC32_LINK_SYSMOD_CMDS
|
---|
294 | $(QUIET)$(TOOL_GCC32_LD_SYSMOD) $(TOOL_GCC32_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
|
---|
295 | $(foreach p,$(libpath), -L$(p))\
|
---|
296 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
|
---|
297 | $(call TOOL_GCC32_LD_SYSMOD_MAP,$(outbase).map)
|
---|
298 | endef
|
---|
299 |
|
---|