1 | # $Id: footer.kmk 460 2006-07-02 22:21:59Z bird $
|
---|
2 | ## @file
|
---|
3 | #
|
---|
4 | # kBuild - File included at top of makefile.
|
---|
5 | #
|
---|
6 | # Copyright (c) 2004-2005 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 source 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 | ifndef __footer_kmk__
|
---|
28 | # start-of-file-content
|
---|
29 |
|
---|
30 | #
|
---|
31 | # Variables.
|
---|
32 | # (Some of these need initialization before including definitions using them.)
|
---|
33 | #
|
---|
34 |
|
---|
35 | # all targets.
|
---|
36 | ALL_TARGETS += \
|
---|
37 | $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) \
|
---|
38 | $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) \
|
---|
39 | $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) \
|
---|
40 | $(DLLS) $(DLLS.$(BUILD_TARGET)) \
|
---|
41 | $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) \
|
---|
42 | $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) \
|
---|
43 | $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) \
|
---|
44 | $(OTHERS) $(OTHERS.$(BUILD_TARGET))
|
---|
45 |
|
---|
46 | # all $(BUILD_TARGET) targets.
|
---|
47 | _ALL_BUILD_TARGET_TARGETS += \
|
---|
48 | $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) \
|
---|
49 | $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) \
|
---|
50 | $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) \
|
---|
51 | $(DLLS) $(DLLS.$(BUILD_TARGET)) \
|
---|
52 | $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) \
|
---|
53 | $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) \
|
---|
54 | $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) \
|
---|
55 | $(OTHERS) $(OTHERS.$(BUILD_TARGET))
|
---|
56 |
|
---|
57 | # all $(BUILD_TARGET) targets.
|
---|
58 | _ALL_BUILD_PLATFORM_TARGETS += \
|
---|
59 | $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM))
|
---|
60 |
|
---|
61 | # dependency files.
|
---|
62 | _DEPFILES :=
|
---|
63 |
|
---|
64 | # included dependency files.
|
---|
65 | _DEPFILES_INCLUDED :=
|
---|
66 |
|
---|
67 |
|
---|
68 | # All kind of output files except for _OBJS and _DEPFILES.
|
---|
69 | # Compiling or linking definition outputting other things that $@ and any
|
---|
70 | # required dependency file must add those output files to this variable.
|
---|
71 | _OUT_FILES :=
|
---|
72 |
|
---|
73 | # Files which only requires cleaning up.
|
---|
74 | _CLEAN_FILES :=
|
---|
75 |
|
---|
76 | # all of a type
|
---|
77 | _OBJS :=
|
---|
78 | _BLDPROGS :=
|
---|
79 | _LIBS :=
|
---|
80 | _DLLS :=
|
---|
81 | _PROGRAMS :=
|
---|
82 | _SYSMODS :=
|
---|
83 | _INSTALLS :=
|
---|
84 | _INSTALLS_DIRS :=
|
---|
85 | _OTHERS :=
|
---|
86 | _PACKING :=
|
---|
87 | _DIRS := $(PATH_TARGET)/ $(PATH_TARGET)
|
---|
88 | _IMPORT_LIBS :=
|
---|
89 |
|
---|
90 | # misc
|
---|
91 | pass_prev :=
|
---|
92 |
|
---|
93 |
|
---|
94 | #
|
---|
95 | # Basic macros
|
---|
96 | #
|
---|
97 |
|
---|
98 | ## Figure out the tool for a source
|
---|
99 | # @param $target source file
|
---|
100 | # @param $source normalized main target
|
---|
101 | # @param $type tooltype
|
---|
102 | # @param bld_trg build target.
|
---|
103 | _SOURCE_TOOL = $(strip $(firstword \
|
---|
104 | $($(target)_$(source)_$(type)TOOL.$(bld_trg)) \
|
---|
105 | $($(target)_$(source)_$(type)TOOL) \
|
---|
106 | $($(target)_$(source)_TOOL.$(bld_trg)) \
|
---|
107 | $($(target)_$(source)_TOOL) \
|
---|
108 | $($(target)_$(type)TOOL.$(bld_trg)) \
|
---|
109 | $($(target)_$(type)TOOL) \
|
---|
110 | $($(target)_TOOL.$(bld_trg)) \
|
---|
111 | $($(target)_TOOL) \
|
---|
112 | $($(source)_$(type)TOOL.$(bld_trg)) \
|
---|
113 | $($(source)_$(type)TOOL) \
|
---|
114 | $($(source)_TOOL.$(bld_trg)) \
|
---|
115 | $($(source)_TOOL) \
|
---|
116 | $($(type)TOOL.$(bld_trg)) \
|
---|
117 | $($(type)TOOL) \
|
---|
118 | $(TOOL.$(bld_trg)) \
|
---|
119 | $(TOOL) ))
|
---|
120 |
|
---|
121 | ## Figure out the tool for a target.
|
---|
122 | # @param $target normalized target.
|
---|
123 | # @param $source tooltype.
|
---|
124 | # @param bld_trg build target.
|
---|
125 | _TARGET_TOOL = $(strip $(firstword \
|
---|
126 | $($(target)_$(source)TOOL.$(bld_trg)) \
|
---|
127 | $($(target)_$(source)TOOL) \
|
---|
128 | $($(target)_TOOL.$(bld_trg)) \
|
---|
129 | $($(target)_TOOL) \
|
---|
130 | $($(source)TOOL.$(bld_trg)) \
|
---|
131 | $($(source)TOOL) \
|
---|
132 | $(TOOL.$(bld_trg)) \
|
---|
133 | $(TOOL) \
|
---|
134 | ))
|
---|
135 |
|
---|
136 | ## Removes the drive letter from a path (if it has one)
|
---|
137 | # @param $1 the path
|
---|
138 | no-drive=$(word $(words $(subst :, ,$(1))),$(subst :, ,$(1)))
|
---|
139 |
|
---|
140 | ## Removes the root slash from a path (if it has one)
|
---|
141 | # @param $1 the path
|
---|
142 | no-root-slash=$(patsubst /%,%,$(1))
|
---|
143 |
|
---|
144 | ## Figure out where to put object files.
|
---|
145 | # @param $1 source file
|
---|
146 | # @param $2 normalized main target
|
---|
147 | # @remark There are two major hacks here:
|
---|
148 | # 1. Source files in the output directory are translated into a gen/ subdir.
|
---|
149 | # 2. Catch anyone specifying $(PATH_CURRENT)/sourcefile.c.
|
---|
150 | _OBJECT_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(basename \
|
---|
151 | $(patsubst $(PATH_ROOT)/%,%,$(patsubst $(PATH_CURRENT)/%,%,$(patsubst $(PATH_TARGET)/$(2)/%,gen/%,$(1)))))))
|
---|
152 |
|
---|
153 | ## Figure out where to put object files.
|
---|
154 | # @param $1 real target name.
|
---|
155 | # @param $2 normalized main target
|
---|
156 | _TARGET_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(basename $(1))))
|
---|
157 |
|
---|
158 |
|
---|
159 | ## Figure out the actual name of an installed file.
|
---|
160 | # @param $1 The file to install.
|
---|
161 | # @param $2 The target name.
|
---|
162 | # @param $3 The _INST value (can be empty).
|
---|
163 | # @param $4 The default directory to use when $3 is empty.
|
---|
164 | _INSTALL_FILE = $(patsubst %/,%/$(notdir $(1)),$(if $(3),$(PATH_INS)/$(3),$(4)/))
|
---|
165 |
|
---|
166 |
|
---|
167 | #
|
---|
168 | # Check syntax which leads to weird syntax errors.
|
---|
169 | #
|
---|
170 |
|
---|
171 | ## Check
|
---|
172 | # @param $(target) Target name.
|
---|
173 | define def_check_target
|
---|
174 | ifneq ("$($(target)_TEMPLATE)","$(strip $($(target)_TEMPLATE))")
|
---|
175 | $$(error $(target) have an incorrect template name. Remove any tabs!)
|
---|
176 | endif
|
---|
177 | endef
|
---|
178 | $(foreach target, $(ALL_TARGETS),$(eval $(def_check_target)))
|
---|
179 |
|
---|
180 |
|
---|
181 | #
|
---|
182 | # Include templates
|
---|
183 | #
|
---|
184 | _TEMPLATES := $(TEMPLATE)
|
---|
185 | define def_templates
|
---|
186 | ifdef $(target)_TEMPLATE
|
---|
187 | _TEMPLATES += $($(target)_TEMPLATE)
|
---|
188 | endif
|
---|
189 | endef
|
---|
190 | $(foreach target, $(ALL_TARGETS), $(eval $(def_templates)))
|
---|
191 | _TEMPLATES := $(sort $(_TEMPLATES))
|
---|
192 | # $ (warning dbg: _TEMPLATES=$(_TEMPLATES))
|
---|
193 |
|
---|
194 | define def_templates_include
|
---|
195 | ifndef TEMPLATE_$(template)
|
---|
196 | include $(firstword $(foreach path, $(TEMPLATE_PATHS) $(PATH_KBUILD)/templates/, $(wildcard $(path)/$(template).kmk)))
|
---|
197 | endif
|
---|
198 | endef
|
---|
199 | $(foreach template, $(_TEMPLATES), $(eval $(def_templates)))
|
---|
200 |
|
---|
201 |
|
---|
202 | #
|
---|
203 | # Template Inheritance.
|
---|
204 | #
|
---|
205 | define def_template_extends_prop
|
---|
206 | ifndef TEMPLATE_$(template)_$(prop)
|
---|
207 | ifdef TEMPLATE_$(parent)_$(prop)
|
---|
208 | TEMPLATE_$(template)_$(prop) = $$(TEMPLATE_$(parent)_$(prop))
|
---|
209 | endif
|
---|
210 | endif
|
---|
211 | endef
|
---|
212 |
|
---|
213 | define def_template_extends
|
---|
214 | ifdef TEMPLATE_$(template)_EXTENDS
|
---|
215 | parent := $(strip $(TEMPLATE_$(template)_EXTENDS))
|
---|
216 |
|
---|
217 | $(foreach prop, $(PROPS_SINGLE) $(PROPS_ACCUMULATE) $(PROPS_DEFERRED)\
|
---|
218 | $(addsuffix .$(BUILD_TARGET), $(PROPS_SINGLE) $(PROPS_ACCUMULATE) $(PROPS_DEFERRED))\
|
---|
219 | $(addsuffix .$(BUILD_TARGET_ARCH), $(PROPS_SINGLE) $(PROPS_ACCUMULATE) $(PROPS_DEFERRED))\
|
---|
220 | $(addsuffix .$(BUILD_TARGET_CPU), $(PROPS_SINGLE) $(PROPS_ACCUMULATE) $(PROPS_DEFERRED))\
|
---|
221 | $(addsuffix .$(BUILD_TYPE), $(PROPS_SINGLE) $(PROPS_ACCUMULATE) $(PROPS_DEFERRED))\
|
---|
222 | ,$(eval $(def_template_extends_prop))) # exploits the 2 evaluation, so no value!
|
---|
223 | endif
|
---|
224 | endef
|
---|
225 |
|
---|
226 | # $ (foreach template, $(_TEMPLATES), $(if TEMPLATE_$(template)_EXTENDS, $(eval $(value def_template_extends))))
|
---|
227 | $(foreach template, $(_TEMPLATES), $(eval $(value def_template_extends)))
|
---|
228 |
|
---|
229 |
|
---|
230 | #
|
---|
231 | # Common Inheritance
|
---|
232 | #
|
---|
233 |
|
---|
234 | ## Inherit one template property in a non-accumulative manner.
|
---|
235 | # @param $(prop) Property name
|
---|
236 | # @param $(target) Target name
|
---|
237 | # @todo fix the precedence order for some properties.
|
---|
238 | define def_inherit_template_one
|
---|
239 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
240 | ifndef $(target)_$(prop)
|
---|
241 | $(target)_$(prop) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
242 | #$ (warning dbgtarget: $(target)_$(prop):='$(value $(target)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
243 | endif
|
---|
244 | endif
|
---|
245 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
---|
246 | ifndef $(target)_$(prop).$(bld_trg)
|
---|
247 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
248 | $(target)_$(prop).$(bld_trg) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
249 | endif
|
---|
250 | endif
|
---|
251 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
---|
252 | ifndef $(target)_$(prop).$(bld_trg_arch)
|
---|
253 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg_arch)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
254 | $(target)_$(prop).$(bld_trg_arch) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
255 | endif
|
---|
256 | endif
|
---|
257 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
---|
258 | ifndef $(target)_$(prop).$(bld_trg_cpu)
|
---|
259 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg_cpu)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
260 | $(target)_$(prop).$(bld_trg_cpu) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
261 | endif
|
---|
262 | endif
|
---|
263 | endef
|
---|
264 |
|
---|
265 | ## Inherit one template property in a non-accumulative manner, deferred expansion.
|
---|
266 | # @param 1: $(prop) Property name
|
---|
267 | # @param 2: $(target) Target name
|
---|
268 | # @todo fix the precedence order for some properties.
|
---|
269 | # @remark this define relies on double evaluation
|
---|
270 | define def_inherit_template_one_deferred
|
---|
271 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
272 | ifndef $(target)_$(prop)
|
---|
273 | $(target)_$(prop) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
274 | #$ (warning dbgtarget: $(target)_$(prop):='$(value $(target)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
275 | endif
|
---|
276 | endif
|
---|
277 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
---|
278 | ifndef $(target)_$(prop).$(bld_trg)
|
---|
279 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
280 | $(target)_$(prop).$(bld_trg) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
281 | endif
|
---|
282 | endif
|
---|
283 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
---|
284 | ifndef $(target)_$(prop).$(bld_trg_arch)
|
---|
285 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg_arch)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
286 | $(target)_$(prop).$(bld_trg_arch) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
287 | endif
|
---|
288 | endif
|
---|
289 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
---|
290 | ifndef $(target)_$(prop).$(bld_trg_cpu)
|
---|
291 | #$ (warning dbgsource: $(target)_$(prop).$(bld_trg_cpu)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
292 | $(target)_$(prop).$(bld_trg_cpu) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
293 | endif
|
---|
294 | endif
|
---|
295 | endef
|
---|
296 |
|
---|
297 | ## Inherit one template property.
|
---|
298 | # @param $(prop) Property name
|
---|
299 | # @param $(target) Target name
|
---|
300 | define def_inherit_template_one_accumulate
|
---|
301 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
|
---|
302 | #$ (warning dbgtype: TEMPLATE_$($(target)_TEMPLATE)_$(prop) $(target)_$(prop)=$($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
|
---|
303 | $(target)_$(prop) += $(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
|
---|
304 | #$ (warning dbgtype: $(target)_$(prop)=$($(target)_$(prop)))
|
---|
305 | endif
|
---|
306 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)
|
---|
307 | #$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
|
---|
308 | $(target)_$(prop).$(BUILD_TYPE) += $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
|
---|
309 | endif
|
---|
310 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
|
---|
311 | #$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
312 | $(target)_$(prop).$(bld_trg) += $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
|
---|
313 | endif
|
---|
314 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
|
---|
315 | #$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
316 | $(target)_$(prop).$(bld_trg_cpu) += $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
|
---|
317 | endif
|
---|
318 | ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
|
---|
319 | #$ (warning dbg6: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
320 | $(target)_$(prop).$(bld_trg_arch) += $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
|
---|
321 | endif
|
---|
322 | endef
|
---|
323 |
|
---|
324 | ## Inherit template properties for on target.
|
---|
325 | # @param $(target) Target name.
|
---|
326 | define def_inherit_template
|
---|
327 | # Inherit any default template.
|
---|
328 | ifdef TEMPLATE
|
---|
329 | ifeq ($($(target)_TEMPLATE),)
|
---|
330 | $(eval $(target)_TEMPLATE:=$(TEMPLATE))
|
---|
331 | endif
|
---|
332 | endif
|
---|
333 | # Expand the template if specified.
|
---|
334 | ifneq ($($(target)_TEMPLATE),)
|
---|
335 | $(foreach prop,$(PROPS_SINGLE),$(eval $(value def_inherit_template_one)))
|
---|
336 | $(foreach prop,$(PROPS_DEFERRED),$(eval $(def_inherit_template_one_deferred))) # exploits the 2 evaluation, so no value!
|
---|
337 | $(foreach prop,$(PROPS_ACCUMULATE),$(eval $(def_inherit_template_one_accumulate))) # += works fine (better) without value.
|
---|
338 | endif
|
---|
339 | endef
|
---|
340 |
|
---|
341 | # Inherit template properties
|
---|
342 | bld_trg := $(BUILD_TARGET)
|
---|
343 | bld_trg_arch := $(BUILD_TARGET_ARCH)
|
---|
344 | bld_trg_cpu := $(BUILD_TARGET_CPU)
|
---|
345 | $(foreach target, $(_ALL_BUILD_TARGET_TARGETS),$(eval $(value def_inherit_template)))
|
---|
346 |
|
---|
347 | bld_trg := $(BUILD_PLATFORM)
|
---|
348 | bld_trg_arch := $(BUILD_PLATFORM_ARCH)
|
---|
349 | bld_trg_cpu := $(BUILD_PLATFORM_CPU)
|
---|
350 | $(foreach target, $(_ALL_BUILD_PLATFORM_TARGETS),$(eval $(value def_inherit_template)))
|
---|
351 |
|
---|
352 |
|
---|
353 | #
|
---|
354 | # Include tools & sdks
|
---|
355 | #
|
---|
356 | _TOOLS := $(TOOL.$(BUILD_TARGET)) $(TOOL.$(BUILD_TARGET_ARCH)) $(TOOL.$(BUILD_PLATFORM)) $(TOOL.$(BUILD_PLATFORM_ARCH)) $(TOOL)
|
---|
357 | _SDKS := $(SDKS.$(BUILD_TARGET)) $(SDKS.$(BUILD_TARGET_ARCH)) $(SDKS.$(BUILD_PLATFORM)) $(SDKS.$(BUILD_PLATFORM_ARCH)) $(SDKS)
|
---|
358 | define def_tools_sdks_target_source
|
---|
359 | $(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
|
---|
360 | $($(source)_$(prop).$(_bld_trg)) \
|
---|
361 | $($(target)_$(source)_$(prop).$(_bld_trg)) \
|
---|
362 | $($(source)_$(prop).$(_bld_trg_arch)) \
|
---|
363 | $($(target)_$(source)_$(prop).$(_bld_trg_arch)) \
|
---|
364 | $($(source)_$(prop)) \
|
---|
365 | $($(target)_$(source)_$(prop))))
|
---|
366 | $(eval _SDKS += \
|
---|
367 | $($(source)_SDKS.$(_bld_trg)) \
|
---|
368 | $($(target)_$(source)_SDKS.$(_bld_trg)) \
|
---|
369 | $($(source)_SDKS.$(_bld_trg_arch)) \
|
---|
370 | $($(target)_$(source)_SDKS.$(_bld_trg_arch)) \
|
---|
371 | $($(source)_SDKS) \
|
---|
372 | $($(target)_$(source)_SDKS))
|
---|
373 | endef
|
---|
374 |
|
---|
375 | define def_tools_sdks_target
|
---|
376 | _bld_trg := $(firstword $($(target)_BLD_TRG) $(bld_trg))
|
---|
377 | _bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(bld_trg_arch))
|
---|
378 | _bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(bld_trg_cpu))
|
---|
379 |
|
---|
380 | $(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
|
---|
381 | $($(target)_$(prop).$(_bld_trg)) \
|
---|
382 | $($(target)_$(prop).$(_bld_trg_arch)) \
|
---|
383 | $($(target)_$(prop))))
|
---|
384 | $(eval _SDKS += \
|
---|
385 | $($(target)_SDKS.$(_bld_trg)) \
|
---|
386 | $($(target)_SDKS.$(_bld_trg_arch)) \
|
---|
387 | $($(target)_SDKS))
|
---|
388 | $(foreach source, \
|
---|
389 | $($(target)_SOURCES.$(_bld_trg)) \
|
---|
390 | $($(target)_SOURCES.$(_bld_trg_arch)) \
|
---|
391 | $($(target)_SOURCES.$(_bld_trg_cpu)) \
|
---|
392 | $($(target)_SOURCES.$(BUILD_TYPE)) \
|
---|
393 | $($(target)_SOURCES) \
|
---|
394 | , $(eval $(value def_tools_sdks_target_source)))
|
---|
395 | endef
|
---|
396 |
|
---|
397 | bld_trg := $(BUILD_TARGET)
|
---|
398 | bld_trg_arch := $(BUILD_TARGET_ARCH)
|
---|
399 | bld_trg_cpu := $(BUILD_TARGET_CPU)
|
---|
400 | $(foreach target, $(_ALL_BUILD_TARGET_TARGETS), $(eval $(value def_tools_sdks_target)))
|
---|
401 |
|
---|
402 | bld_trg := $(BUILD_PLATFORM)
|
---|
403 | bld_trg_arch := $(BUILD_PLATFORM_ARCH)
|
---|
404 | bld_trg_cpu := $(BUILD_PLATFORM_CPU)
|
---|
405 | $(foreach target, $(_ALL_BUILD_PLATFORM_TARGETS), $(eval $(value def_tools_sdks_target)))
|
---|
406 |
|
---|
407 |
|
---|
408 | # include TOOLS
|
---|
409 | define def_tools_include
|
---|
410 | ifndef TOOL_$(tool)
|
---|
411 | TOOL_$(tool)_KMK_FILE := $(firstword $(foreach path, $(TOOL_PATHS) $(PATH_KBUILD)/tools, $(wildcard $(path)/$(tool).kmk)))
|
---|
412 | ifeq ($(TOOL_$(tool)_KMK_FILE),)
|
---|
413 | $(error kBuild: Cannot find include file for the tool '$(tool)'! Searched: $(TOOL_PATHS) $(PATH_KBUILD)/tools)
|
---|
414 | endif
|
---|
415 | include $(TOOL_$(tool)_KMK_FILE)
|
---|
416 | endif
|
---|
417 | endef
|
---|
418 |
|
---|
419 | _TOOLS := $(sort $(_TOOLS))
|
---|
420 | $(foreach tool, $(_TOOLS), $(eval $(value def_tools_include)))
|
---|
421 |
|
---|
422 |
|
---|
423 | # include SDKS
|
---|
424 | define def_sdks_include_one
|
---|
425 | ifndef SDK_$(sdk)
|
---|
426 | SDK_$(sdk)_KMK_FILE := $(firstword $(foreach path, $(SDK_PATHS) $(PATH_KBUILD)/sdks, $(wildcard $(path)/$(sdk).kmk)))
|
---|
427 | ifeq ($(SDK_$(sdk)_KMK_FILE),)
|
---|
428 | $(error kBuild: Cannot find include file for the SDK '$(sdk)'! Searched: $(SDK_PATHS) $(PATH_KBUILD)/sdks)
|
---|
429 | endif
|
---|
430 | include $(SDK_$(sdk)_KMK_FILE)
|
---|
431 | endif
|
---|
432 | endef
|
---|
433 |
|
---|
434 | _SDKS := $(sort $(_SDKS))
|
---|
435 | $(foreach sdk, $(_SDKS), $(eval $(value def_sdks_include_one)))
|
---|
436 |
|
---|
437 |
|
---|
438 | #
|
---|
439 | # Object processing.
|
---|
440 | #
|
---|
441 |
|
---|
442 | ## wrapper the compile command dependency check.
|
---|
443 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
444 | _DEP_COMPILE_CMDS = $(if $(subst $(strip $($(target)_$(source)_CMDS_PREV_)),,$(strip $($(target)_$(source)_CMDS_))),FORCE,)
|
---|
445 | else
|
---|
446 | _DEP_COMPILE_CMDS =
|
---|
447 | endif
|
---|
448 |
|
---|
449 | ## Generates the rules for building a specific object, and the '::' aliases
|
---|
450 | # for building a source file.
|
---|
451 | # @param $(obj) The object file.
|
---|
452 | define def_target_source_rule
|
---|
453 | $(obj) $($(target)_$(source)_OUTPUT_): \
|
---|
454 | $($(target)_$(source)_DEPEND_) \
|
---|
455 | $(_DEP_COMPILE_CMDS) \
|
---|
456 | | \
|
---|
457 | $($(target)_$(source)_DEPORD_)
|
---|
458 | $(call MSG_L1,Creating $$@)
|
---|
459 | $(RM) -f $(dep) $(out) $($(target)_$(source)_OUTPUT_)
|
---|
460 | $(custom_pre)
|
---|
461 |
|
---|
462 | $($(target)_$(source)_CMDS_)
|
---|
463 |
|
---|
464 | $(custom_post)
|
---|
465 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
466 | @$(APPEND) "$(dep)"
|
---|
467 | @$(APPEND) "$(dep)" 'define $(target)_$(source)_CMDS_PREV_'
|
---|
468 | @$(APPEND) "$(dep)" '$(subst $(NL),'$(NL)$(TAB)@$(APPEND) "$(dep)" ',$($(target)_$(source)_CMDS_))'
|
---|
469 | @$(APPEND) "$(dep)" 'endef'
|
---|
470 | endif
|
---|
471 |
|
---|
472 | $(basename $(notdir $(obj))).o::
|
---|
473 | + $$(MAKE) -f $$(MAKEFILE) $(obj)
|
---|
474 | $(basename $(notdir $(obj))).obj::
|
---|
475 | + $$(MAKE) -f $$(MAKEFILE) $(obj)
|
---|
476 | endef
|
---|
477 |
|
---|
478 |
|
---|
479 | ## wrapper the link command dependency check.
|
---|
480 | ifndef NO_COMPILE_CMDS_DEPS
|
---|
481 | _DEP_LINK_CMDS = $(if $(subst $(strip $($(target)_CMDS_PREV_)),,$(strip $($(target)_CMDS_))),FORCE,)
|
---|
482 | else
|
---|
483 | _DEP_LINK_CMDS =
|
---|
484 | endif
|
---|
485 |
|
---|
486 | ## Generate the link rule for a target.
|
---|
487 | # @param $(target) The normalized target name.
|
---|
488 | # @param $(dirdep) Directories we depend upon begin created before linking.
|
---|
489 | # @param $(dep) The name of the dependency file.
|
---|
490 | # @param $(out)
|
---|
491 | # @param $($(target)_OUTPUT_) Output files from the link.
|
---|
492 | # @param $($(target)_DEPEND_) Dependencies.
|
---|
493 | # @param $($(target)_DEPORD_) Dependencies which should only affect build order.
|
---|
494 | # @param $($(target)_CMDS_) The link commands.
|
---|
495 | # @param $($(target)_CMDS_PREV_) The link commands from the previous run.
|
---|
496 | define def_link_rule
|
---|
497 | $(out) $($(target)_OUTPUT_): \
|
---|
498 | $($(target)_DEPEND_) \
|
---|
499 | $(_DEP_LINK_CMDS) \
|
---|
500 | | \
|
---|
501 | $($(target)_DEPORD_)
|
---|
502 | $(call MSG_L1,Creating $$@)
|
---|
503 | $(RM) -f $(dep) $($(target)_OUTPUT_)
|
---|
504 | $(custom_pre)
|
---|
505 |
|
---|
506 | $($(target)_CMDS_)
|
---|
507 |
|
---|
508 | $(custom_post)
|
---|
509 | ifndef NO_LINK_CMDS_DEP
|
---|
510 | @$(APPEND) "$(dep)" 'define $(target)_CMDS_PREV_'
|
---|
511 | @$(APPEND) "$(dep)" '$(subst $(NL),'$(NL)$(TAB)@$(APPEND) "$(dep)" ',$($(target)_CMDS_))'
|
---|
512 | @$(APPEND) "$(dep)" 'endef'
|
---|
513 | endif
|
---|
514 |
|
---|
515 | $(basename $(notdir $(out)))::
|
---|
516 | + $$(MAKE) -f $$(MAKEFILE) $(out)
|
---|
517 | endef
|
---|
518 |
|
---|
519 |
|
---|
520 | ## Generate the link & lib install rule
|
---|
521 | # @param $(target) Normalized target name.
|
---|
522 | # @param $(out) The build target.
|
---|
523 | # @param $(INSTARGET_$(target)) The installation targets.
|
---|
524 | # @param $(mode) The file mode (optional)
|
---|
525 | define def_link_install_rule
|
---|
526 | $(INSTARGET_$(target)) : $(out) | $(call DIRDEP,$(dir $(INSTARGET_$(target))))
|
---|
527 | $(INSTALL) $$(if $(mode),-m $(mode)) $(out) $$@
|
---|
528 | endef
|
---|
529 |
|
---|
530 |
|
---|
531 |
|
---|
532 | ## Generic macro for processing C, C++ and Assembly sources.
|
---|
533 | # @param $(target) Normalized target name.
|
---|
534 | # @param $(source) Source file name.
|
---|
535 | # @param $(type) Source type. {C,CXX,AS}
|
---|
536 | # @param bld_type Build type.
|
---|
537 | # @param bld_trg Build target.
|
---|
538 | # @param bld_trg_arch Build target arch.
|
---|
539 | # @param bld_trg_cpu Build target cpu.
|
---|
540 | #
|
---|
541 | # @remark I've no clue why I've to $(eval ..) everything in this define. MAKE bug?
|
---|
542 | # @remark I now have a clue. Have to use $$ if not.
|
---|
543 | define def_target_source_c_cpp_asm
|
---|
544 | #$ (warning dbg: def_target_source_c_cpp_asm: source='$(source)' target='$(target)' type='$(type)')
|
---|
545 |
|
---|
546 | tool := $(call _SOURCE_TOOL,$(source),$(target),$(type))
|
---|
547 | outbase := $(call _OBJECT_BASE,$(source),$(target))
|
---|
548 | PATH_$(target)_$(source) := $(patsubst %/,%,$(dir $(outbase)))
|
---|
549 | dirdep := $(call DIRDEP,$(dir $(outbase)))
|
---|
550 | defs :=\
|
---|
551 | $(TOOL_$(tool)_DEFS)\
|
---|
552 | $(TOOL_$(tool)_DEFS.$(bld_type))\
|
---|
553 | $(TOOL_$(tool)_DEFS.$(bld_trg))\
|
---|
554 | $(TOOL_$(tool)_DEFS.$(bld_trg_arch))\
|
---|
555 | $(TOOL_$(tool)_DEFS.$(bld_trg_cpu))\
|
---|
556 | $(TOOL_$(tool)_$(type)DEFS)\
|
---|
557 | $(TOOL_$(tool)_$(type)DEFS.$(bld_type))\
|
---|
558 | $(foreach sdk, $(SDKS.$(bld_trg)) \
|
---|
559 | $(SDKS.$(bld_type)) \
|
---|
560 | $(SDKS),\
|
---|
561 | $(SDK_$(sdk)_DEFS)\
|
---|
562 | $(SDK_$(sdk)_DEFS.$(bld_type))\
|
---|
563 | $(SDK_$(sdk)_DEFS.$(bld_trg))\
|
---|
564 | $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
|
---|
565 | $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
|
---|
566 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
567 | $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
|
---|
568 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
|
---|
569 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
|
---|
570 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
|
---|
571 | $(DEFS)\
|
---|
572 | $(DEFS.$(bld_type))\
|
---|
573 | $(DEFS.$(bld_trg))\
|
---|
574 | $(DEFS.$(bld_trg_arch))\
|
---|
575 | $(DEFS.$(bld_trg_cpu))\
|
---|
576 | $($(type)DEFS)\
|
---|
577 | $($(type)DEFS.$(bld_type))\
|
---|
578 | $($(type)DEFS.$(bld_trg))\
|
---|
579 | $($(type)DEFS.$(bld_trg_arch))\
|
---|
580 | $($(type)DEFS.$(bld_trg_cpu))\
|
---|
581 | $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
|
---|
582 | $($(target)_SDKS.$(bld_type)) \
|
---|
583 | $($(target)_SDKS),\
|
---|
584 | $(SDK_$(sdk)_DEFS)\
|
---|
585 | $(SDK_$(sdk)_DEFS.$(bld_type))\
|
---|
586 | $(SDK_$(sdk)_DEFS.$(bld_trg))\
|
---|
587 | $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
|
---|
588 | $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
|
---|
589 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
590 | $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
|
---|
591 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
|
---|
592 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
|
---|
593 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
|
---|
594 | $($(target)_DEFS)\
|
---|
595 | $($(target)_DEFS.$(bld_type))\
|
---|
596 | $($(target)_DEFS.$(bld_trg))\
|
---|
597 | $($(target)_DEFS.$(bld_trg_arch))\
|
---|
598 | $($(target)_DEFS.$(bld_trg_cpu))\
|
---|
599 | $($(target)_$(type)DEFS)\
|
---|
600 | $($(target)_$(type)DEFS.$(bld_type))\
|
---|
601 | $($(target)_$(type)DEFS.$(bld_trg))\
|
---|
602 | $($(target)_$(type)DEFS.$(bld_trg_arch))\
|
---|
603 | $($(target)_$(type)DEFS.$(bld_trg_cpu))\
|
---|
604 | $(foreach sdk, $($(source)_SDKS.$(bld_trg)) \
|
---|
605 | $($(source)_SDKS.$(bld_type)) \
|
---|
606 | $($(source)_SDKS),\
|
---|
607 | $(SDK_$(sdk)_DEFS)\
|
---|
608 | $(SDK_$(sdk)_DEFS.$(bld_type))\
|
---|
609 | $(SDK_$(sdk)_DEFS.$(bld_trg))\
|
---|
610 | $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
|
---|
611 | $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
|
---|
612 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
613 | $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
|
---|
614 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
|
---|
615 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
|
---|
616 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
|
---|
617 | $($(source)_DEFS)\
|
---|
618 | $($(source)_DEFS.$(bld_type))\
|
---|
619 | $($(source)_DEFS.$(bld_trg))\
|
---|
620 | $($(source)_DEFS.$(bld_trg_arch))\
|
---|
621 | $($(source)_DEFS.$(bld_trg_cpu))\
|
---|
622 | $($(source)_$(type)DEFS)\
|
---|
623 | $($(source)_$(type)DEFS.$(bld_type))\
|
---|
624 | $($(source)_$(type)DEFS.$(bld_trg))\
|
---|
625 | $($(source)_$(type)DEFS.$(bld_trg_arch))\
|
---|
626 | $($(source)_$(type)DEFS.$(bld_trg_cpu))\
|
---|
627 | $(foreach sdk, $($(target)_$(source)_SDKS.$(bld_trg)) \
|
---|
628 | $($(target)_$(source)_SDKS.$(bld_type)) \
|
---|
629 | $($(target)_$(source)_SDKS),\
|
---|
630 | $(SDK_$(sdk)_DEFS)\
|
---|
631 | $(SDK_$(sdk)_DEFS.$(bld_type))\
|
---|
632 | $(SDK_$(sdk)_DEFS.$(bld_trg))\
|
---|
633 | $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
|
---|
634 | $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
|
---|
635 | $(SDK_$(sdk)_$(type)DEFS)\
|
---|
636 | $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
|
---|
637 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
|
---|
638 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
|
---|
639 | $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
|
---|
640 | $($(target)_$(source)_DEFS)\
|
---|
641 | $($(target)_$(source)_DEFS.$(bld_type))\
|
---|
642 | $($(target)_$(source)_DEFS.$(bld_trg))\
|
---|
643 | $($(target)_$(source)_DEFS.$(bld_trg_arch))\
|
---|
644 | $($(target)_$(source)_DEFS.$(bld_trg_cpu))\
|
---|
645 | $($(target)_$(source)_$(type)DEFS)\
|
---|
646 | $($(target)_$(source)_$(type)DEFS.$(bld_type))\
|
---|
647 | $($(target)_$(source)_$(type)DEFS.$(bld_trg))\
|
---|
648 | $($(target)_$(source)_$(type)DEFS.$(bld_trg_arch))\
|
---|
649 | $($(target)_$(source)_$(type)DEFS.$(bld_trg_cpu))
|
---|
650 | incs :=\
|
---|
651 | $($(target)_$(source)_$(type)INCS.$(bld_trg_cpu))\
|
---|
652 | $($(target)_$(source)_$(type)INCS.$(bld_trg_arch))\
|
---|
653 | $($(target)_$(source)_$(type)INCS.$(bld_trg))\
|
---|
654 | $($(target)_$(source)_$(type)INCS.$(bld_type))\
|
---|
655 | $($(target)_$(source)_$(type)INCS)\
|
---|
656 | $($(target)_$(source)_INCS.$(bld_trg_cpu))\
|
---|
657 | $($(target)_$(source)_INCS.$(bld_trg_arch))\
|
---|
658 | $($(target)_$(source)_INCS.$(bld_trg))\
|
---|
659 | $($(target)_$(source)_INCS.$(bld_type))\
|
---|
660 | $($(target)_$(source)_INCS)\
|
---|
661 | $(foreach sdk, $($(target)_$(source)_SDKS.$(bld_trg)) \
|
---|
662 | $($(target)_$(source)_SDKS.$(bld_type)) \
|
---|
663 | $($(target)_$(source)_SDKS),\
|
---|
664 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
|
---|
665 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
|
---|
666 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
|
---|
667 | $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
|
---|
668 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
669 | $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
|
---|
670 | $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
|
---|
671 | $(SDK_$(sdk)_INCS.$(bld_trg))\
|
---|
672 | $(SDK_$(sdk)_INCS.$(bld_type))\
|
---|
673 | $(SDK_$(sdk)_INCS))\
|
---|
674 | $($(source)_$(type)INCS.$(bld_trg_cpu))\
|
---|
675 | $($(source)_$(type)INCS.$(bld_trg_arch))\
|
---|
676 | $($(source)_$(type)INCS.$(bld_trg))\
|
---|
677 | $($(source)_$(type)INCS.$(bld_type))\
|
---|
678 | $($(source)_$(type)INCS)\
|
---|
679 | $($(source)_INCS.$(bld_trg_cpu))\
|
---|
680 | $($(source)_INCS.$(bld_trg_arch))\
|
---|
681 | $($(source)_INCS.$(bld_trg))\
|
---|
682 | $($(source)_INCS.$(bld_type))\
|
---|
683 | $($(source)_INCS)\
|
---|
684 | $(foreach sdk, $($(source)_SDKS.$(bld_trg)) \
|
---|
685 | $($(source)_SDKS.$(bld_type)) \
|
---|
686 | $($(source)_SDKS),\
|
---|
687 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
|
---|
688 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
|
---|
689 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
|
---|
690 | $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
|
---|
691 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
692 | $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
|
---|
693 | $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
|
---|
694 | $(SDK_$(sdk)_INCS.$(bld_trg))\
|
---|
695 | $(SDK_$(sdk)_INCS.$(bld_type))\
|
---|
696 | $(SDK_$(sdk)_INCS))\
|
---|
697 | $($(target)_$(type)INCS.$(bld_trg_cpu))\
|
---|
698 | $($(target)_$(type)INCS.$(bld_trg_arch))\
|
---|
699 | $($(target)_$(type)INCS.$(bld_trg))\
|
---|
700 | $($(target)_$(type)INCS.$(bld_type))\
|
---|
701 | $($(target)_$(type)INCS)\
|
---|
702 | $($(target)_INCS.$(bld_trg_cpu))\
|
---|
703 | $($(target)_INCS.$(bld_trg_arch))\
|
---|
704 | $($(target)_INCS.$(bld_trg))\
|
---|
705 | $($(target)_INCS.$(bld_type))\
|
---|
706 | $($(target)_INCS)\
|
---|
707 | $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
|
---|
708 | $($(target)_SDKS.$(bld_type)) \
|
---|
709 | $($(target)_SDKS),\
|
---|
710 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
|
---|
711 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
|
---|
712 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
|
---|
713 | $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
|
---|
714 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
715 | $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
|
---|
716 | $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
|
---|
717 | $(SDK_$(sdk)_INCS.$(bld_trg))\
|
---|
718 | $(SDK_$(sdk)_INCS.$(bld_type))\
|
---|
719 | $(SDK_$(sdk)_INCS))\
|
---|
720 | $(INCS.$(bld_trg_cpu))\
|
---|
721 | $(INCS.$(bld_trg_arch))\
|
---|
722 | $(INCS.$(bld_trg))\
|
---|
723 | $(INCS.$(bld_type))\
|
---|
724 | $(INCS)\
|
---|
725 | $(foreach sdk, $(SDKS.$(bld_trg)) \
|
---|
726 | $(SDKS.$(bld_type)) \
|
---|
727 | $(SDKS),\
|
---|
728 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
|
---|
729 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
|
---|
730 | $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
|
---|
731 | $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
|
---|
732 | $(SDK_$(sdk)_$(type)INCS)\
|
---|
733 | $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
|
---|
734 | $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
|
---|
735 | $(SDK_$(sdk)_INCS.$(bld_trg))\
|
---|
736 | $(SDK_$(sdk)_INCS.$(bld_type))\
|
---|
737 | $(SDK_$(sdk)_INCS))\
|
---|
738 | $(TOOL_$(tool)_$(type)INCS.$(bld_trg_cpu))\
|
---|
739 | $(TOOL_$(tool)_$(type)INCS.$(bld_trg_arch))\
|
---|
740 | $(TOOL_$(tool)_$(type)INCS.$(bld_trg))\
|
---|
741 | $(TOOL_$(tool)_$(type)INCS.$(bld_type))\
|
---|
742 | $(TOOL_$(tool)_$(type)INCS)
|
---|
743 | flags :=\
|
---|
744 | $(TOOL_$(tool)_$(type)FLAGS)\
|
---|
745 | $(TOOL_$(tool)_$(type)FLAGS.$(bld_type))\
|
---|
746 | $(TOOL_$(tool)_$(type)FLAGS.$(bld_trg))\
|
---|
747 | $(TOOL_$(tool)_$(type)FLAGS.$(bld_trg_arch))\
|
---|
748 | $(TOOL_$(tool)_$(type)FLAGS.$(bld_trg_cpu))\
|
---|
749 | $($(type)FLAGS)\
|
---|
750 | $($(type)FLAGS.$(bld_type))\
|
---|
751 | $($(type)FLAGS.$(bld_trg))\
|
---|
752 | $($(type)FLAGS.$(bld_trg_arch))\
|
---|
753 | $($(type)FLAGS.$(bld_trg_cpu))\
|
---|
754 | $($(target)_$(type)FLAGS)\
|
---|
755 | $($(target)_$(type)FLAGS.$(bld_type))\
|
---|
756 | $($(target)_$(type)FLAGS.$(bld_trg))\
|
---|
757 | $($(target)_$(type)FLAGS.$(bld_trg_arch))\
|
---|
758 | $($(target)_$(type)FLAGS.$(bld_trg_cpu))\
|
---|
759 | $($(source)_$(type)FLAGS)\
|
---|
760 | $($(source)_$(type)FLAGS.$(bld_type))\
|
---|
761 | $($(source)_$(type)FLAGS.$(bld_trg))\
|
---|
762 | $($(source)_$(type)FLAGS.$(bld_trg_arch))\
|
---|
763 | $($(source)_$(type)FLAGS.$(bld_trg_cpu))\
|
---|
764 | $($(target)_$(source)_$(type)FLAGS)\
|
---|
765 | $($(target)_$(source)_$(type)FLAGS.$(bld_type))\
|
---|
766 | $($(target)_$(source)_$(type)FLAGS.$(bld_trg))\
|
---|
767 | $($(target)_$(source)_$(type)FLAGS.$(bld_trg_arch))\
|
---|
768 | $($(target)_$(source)_$(type)FLAGS.$(bld_trg_cpu))
|
---|
769 | objsuff := $(firstword \
|
---|
770 | $($(target)_$(source)_OBJSUFF.$(bld_trg))\
|
---|
771 | $($(target)_$(source)_OBJSUFF)\
|
---|
772 | $($(source)_OBJSUFF.$(bld_trg))\
|
---|
773 | $($(source)_OBJSUFF)\
|
---|
774 | $($(target)_OBJSUFF.$(bld_trg))\
|
---|
775 | $($(target)_OBJSUFF)\
|
---|
776 | $(TOOL_$(tool)_$(type)OBJSUFF.$(bld_trg))\
|
---|
777 | $(TOOL_$(tool)_$(type)OBJSUFF)\
|
---|
778 | $(SUFF_OBJ))
|
---|
779 | obj := $(outbase)$(objsuff)
|
---|
780 | deps := \
|
---|
781 | $($(target)_$(source)_DEPS)\
|
---|
782 | $($(target)_$(source)_DEPS.$(bld_type))\
|
---|
783 | $($(target)_$(source)_DEPS.$(bld_trg))\
|
---|
784 | $($(target)_$(source)_DEPS.$(bld_trg_arch))\
|
---|
785 | $($(target)_$(source)_DEPS.$(bld_trg_cpu))\
|
---|
786 | $($(source)_DEPS)\
|
---|
787 | $($(source)_DEPS.$(bld_type))\
|
---|
788 | $($(source)_DEPS.$(bld_trg))\
|
---|
789 | $($(source)_DEPS.$(bld_trg_arch))\
|
---|
790 | $($(source)_DEPS.$(bld_trg_cpu))\
|
---|
791 | $($(target)_DEPS)\
|
---|
792 | $($(target)_DEPS.$(bld_type))\
|
---|
793 | $($(target)_DEPS.$(bld_trg_arch))\
|
---|
794 | $($(target)_DEPS.$(bld_trg_cpu))
|
---|
795 |
|
---|
796 | # dependencies
|
---|
797 | dep := $(obj)$(SUFF_DEP)
|
---|
798 | ifndef NO_COMPILE_DEPS
|
---|
799 | _DEPFILES_INCLUDED += $(dep)
|
---|
800 | $(if $(wildcard $(dep)),$(eval include $(dep)))
|
---|
801 | endif
|
---|
802 |
|
---|
803 | #$ (warning dbg: target=$(target) source=$(source) tool=$(tool) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff) deps=$(deps))
|
---|
804 | ifndef TOOL_$(tool)_COMPILE_$(type)_CMDS
|
---|
805 | $(warning kBuild: tools: \
|
---|
806 | 1 $($(target)_$(source)_$(type)TOOL.$(bld_trg)) \
|
---|
807 | 2 $($(target)_$(source)_$(type)TOOL) \
|
---|
808 | 3 $($(target)_$(source)_TOOL.$(bld_trg)) \
|
---|
809 | 4 $($(target)_$(source)_TOOL) \
|
---|
810 | 5 $($(target)_$(type)TOOL.$(bld_trg)) \
|
---|
811 | 6 $($(target)_$(type)TOOL) \
|
---|
812 | 7 $($(target)_TOOL.$(bld_trg)) \
|
---|
813 | 8 $($(target)_TOOL) \
|
---|
814 | 9 $($(source)_$(type)TOOL.$(bld_trg)) \
|
---|
815 | 10 $($(source)_$(type)TOOL) \
|
---|
816 | 11 $($(source)_TOOL.$(bld_trg)) \
|
---|
817 | 12 $($(source)_TOOL) \
|
---|
818 | 13 $($(type)TOOL.$(bld_trg)) \
|
---|
819 | 14 $($(type)TOOL) \
|
---|
820 | 15 $(TOOL.$(bld_trg)) \
|
---|
821 | 16 $(TOOL) )
|
---|
822 | $(error kBuild: TOOL_$(tool)_COMPILE_$(type)_CMDS is not defined. source=$(source) target=$(target) )
|
---|
823 | endif
|
---|
824 |
|
---|
825 | # call the tool
|
---|
826 | $(target)_$(source)_CMDS_ := $(TOOL_$(tool)_COMPILE_$(type)_CMDS)
|
---|
827 | $(target)_$(source)_OUTPUT_ := $(TOOL_$(tool)_COMPILE_$(type)_OUTPUT)
|
---|
828 | $(target)_$(source)_DEPEND_ := $(TOOL_$(tool)_COMPILE_$(type)_DEPEND) $(deps) $(source)
|
---|
829 | $(target)_$(source)_DEPORD_ := $(TOOL_$(tool)_COMPILE_$(type)_DEPORD) $(dirdep)
|
---|
830 |
|
---|
831 | # generate the compile rule.
|
---|
832 | $(eval $(def_target_source_rule))
|
---|
833 |
|
---|
834 | _OUT_FILES += $($(target)_$(source)_OUTPUT_)
|
---|
835 | $(target)_OBJS_ += $(obj)
|
---|
836 |
|
---|
837 | endef
|
---|
838 |
|
---|
839 | ## Generic macro for processing all target sources.
|
---|
840 | # @param $(target) Normalized target name.
|
---|
841 | define def_target_sources
|
---|
842 | #$ (warning def_target_sources)
|
---|
843 | # C sources
|
---|
844 | type := C
|
---|
845 | $(foreach source, $(filter %.c, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\
|
---|
846 | ,$(eval $(value def_target_source_c_cpp_asm)) )
|
---|
847 |
|
---|
848 | # C++ sources
|
---|
849 | type := CXX
|
---|
850 | $(foreach source, $(filter %.cpp %.cxx %.xx, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\
|
---|
851 | ,$(eval $(value def_target_source_c_cpp_asm)) )
|
---|
852 |
|
---|
853 | # ASM sources
|
---|
854 | type := AS
|
---|
855 | $(foreach source, $(filter %.asm %.s %.S, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\
|
---|
856 | ,$(eval $(value def_target_source_c_cpp_asm)) )
|
---|
857 |
|
---|
858 | endef
|
---|
859 |
|
---|
860 |
|
---|
861 |
|
---|
862 | ## Generic macro for generating the install rule(s) for a target
|
---|
863 | # and update the globals with default out.
|
---|
864 | #
|
---|
865 | # @param $(target) Normalized target name.
|
---|
866 | # @param $(out) The output file.
|
---|
867 | # @param $(definst) The default _INST value.
|
---|
868 | # @param $(typevar) The name of the variable with all the root targets of its type.
|
---|
869 | # @obsolete
|
---|
870 | define def_target_install_pluss
|
---|
871 | ifndef $(target)_NOINST
|
---|
872 | INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
|
---|
873 | $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
|
---|
874 |
|
---|
875 | $(eval $(def_link_install_rule))
|
---|
876 |
|
---|
877 | _INSTALLS += $(INSTARGET_$(target))
|
---|
878 |
|
---|
879 | ifdef KBUILD_DO_AUTO_INSTALL
|
---|
880 | $(typevar) += $(INSTARGET_$(target))
|
---|
881 | else
|
---|
882 | $(typevar) += $(out)
|
---|
883 | endif
|
---|
884 | else # _NOINST
|
---|
885 | $(typevar) += $(out)
|
---|
886 | endif
|
---|
887 |
|
---|
888 | _OUT_FILES += $(out)
|
---|
889 | _CLEAN_FILES += $($(target)_CLEAN)
|
---|
890 | _OBJS += $($(target)_OBJS_)
|
---|
891 |
|
---|
892 | endef
|
---|
893 |
|
---|
894 |
|
---|
895 |
|
---|
896 | #
|
---|
897 | # LIBRARIES
|
---|
898 | #
|
---|
899 |
|
---|
900 | ## Library (one).
|
---|
901 | # @param $(target) Normalized library (target) name.
|
---|
902 | define def_lib
|
---|
903 | # library basics
|
---|
904 | ## @todo prefix
|
---|
905 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
906 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))
|
---|
907 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
|
---|
908 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU))
|
---|
909 | tool := $(call _TARGET_TOOL,$(target),AR)
|
---|
910 | ifeq ($(tool),)
|
---|
911 | $(error kBuild: Library target $(target) does not have a tool defined!)
|
---|
912 | endif
|
---|
913 | outbase := $(call _TARGET_BASE,$(target),$(target))
|
---|
914 | PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
|
---|
915 | suff := $(firstword\
|
---|
916 | $($(target)_LIBSUFF.$(bld_trg))\
|
---|
917 | $($(target)_LIBSUFF)\
|
---|
918 | $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg))\
|
---|
919 | $(TOOL_$(tool)_ARLIBSUFF)\
|
---|
920 | $(SUFF_LIB))
|
---|
921 | out := $(outbase)$(suff)
|
---|
922 | TARGET_$(target) := $(out)
|
---|
923 | $(target)_OBJS_ := $(filter %.o %.obj, \
|
---|
924 | $($(target)_SOURCES) \
|
---|
925 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
926 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
927 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
928 | $($(target)_SOURCES.$(bld_type)))
|
---|
929 |
|
---|
930 |
|
---|
931 | # source -> object
|
---|
932 | $(eval $(value def_target_sources))
|
---|
933 |
|
---|
934 | # library linking
|
---|
935 | tool := $(call _TARGET_TOOL,$(target),AR)
|
---|
936 | outbase := $(call _TARGET_BASE,$(target),$(target))
|
---|
937 | flags :=\
|
---|
938 | $(TOOL_$(tool)_ARFLAGS)\
|
---|
939 | $(TOOL_$(tool)_ARFLAGS.$(bld_type))\
|
---|
940 | $(ARFLAGS)\
|
---|
941 | $(ARFLAGS.$(bld_type))\
|
---|
942 | $($(target)_ARFLAGS)\
|
---|
943 | $($(target)_ARFLAGS.$(bld_type))
|
---|
944 | othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,\
|
---|
945 | $($(target)_SOURCES) \
|
---|
946 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
947 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
948 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
949 | $($(target)_SOURCES.$(bld_type)))
|
---|
950 | objs = $($(target)_OBJS_)
|
---|
951 | dirdep := $(call DIRDEP,$(dir $(out)))
|
---|
952 | ## @todo fix dependencies on makefiles an such
|
---|
953 | deps := $($(target)_DEPS)
|
---|
954 |
|
---|
955 | # dependency file
|
---|
956 | dep := $(out)$(SUFF_DEP)
|
---|
957 | ifndef NO_LINK_CMDS_DEP
|
---|
958 | _DEPFILES_INCLUDED += $(dep)
|
---|
959 | $(if $(wildcard $(dep)),$(eval include $(dep)))
|
---|
960 | endif
|
---|
961 |
|
---|
962 | # check that the tool is defined.
|
---|
963 | ifndef TOOL_$(tool)_LINK_LIBRARY_CMDS
|
---|
964 | $(warning kBuild: tools: \
|
---|
965 | 1 $($(target)_$(source)TOOL.$(bld_trg)) \
|
---|
966 | 2 $($(target)_$(source)TOOL) \
|
---|
967 | 3 $($(target)_TOOL.$(bld_trg)) \
|
---|
968 | 4 $($(target)_TOOL) \
|
---|
969 | 5 $($(source)TOOL) \
|
---|
970 | 6 $($(source)TOOL.$(bld_trg)) \
|
---|
971 | 7 $(TOOL.$(bld_trg)) \
|
---|
972 | 8 $(TOOL) )
|
---|
973 | $(error kBuild: TOOL_$(tool)_LINK_LIBRARY_CMDS isn't defined! target=$(target) )
|
---|
974 | endif
|
---|
975 |
|
---|
976 | # call the tool
|
---|
977 | $(target)_CMDS_ := $(TOOL_$(tool)_LINK_LIBRARY_CMDS)
|
---|
978 | $(target)_OUTPUT_ := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT)
|
---|
979 | $(target)_DEPEND_ := $(TOOL_$(tool)_LINK_LIBRARY_DEPEND) $(deps) $(objs)
|
---|
980 | $(target)_DEPORD_ := $(TOOL_$(tool)_LINK_LIBRARY_DEPORD) $(dirdep)
|
---|
981 |
|
---|
982 | # generate the link rule.
|
---|
983 | $(eval $(def_link_rule))
|
---|
984 |
|
---|
985 | # installing and globals
|
---|
986 | definst := $(PATH_LIB)
|
---|
987 | typevar := _LIBS
|
---|
988 | $(eval $(value def_target_install_pluss))
|
---|
989 | endef
|
---|
990 |
|
---|
991 | # Process libraries
|
---|
992 | mode := 0644
|
---|
993 | $(foreach target, $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)), $(eval $(value def_lib)))
|
---|
994 |
|
---|
995 |
|
---|
996 | #
|
---|
997 | # Link operations.
|
---|
998 | #
|
---|
999 |
|
---|
1000 | ##
|
---|
1001 | # Link prolog
|
---|
1002 | #
|
---|
1003 | # @param $(target) Normalized target name.
|
---|
1004 | # @param $(EXT) EXE,DLL,SYS.
|
---|
1005 | # @param $(definst) The default _INST value.
|
---|
1006 | # @param $(typevar) The name of the variable with all the root targets of its type.
|
---|
1007 | define def_link_common
|
---|
1008 | # basics
|
---|
1009 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
1010 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var)))
|
---|
1011 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH))
|
---|
1012 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU))
|
---|
1013 |
|
---|
1014 | tool := $(call _TARGET_TOOL,$(target),LD)
|
---|
1015 | outbase := $(call _TARGET_BASE,$(target),$(target))
|
---|
1016 | suff := $(firstword \
|
---|
1017 | $($(target)_$(EXT)SUFF) \
|
---|
1018 | $($(target)_$(EXT)SUFF) \
|
---|
1019 | $(TOOL_$(tool)_LD$(EXT)SUFF) \
|
---|
1020 | $($(EXTPRE)SUFF_$(EXT)))
|
---|
1021 | out := $(outbase)$(suff)
|
---|
1022 | PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
|
---|
1023 | TARGET_$(target) := $(out)
|
---|
1024 | $(target)_OBJS_ := $(filter %.o %.obj, \
|
---|
1025 | $($(target)_SOURCES) \
|
---|
1026 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
1027 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
1028 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
1029 | $($(target)_SOURCES.$(bld_type)))
|
---|
1030 |
|
---|
1031 | # source -> object
|
---|
1032 | $(eval $(value def_target_sources))
|
---|
1033 |
|
---|
1034 | # more library stuff.
|
---|
1035 | tool := $(call _TARGET_TOOL,$(target),LD)
|
---|
1036 | outbase := $(call _TARGET_BASE,$(target),$(target))
|
---|
1037 | flags :=\
|
---|
1038 | $(TOOL_$(tool)_LDFLAGS)\
|
---|
1039 | $(TOOL_$(tool)_LDFLAGS.$(bld_type))\
|
---|
1040 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg))\
|
---|
1041 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg_arch))\
|
---|
1042 | $(TOOL_$(tool)_LDFLAGS.$(bld_trg_cpu))\
|
---|
1043 | $(LDFLAGS)\
|
---|
1044 | $(LDFLAGS.$(bld_type))\
|
---|
1045 | $(LDFLAGS.$(bld_trg))\
|
---|
1046 | $(LDFLAGS.$(bld_trg_arch))\
|
---|
1047 | $(LDFLAGS.$(bld_trg_cpu))\
|
---|
1048 | $($(target)_LDFLAGS)\
|
---|
1049 | $($(target)_LDFLAGS.$(bld_type))\
|
---|
1050 | $($(target)_LDFLAGS.$(bld_trg))\
|
---|
1051 | $($(target)_LDFLAGS.$(bld_trg_arch))\
|
---|
1052 | $($(target)_LDFLAGS.$(bld_trg_cpu))
|
---|
1053 | othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,\
|
---|
1054 | $($(target)_SOURCES)\
|
---|
1055 | $($(target)_SOURCES.$(bld_trg)) \
|
---|
1056 | $($(target)_SOURCES.$(bld_trg_arch)) \
|
---|
1057 | $($(target)_SOURCES.$(bld_trg_cpu)) \
|
---|
1058 | $($(target)_SOURCES.$(bld_type)))
|
---|
1059 | objs = $($(target)_OBJS_)
|
---|
1060 | libs :=\
|
---|
1061 | $($(target)_LIBS.$(bld_trg_cpu))\
|
---|
1062 | $($(target)_LIBS.$(bld_trg_arch))\
|
---|
1063 | $($(target)_LIBS.$(bld_trg))\
|
---|
1064 | $($(target)_LIBS.$(bld_type))\
|
---|
1065 | $($(target)_LIBS)\
|
---|
1066 | $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
|
---|
1067 | $($(target)_SDKS.$(bld_type)) \
|
---|
1068 | $($(target)_SDKS),\
|
---|
1069 | $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
|
---|
1070 | $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
|
---|
1071 | $(SDK_$(sdk)_LIBS.$(bld_trg))\
|
---|
1072 | $(SDK_$(sdk)_LIBS.$(bld_type))\
|
---|
1073 | $(SDK_$(sdk)_LIBS))\
|
---|
1074 | $(LIBS.$(bld_trg_cpu))\
|
---|
1075 | $(LIBS.$(bld_trg_arch))\
|
---|
1076 | $(LIBS.$(bld_trg))\
|
---|
1077 | $(LIBS.$(bld_type))\
|
---|
1078 | $(LIBS)\
|
---|
1079 | $(foreach sdk, $(SDKS.$(bld_trg)) \
|
---|
1080 | $(SDKS.$(bld_type)) \
|
---|
1081 | $(SDKS),\
|
---|
1082 | $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
|
---|
1083 | $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
|
---|
1084 | $(SDK_$(sdk)_LIBS.$(bld_trg))\
|
---|
1085 | $(SDK_$(sdk)_LIBS.$(bld_type))\
|
---|
1086 | $(SDK_$(sdk)_LIBS))\
|
---|
1087 | $(TOOL_$(tool)_LIBS.$(bld_trg_cpu))\
|
---|
1088 | $(TOOL_$(tool)_LIBS.$(bld_trg_arch))\
|
---|
1089 | $(TOOL_$(tool)_LIBS.$(bld_trg))\
|
---|
1090 | $(TOOL_$(tool)_LIBS.$(bld_type))\
|
---|
1091 | $(TOOL_$(tool)_LIBS)
|
---|
1092 | libpath :=\
|
---|
1093 | $($(target)_LIBPATH.$(bld_trg_cpu))\
|
---|
1094 | $($(target)_LIBPATH.$(bld_trg_arch))\
|
---|
1095 | $($(target)_LIBPATH.$(bld_trg))\
|
---|
1096 | $($(target)_LIBPATH.$(bld_type))\
|
---|
1097 | $($(target)_LIBPATH)\
|
---|
1098 | $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
|
---|
1099 | $($(target)_SDKS.$(bld_type)) \
|
---|
1100 | $($(target)_SDKS),\
|
---|
1101 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
|
---|
1102 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
|
---|
1103 | $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
|
---|
1104 | $(SDK_$(sdk)_LIBPATH.$(bld_type))\
|
---|
1105 | $(SDK_$(sdk)_LIBPATH))\
|
---|
1106 | $(LIBPATH.$(bld_trg_cpu))\
|
---|
1107 | $(LIBPATH.$(bld_trg_arch))\
|
---|
1108 | $(LIBPATH.$(bld_trg))\
|
---|
1109 | $(LIBPATH.$(bld_type))\
|
---|
1110 | $(LIBPATH)\
|
---|
1111 | $(foreach sdk, $(SDKS.$(bld_trg)) \
|
---|
1112 | $(SDKS.$(bld_type)) \
|
---|
1113 | $(SDKS),\
|
---|
1114 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
|
---|
1115 | $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
|
---|
1116 | $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
|
---|
1117 | $(SDK_$(sdk)_LIBPATH.$(bld_type))\
|
---|
1118 | $(SDK_$(sdk)_LIBPATH))\
|
---|
1119 | $(TOOL_$(tool)_LIBPATH.$(bld_trg_cpu))\
|
---|
1120 | $(TOOL_$(tool)_LIBPATH.$(bld_trg_arch))\
|
---|
1121 | $(TOOL_$(tool)_LIBPATH.$(bld_trg))\
|
---|
1122 | $(TOOL_$(tool)_LIBPATH.$(bld_type))\
|
---|
1123 | $(TOOL_$(tool)_LIBPATH)
|
---|
1124 | dirdep := $(call DIRDEP,$(dir $(out)))
|
---|
1125 | ## @todo fix dependencies
|
---|
1126 | deps := $($(target)_DEPS)
|
---|
1127 |
|
---|
1128 | ## @todo this stuff can't be working.
|
---|
1129 | custom_pre := $(strip $(firstword \
|
---|
1130 | $($(target)_CUSTOM_PRE.$(bld_trg).$(bld_type))\
|
---|
1131 | $($(target)_CUSTOM_PRE.$(bld_trg))\
|
---|
1132 | $($(target)_CUSTOM_PRE.$(bld_type))\
|
---|
1133 | $($(target)_CUSTOM_PRE)\
|
---|
1134 | $(CUSTOM_PRE.$(bld_trg).$(bld_type))\
|
---|
1135 | $(CUSTOM_PRE.$(bld_trg))\
|
---|
1136 | $(CUSTOM_PRE.$(bld_type))\
|
---|
1137 | $(CUSTOM_PRE)\
|
---|
1138 | ))
|
---|
1139 | custom_post := $(strip $(firstword \
|
---|
1140 | $($(target)_CUSTOM_POST.$(bld_trg).$(bld_type))\
|
---|
1141 | $($(target)_CUSTOM_POST.$(bld_trg))\
|
---|
1142 | $($(target)_CUSTOM_POST.$(bld_type))\
|
---|
1143 | $($(target)_CUSTOM_POST)\
|
---|
1144 | $(CUSTOM_POST.$(bld_trg).$(bld_type))\
|
---|
1145 | $(CUSTOM_POST.$(bld_trg))\
|
---|
1146 | $(CUSTOM_POST.$(bld_type))\
|
---|
1147 | $(CUSTOM_POST)\
|
---|
1148 | ))
|
---|
1149 |
|
---|
1150 | # installation targets
|
---|
1151 | ifndef $(target)_NOINST
|
---|
1152 | INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
|
---|
1153 | $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
|
---|
1154 | ifdef KBUILD_DO_AUTO_INSTALL
|
---|
1155 | $(typevar) += $(INSTARGET_$(target))
|
---|
1156 | else
|
---|
1157 | $(typevar) += $(out)
|
---|
1158 | endif
|
---|
1159 | # generate the install rule
|
---|
1160 | $(eval $(def_link_install_rule))
|
---|
1161 |
|
---|
1162 | else # NOINST
|
---|
1163 | INSTARGET_$(target) :=
|
---|
1164 | $(typevar) += $(out)
|
---|
1165 | endif # NOINST
|
---|
1166 |
|
---|
1167 | # dependency file
|
---|
1168 | dep := $(outbase)$(SUFF_DEP)
|
---|
1169 | ifndef NO_LINK_CMDS_DEP
|
---|
1170 | _DEPFILES_INCLUDED += $(dep)
|
---|
1171 | $(if $(wildcard $(dep)),$(eval include $(dep)))
|
---|
1172 | endif
|
---|
1173 |
|
---|
1174 | # check that the tool is defined.
|
---|
1175 | ifndef TOOL_$(tool)_$(tool_do)_CMDS
|
---|
1176 | $(warning kBuild: tools: \
|
---|
1177 | 1 $($(target)_$(source)TOOL.$(bld_trg)) \
|
---|
1178 | 2 $($(target)_$(source)TOOL) \
|
---|
1179 | 3 $($(target)_TOOL.$(bld_trg)) \
|
---|
1180 | 4 $($(target)_TOOL) \
|
---|
1181 | 5 $($(source)TOOL) \
|
---|
1182 | 6 $($(source)TOOL.$(bld_trg)) \
|
---|
1183 | 7 $(TOOL.$(bld_trg)) \
|
---|
1184 | 8 $(TOOL) )
|
---|
1185 | $(error kBuild: TOOL_$(tool)_$(tool_do)_CMDS isn't defined! target=$(target) )
|
---|
1186 | endif
|
---|
1187 |
|
---|
1188 | # call the tool
|
---|
1189 | $(target)_CMDS_ := $(TOOL_$(tool)_$(tool_do)_CMDS)
|
---|
1190 | $(target)_OUTPUT_ := $(TOOL_$(tool)_$(tool_do)_OUTPUT)
|
---|
1191 | $(target)_DEPEND_ := $(TOOL_$(tool)_$(tool_do)_DEPEND) $(deps) $(objs)
|
---|
1192 | $(target)_DEPORD_ := $(TOOL_$(tool)_$(tool_do)_DEPORD) $(dirdep)
|
---|
1193 |
|
---|
1194 | # generate the link rule.
|
---|
1195 | $(eval $(def_link_rule))
|
---|
1196 |
|
---|
1197 |
|
---|
1198 | # Update globals.
|
---|
1199 | _OBJS += $($(target)_OBJS_)
|
---|
1200 | _OUT_FILES += $($(target)_OUTPUT_) $(out)
|
---|
1201 | _CLEAN_FILES += $($(target)_CLEAN)
|
---|
1202 | _INSTALLS += $(INSTARGET_$(target))
|
---|
1203 |
|
---|
1204 | endef
|
---|
1205 |
|
---|
1206 |
|
---|
1207 | #
|
---|
1208 | # BLDPROGS
|
---|
1209 | #
|
---|
1210 |
|
---|
1211 | ## Build program (one).
|
---|
1212 | # @param $(target) Normalized target (program) name.
|
---|
1213 | define def_bldprog
|
---|
1214 |
|
---|
1215 | # set NOINST if not forced installation.
|
---|
1216 | ifndef $(target)_INST
|
---|
1217 | $(target)_NOINST := 1
|
---|
1218 | endif
|
---|
1219 |
|
---|
1220 | # do the usual stuff.
|
---|
1221 | $(eval $(value def_link_common))
|
---|
1222 |
|
---|
1223 | endef
|
---|
1224 |
|
---|
1225 | # Process build programs.
|
---|
1226 | EXT := EXE
|
---|
1227 | EXTPRE := HOST
|
---|
1228 | tool_do := LINK_PROGRAM
|
---|
1229 | definst := $(PATH_BIN)
|
---|
1230 | typevar := _BLDPROGS
|
---|
1231 | mode := 0755
|
---|
1232 | bld_trg_base_var := PLATFORM
|
---|
1233 | $(foreach target, $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)), $(eval $(value def_bldprog)))
|
---|
1234 |
|
---|
1235 |
|
---|
1236 |
|
---|
1237 | #
|
---|
1238 | # DLLS
|
---|
1239 | #
|
---|
1240 |
|
---|
1241 | # Process dlls
|
---|
1242 | EXT := DLL
|
---|
1243 | EXTPRE :=
|
---|
1244 | tool_do := LINK_DLL
|
---|
1245 | definst := $(PATH_DLL)
|
---|
1246 | typevar := _DLLS
|
---|
1247 | mode := 0755
|
---|
1248 | bld_trg_base_var := TARGET
|
---|
1249 | $(foreach target, $(DLLS) $(DLLS.$(BUILD_TARGET)), $(eval $(value def_link_common)))
|
---|
1250 |
|
---|
1251 |
|
---|
1252 | #
|
---|
1253 | # Process import libraries.
|
---|
1254 | #
|
---|
1255 | # - On OS/2 and windows these are libraries.
|
---|
1256 | # - On other platforms they are fake DLLs.
|
---|
1257 | ifeq ($(filter-out win64 win32 os2,$(BUILD_TARGET)),)
|
---|
1258 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval $(value def_lib)))
|
---|
1259 | else
|
---|
1260 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval $(value def_link_common)))
|
---|
1261 | endif
|
---|
1262 | $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), \
|
---|
1263 | $(eval _IMPORT_LIBS += $(if $(INSTARGET_$(target)),$(INSTARGET_$(target)), $(TARGET_$(target)))))
|
---|
1264 |
|
---|
1265 |
|
---|
1266 | #
|
---|
1267 | # PROGRAMS
|
---|
1268 | #
|
---|
1269 |
|
---|
1270 | # Process programs
|
---|
1271 | EXT := EXE
|
---|
1272 | EXTPRE :=
|
---|
1273 | tool_do := LINK_PROGRAM
|
---|
1274 | definst := $(PATH_BIN)
|
---|
1275 | typevar := _PROGRAMS
|
---|
1276 | mode := 0755
|
---|
1277 | bld_trg_base_var := TARGET
|
---|
1278 | $(foreach target, $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)), $(eval $(value def_link_common)))
|
---|
1279 |
|
---|
1280 |
|
---|
1281 |
|
---|
1282 | #
|
---|
1283 | # SYSMODS
|
---|
1284 | #
|
---|
1285 |
|
---|
1286 | # Process sysmods
|
---|
1287 | EXT := SYS
|
---|
1288 | EXTPRE :=
|
---|
1289 | tool_do := LINK_SYSMOD
|
---|
1290 | definst := $(PATH_SYS)
|
---|
1291 | typevar := _SYSMODS
|
---|
1292 | mode := 0644
|
---|
1293 | bld_trg_base_var := TARGET
|
---|
1294 | $(foreach target, $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)), $(eval $(value def_link_common)))
|
---|
1295 |
|
---|
1296 |
|
---|
1297 | #
|
---|
1298 | # OTHERS
|
---|
1299 | #
|
---|
1300 | _OTHERS = $(OTHERS) $(OTHERS.$(BUILD_TARGET))
|
---|
1301 |
|
---|
1302 |
|
---|
1303 | #
|
---|
1304 | # INSTALLS
|
---|
1305 | #
|
---|
1306 |
|
---|
1307 | ## generate the install rule
|
---|
1308 | define def_install_src_rule
|
---|
1309 | # the install rule
|
---|
1310 | $(insdst) : $(srcsrc) | $(call DIRDEP,$(dir $(insdst)))
|
---|
1311 | $$(if $$(filter $(INSTALL),$(inscmd)),,$$(RM) -f $$@)
|
---|
1312 | $(inscmd)
|
---|
1313 | endef
|
---|
1314 |
|
---|
1315 | ## install one file
|
---|
1316 | define def_install_src
|
---|
1317 |
|
---|
1318 | # deal with '=>' in the source file name.
|
---|
1319 | srcdst := $(subst =>, ,$(src))
|
---|
1320 | srcsrc := $(firstword $(srcdst))
|
---|
1321 | srcdstdir := $(dir $(word 2,$(srcdst)))
|
---|
1322 | srcdst := $(word $(words $(srcdst)),$(srcdst))
|
---|
1323 |
|
---|
1324 | # _INSTFUN
|
---|
1325 | ifdef $(srcsrc)_INSTFUN
|
---|
1326 | instfun := $(srcsrc)_INSTFUN
|
---|
1327 | else
|
---|
1328 | ifdef $(target)_INSTFUN
|
---|
1329 | instfun := $(target)_INSTFUN
|
---|
1330 | else
|
---|
1331 | instfun := _INSTALL_FILE
|
---|
1332 | endif
|
---|
1333 | endif
|
---|
1334 |
|
---|
1335 | # _INST
|
---|
1336 | ifdef $(srcsrc)_INST
|
---|
1337 | inst := $(patsubst %/,%,$($(srcsrc)_INST))/$(dir $(srcdstdir))
|
---|
1338 | else
|
---|
1339 | ifdef $(target)_INST
|
---|
1340 | inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(srcdstdir))
|
---|
1341 | else
|
---|
1342 | inst := $(dir $(srcdstdir))
|
---|
1343 | endif
|
---|
1344 | endif
|
---|
1345 |
|
---|
1346 | # calc target
|
---|
1347 | insdst := $(call $(instfun),$(srcdst),$(target),$(inst),$(PATH_INS))
|
---|
1348 | #$(warning instfun=$(instfun) srcdst=$(srcdst) target=$(target) inst=$(inst) => insdst=$(insdst))
|
---|
1349 |
|
---|
1350 | # mode, uid and gid
|
---|
1351 | mode := $(firstword \
|
---|
1352 | $($(target)_$(srcsrc)_MODE.$(bld_trg)) \
|
---|
1353 | $($(target)_$(srcsrc)_MODE) \
|
---|
1354 | $($(target)_$(srcdst)_MODE.$(bld_trg)) \
|
---|
1355 | $($(target)_$(srcdst)_MODE) \
|
---|
1356 | $($(srcsrc)_MODE.$(bld_trg)) \
|
---|
1357 | $($(srcsrc)_MODE) \
|
---|
1358 | $($(srcdst)_MODE.$(bld_trg)) \
|
---|
1359 | $($(srcdst)_MODE) \
|
---|
1360 | $($(target)_MODE.$(bld_trg)) \
|
---|
1361 | $($(target)_MODE))
|
---|
1362 | uid := $(firstword \
|
---|
1363 | $($(target)_$(srcsrc)_UID.$(bld_trg)) \
|
---|
1364 | $($(target)_$(srcsrc)_UID) \
|
---|
1365 | $($(target)_$(srcdst)_UID.$(bld_trg)) \
|
---|
1366 | $($(target)_$(srcdst)_UID) \
|
---|
1367 | $($(srcsrc)_UID.$(bld_trg)) \
|
---|
1368 | $($(srcsrc)_UID) \
|
---|
1369 | $($(srcdst)_UID.$(bld_trg)) \
|
---|
1370 | $($(srcdst)_UID) \
|
---|
1371 | $($(target)_UID.$(bld_trg)) \
|
---|
1372 | $($(target)_UID))
|
---|
1373 | gid := $(firstword \
|
---|
1374 | $($(target)_$(srcsrc)_GID.$(bld_trg)) \
|
---|
1375 | $($(target)_$(srcsrc)_GID) \
|
---|
1376 | $($(target)_$(srcdst)_GID.$(bld_trg)) \
|
---|
1377 | $($(target)_$(srcdst)_GID) \
|
---|
1378 | $($(srcsrc)_GID.$(bld_trg)) \
|
---|
1379 | $($(srcsrc)_GID) \
|
---|
1380 | $($(srcdst)_GID.$(bld_trg)) \
|
---|
1381 | $($(srcdst)_GID) \
|
---|
1382 | $($(target)_GID.$(bld_trg)) \
|
---|
1383 | $($(target)_GID))
|
---|
1384 |
|
---|
1385 | # create the command
|
---|
1386 | ifdef $(srcsrc)_INSTALLER
|
---|
1387 | inscmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(insdst),$(target))
|
---|
1388 | else
|
---|
1389 | ifdef $(target)_INSTALLER
|
---|
1390 | inscmd := $(call $(target)_INSTALLER,$(srcsrc),$(insdst),$(target))
|
---|
1391 | else
|
---|
1392 | inscmd := $$(INSTALL)\
|
---|
1393 | $(if $(uid),-o $(uid))\
|
---|
1394 | $(if $(gid),-g $(gid))\
|
---|
1395 | $(if $(mode),-m $(mode))\
|
---|
1396 | $(srcsrc) $(insdst)
|
---|
1397 | endif
|
---|
1398 | endif
|
---|
1399 |
|
---|
1400 | # generate the rule (need double evaluation here)
|
---|
1401 | $(eval $(def_install_src_rule))
|
---|
1402 |
|
---|
1403 | INSTARGET_$(target) += $(insdst)
|
---|
1404 | endef
|
---|
1405 |
|
---|
1406 |
|
---|
1407 | ## generate the symlink rule
|
---|
1408 | define def_install_symlink_rule
|
---|
1409 | # the install rule
|
---|
1410 | $(insdst) : | $(call DIRDEP,$(dir $(insdst)))
|
---|
1411 | $$(RM) -f $$@
|
---|
1412 | $$(LN_SYMLINK) $(symdst) $(insdst)
|
---|
1413 | endef
|
---|
1414 |
|
---|
1415 | ## create one symlink
|
---|
1416 | define def_install_symlink
|
---|
1417 |
|
---|
1418 | # deal with '=>' in the source file name.
|
---|
1419 | symdst := $(subst =>, ,$(src))
|
---|
1420 | symlnk := $(firstword $(symdst))
|
---|
1421 | symdst := $(word $(words $(symdst)),$(symdst))
|
---|
1422 |
|
---|
1423 | # _INSTFUN
|
---|
1424 | ifdef $(symlnk)_INSTFUN
|
---|
1425 | instfun := $(symlnk)_INSTFUN
|
---|
1426 | else
|
---|
1427 | ifdef $(target)_INSTFUN
|
---|
1428 | instfun := $(target)_INSTFUN
|
---|
1429 | else
|
---|
1430 | instfun := _INSTALL_FILE
|
---|
1431 | endif
|
---|
1432 | endif
|
---|
1433 |
|
---|
1434 | # _INST
|
---|
1435 | ifdef $(symlnk)_INST
|
---|
1436 | inst := $(patsubst %/,%,$($(symlnk)_INST))/$(dir $(symlnk))
|
---|
1437 | else
|
---|
1438 | ifdef $(target)_INST
|
---|
1439 | inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(symlnk))
|
---|
1440 | else
|
---|
1441 | inst := $(dir $(symlnk))
|
---|
1442 | endif
|
---|
1443 | endif
|
---|
1444 |
|
---|
1445 | # calc target
|
---|
1446 | insdst := $(call $(instfun),$(symlnk),$(target),$(inst),$(PATH_INS))
|
---|
1447 | #$(warning symlnk=$(symlnk) symdst=$(symdst) insdst=$(insdst) instfun=$(instfun) inst='$(inst)')
|
---|
1448 |
|
---|
1449 | # generate the rule (need double evaluation here)
|
---|
1450 | $(eval $(def_install_symlink_rule))
|
---|
1451 |
|
---|
1452 | INSTARGET_$(target) += $(insdst)
|
---|
1453 | endef
|
---|
1454 |
|
---|
1455 |
|
---|
1456 | ## generate the install rule
|
---|
1457 | define def_install_directory_rule
|
---|
1458 | # the install rule
|
---|
1459 | $(insdst):
|
---|
1460 | $(INSTALL) -d \
|
---|
1461 | $(if $(uid),-o $(uid))\
|
---|
1462 | $(if $(gid),-g $(gid))\
|
---|
1463 | $(if $(mode),-m $(mode))\
|
---|
1464 | $(insdst)
|
---|
1465 |
|
---|
1466 | .NOTPARALLEL: $(insdst)
|
---|
1467 | endef
|
---|
1468 |
|
---|
1469 |
|
---|
1470 | ## create one directory
|
---|
1471 | define def_install_directory
|
---|
1472 |
|
---|
1473 | # _INST
|
---|
1474 | ifdef $(directory)_INST
|
---|
1475 | inst := $(PATH_INS)/$(patsubst %/,%,$($(directory)_INST))
|
---|
1476 | else
|
---|
1477 | ifdef $(target)_INST
|
---|
1478 | inst := $(PATH_INS)/$(patsubst %/,%,$($(target)_INST))
|
---|
1479 | else
|
---|
1480 | inst := $(PATH_INS)
|
---|
1481 | endif
|
---|
1482 | endif
|
---|
1483 |
|
---|
1484 | mode := $(firstword \
|
---|
1485 | $($(target)_$(directory)_MODE.$(bld_trg)) \
|
---|
1486 | $($(target)_$(directory)_MODE) \
|
---|
1487 | $($(directory)_MODE.$(bld_trg)) \
|
---|
1488 | $($(directory)_MODE) \
|
---|
1489 | $($(target)_MODE.$(bld_trg)) \
|
---|
1490 | $($(target)_MODE))
|
---|
1491 | uid := $(firstword \
|
---|
1492 | $($(target)_$(directory)_UID.$(bld_trg)) \
|
---|
1493 | $($(target)_$(directory)_UID) \
|
---|
1494 | $($(directory)_UID.$(bld_trg)) \
|
---|
1495 | $($(directory)_UID) \
|
---|
1496 | $($(target)_UID.$(bld_trg)) \
|
---|
1497 | $($(target)_UID))
|
---|
1498 | gid := $(firstword \
|
---|
1499 | $($(target)_$(directory)_GID.$(bld_trg)) \
|
---|
1500 | $($(target)_$(directory)_GID) \
|
---|
1501 | $($(directory)_GID.$(bld_trg)) \
|
---|
1502 | $($(directory)_GID) \
|
---|
1503 | $($(target)_GID.$(bld_trg)) \
|
---|
1504 | $($(target)_GID))
|
---|
1505 |
|
---|
1506 | insdst := $(inst)/$(directory)/
|
---|
1507 | #$(warning directory=$(directory) inst=$(inst) insdst=$(insdst) mode=$(mode) gid=$(gid) uid=$(uid))
|
---|
1508 |
|
---|
1509 | # generate the rule (need double evaluation here)
|
---|
1510 | $(eval $(def_install_directory_rule))
|
---|
1511 |
|
---|
1512 | INSTARGET_DIRS_$(target) += $(insdst)
|
---|
1513 | endef
|
---|
1514 |
|
---|
1515 |
|
---|
1516 | ## process one install target.
|
---|
1517 | define def_install
|
---|
1518 | bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
|
---|
1519 | bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))
|
---|
1520 | bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
|
---|
1521 | bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU))
|
---|
1522 |
|
---|
1523 | INSTARGET_$(target) :=
|
---|
1524 | INSTARGET_DIRS_$(target) :=
|
---|
1525 |
|
---|
1526 | $(foreach directory,$($(target)_DIRS) $($(target)_DIRS.$(bld_trg)) $($(target)_DIRS.$(bld_trg_arch)) $($(target)_DIRS.$(bld_trg_cpu)) $($(target)_DIRS.$(bld_type)), \
|
---|
1527 | $(eval $(value def_install_directory)))
|
---|
1528 |
|
---|
1529 | $(foreach src,$($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)), \
|
---|
1530 | $(eval $(value def_install_src)))
|
---|
1531 |
|
---|
1532 | $(foreach src,$($(target)_SYMLINKS) $($(target)_SYMLINKS.$(bld_trg)) $($(target)_SYMLINKS.$(bld_trg_arch)) $($(target)_SYMLINKS.$(bld_trg_cpu)) $($(target)_SYMLINKS.$(bld_type)), \
|
---|
1533 | $(eval $(value def_install_symlink)))
|
---|
1534 |
|
---|
1535 | _INSTALLS += $(INSTARGET_$(target)) $($(target)_GOALS)
|
---|
1536 | _INSTALLS_DIRS += $(INSTARGET_DIRS_$(target))
|
---|
1537 | endef
|
---|
1538 |
|
---|
1539 | ## process all install targets
|
---|
1540 | $(foreach target, $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)), \
|
---|
1541 | $(eval $(value def_install)))
|
---|
1542 |
|
---|
1543 |
|
---|
1544 | #
|
---|
1545 | # PACKING
|
---|
1546 | #
|
---|
1547 | _PACKING += $(PACKING) $(PACKING.$(BUILD_TARGET))
|
---|
1548 |
|
---|
1549 |
|
---|
1550 | #
|
---|
1551 | # DOCS
|
---|
1552 | #
|
---|
1553 |
|
---|
1554 |
|
---|
1555 | #
|
---|
1556 | # DIRECTORIES
|
---|
1557 | #
|
---|
1558 | _DIR_ALL := $(sort $(addsuffix /,$(patsubst %/,%,$(_DIRS))) $(dir $(_OUT_FILES) $(_OBJS) $(_INSTALLS)))
|
---|
1559 | $(foreach directory,$(_INSTALLS_DIRS), $(eval _DIR_ALL := $(filter-out $(directory),$(_DIR_ALL))))
|
---|
1560 |
|
---|
1561 |
|
---|
1562 | define def_mkdir_rule
|
---|
1563 | $(directory):
|
---|
1564 | $(call MSG_L1,Creating directory $$@)
|
---|
1565 | $(MKDIR) -p $$@
|
---|
1566 | endef
|
---|
1567 |
|
---|
1568 | $(foreach directory,$(_DIR_ALL),$(eval $(def_mkdir_rule)))
|
---|
1569 |
|
---|
1570 |
|
---|
1571 | #
|
---|
1572 | # NOTHING
|
---|
1573 | #
|
---|
1574 | do-nothing:
|
---|
1575 | $(call MSG_L1,Did nothing in $(CURDIR))
|
---|
1576 |
|
---|
1577 |
|
---|
1578 | #
|
---|
1579 | # CLEAN UP
|
---|
1580 | #
|
---|
1581 | do-clean:
|
---|
1582 | $(RM) -f $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_DEPFILES_INCLUDED) $(_CLEAN_FILES) $(OTHER_CLEAN)
|
---|
1583 |
|
---|
1584 |
|
---|
1585 | #
|
---|
1586 | # PASSES (including directory and makefile walking)
|
---|
1587 | #
|
---|
1588 |
|
---|
1589 | ## Subdir
|
---|
1590 | # @param $(pass) Lowercase pass name.
|
---|
1591 | # @param $(PASS) Uppercase pass name.
|
---|
1592 | # @param $(subdir) Subdirectory
|
---|
1593 | # @param $(tag) tag to attach to the rule name.
|
---|
1594 | define def_pass_subdir
|
---|
1595 | pass_$(pass)$(tag):: $(dep)
|
---|
1596 | + $(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass)
|
---|
1597 | endef
|
---|
1598 |
|
---|
1599 | ## Submakefile
|
---|
1600 | # @param $(pass) Lowercase pass name.
|
---|
1601 | # @param $(PASS) Uppercase pass name.
|
---|
1602 | # @param $(makefile) Makefile.
|
---|
1603 | # @param $(tag) tag to attach to the rule name.
|
---|
1604 | define def_pass_makefile
|
---|
1605 | pass_$(pass)$(tag):: $(dep)
|
---|
1606 | + $(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass)
|
---|
1607 | endef
|
---|
1608 |
|
---|
1609 | ## Execute a pass.
|
---|
1610 | # @param $(pass) Lowercase pass name.
|
---|
1611 | # @param $(PASS) Uppercase pass name.
|
---|
1612 | define def_pass_old
|
---|
1613 | $(eval SUBDIRS_$(PASS) ?= $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET)))
|
---|
1614 | $(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET)))
|
---|
1615 | $(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)))
|
---|
1616 | $(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET)))
|
---|
1617 |
|
---|
1618 | $(eval tag:=_before)
|
---|
1619 | $(eval dep:=)
|
---|
1620 | $(foreach subdir,$(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_subdir)))
|
---|
1621 | $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)),$(eval $(def_pass_makefile)))
|
---|
1622 |
|
---|
1623 | $(eval tag:=_after)
|
---|
1624 | $(eval dep:=pass_$(pass)_doit)
|
---|
1625 | $(foreach subdir,$(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_subdir)))
|
---|
1626 | $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_makefile)))
|
---|
1627 |
|
---|
1628 | .NOTPARALLEL: pass_$(pass)_before pass_$(pass)_after
|
---|
1629 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_doit pass_$(pass)_after
|
---|
1630 | pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$(var))
|
---|
1631 | pass_$(pass)_this: pass_$(pass)_before
|
---|
1632 | + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
|
---|
1633 | pass_$(pass)_after:: pass_$(pass)_this
|
---|
1634 | pass_$(pass): pass_$(pass)_after
|
---|
1635 |
|
---|
1636 | endef
|
---|
1637 |
|
---|
1638 | define def_pass
|
---|
1639 | $(eval SUBDIRS_$(PASS) ?= $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET)))
|
---|
1640 | $(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET)))
|
---|
1641 | $(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)))
|
---|
1642 | $(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET)))
|
---|
1643 |
|
---|
1644 | $(eval tag:=_before)
|
---|
1645 | $(eval dep:=)
|
---|
1646 | $(foreach subdir,$(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_subdir)))
|
---|
1647 | $(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)),$(eval $(def_pass_makefile)))
|
---|
1648 |
|
---|
1649 | $(eval tag:=_after)
|
---|
1650 | $(eval dep:=pass_$(pass)_doit)
|
---|
1651 | $(foreach subdir,$(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_subdir)))
|
---|
1652 | $(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_makefile)))
|
---|
1653 |
|
---|
1654 | ifdef KBUILD_SAFE_PARALLEL
|
---|
1655 | .NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this
|
---|
1656 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this pass_$(pass)_doit
|
---|
1657 | pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$(var))
|
---|
1658 | pass_$(pass)_this: pass_$(pass)_before
|
---|
1659 | + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
|
---|
1660 | pass_$(pass)_after:: pass_$(pass)_this
|
---|
1661 | pass_$(pass): pass_$(pass)_after
|
---|
1662 | else
|
---|
1663 | .NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
|
---|
1664 | .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
|
---|
1665 | pass_$(pass)_doit: pass_$(pass)_before \
|
---|
1666 | $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var)))
|
---|
1667 | pass_$(pass): \
|
---|
1668 | pass_$(pass)_before \
|
---|
1669 | pass_$(pass)_doit \
|
---|
1670 | pass_$(pass)_after
|
---|
1671 | endif
|
---|
1672 |
|
---|
1673 | #$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))))
|
---|
1674 | endef
|
---|
1675 |
|
---|
1676 | # Generate the defined passes.
|
---|
1677 | $(foreach PASS, $(PASSES), \
|
---|
1678 | $(eval pass := $(PASS_$(PASS)_pass)) \
|
---|
1679 | $(eval $(def_pass)))
|
---|
1680 |
|
---|
1681 | ## Pass order
|
---|
1682 | # @param $(pass) Current pass name.
|
---|
1683 | # @param $(prev_pass) The previous pass name.
|
---|
1684 | define def_pass_order
|
---|
1685 | ifdef KBUILD_SAFE_PARALLEL
|
---|
1686 | .NOTPARALLEL: pass_$(pass)_order
|
---|
1687 | .PHONY: pass_$(pass)_order
|
---|
1688 | pass_$(pass)_order: $(pass_prev)
|
---|
1689 | $(call MSG_L1,Pass - $(if $(PASS_$(PASS)),$(PASS_$(PASS)),$(pass)))
|
---|
1690 | + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)
|
---|
1691 | else
|
---|
1692 | .NOTPARALLEL: pass_$(pass)_order pass_$(pass)_banner
|
---|
1693 | .PHONY: pass_$(pass)_order pass_$(pass)_banner
|
---|
1694 | pass_$(pass)_banner:
|
---|
1695 | $(call MSG_L1,Pass - $(if $(PASS_$(PASS)),$(PASS_$(PASS)),$(pass)))
|
---|
1696 | pass_$(pass)_order: \
|
---|
1697 | $(pass_prev) \
|
---|
1698 | pass_$(pass)_banner \
|
---|
1699 | pass_$(pass)
|
---|
1700 | endif
|
---|
1701 | $(eval pass_prev := pass_$(pass)_order)
|
---|
1702 | endef
|
---|
1703 |
|
---|
1704 | ## PASS: order
|
---|
1705 | # Use dependencies to ensure correct pass order.
|
---|
1706 | pass_prev :=
|
---|
1707 | $(foreach PASS,$(DEFAULT_PASSES),\
|
---|
1708 | $(eval pass := $(PASS_$(PASS)_pass)) \
|
---|
1709 | $(eval $(def_pass_order)))
|
---|
1710 |
|
---|
1711 |
|
---|
1712 | #
|
---|
1713 | # THE MAIN RULES
|
---|
1714 | #
|
---|
1715 | all_recursive: $(pass_prev)
|
---|
1716 |
|
---|
1717 | rebuild: clean
|
---|
1718 | + $(MAKE) -f $(firstword $(MAKEFILE_LIST)) all_recursive
|
---|
1719 |
|
---|
1720 | # @todo make this a non-default pass!
|
---|
1721 | uninstall:
|
---|
1722 | $(RM) -f $(_INSTALLS)
|
---|
1723 |
|
---|
1724 | install: pass_installs
|
---|
1725 |
|
---|
1726 | # misc shortcuts.
|
---|
1727 | targets: bldprogs libraries dlls programs sysmods others installs
|
---|
1728 | objects: $(_OBJS)
|
---|
1729 | bldprogs: $(_BLDPROGS)
|
---|
1730 | libraries: $(_LIBS) $(_IMPORT_LIBS) $(_OTHER_LIBRARIES)
|
---|
1731 | dlls: $(_DLLS)
|
---|
1732 | programs: $(_PROGRAMS)
|
---|
1733 | sysmods: $(_SYSMODS)
|
---|
1734 | others: $(_OTHERS)
|
---|
1735 | installs: $(_INSTALLS_DIRS) $(_INSTALLS)
|
---|
1736 |
|
---|
1737 |
|
---|
1738 | #
|
---|
1739 | # kBuild debugging stuff.
|
---|
1740 | #
|
---|
1741 | _SPACE := $(subst ., ,.)
|
---|
1742 | _TAB := $(subst ., ,.)
|
---|
1743 | define _NEWLINE
|
---|
1744 |
|
---|
1745 |
|
---|
1746 | endef
|
---|
1747 | NLTAB = $(_NEWLINE)$(TAB)
|
---|
1748 | show_targets:
|
---|
1749 | @$(foreach target, $(ALL_TARGETS),\
|
---|
1750 | @$(ECHO) "target: $(target)" $(NLTAB)\
|
---|
1751 | @$(ECHO) " PATH_$(target)=$(PATH_$(target))" $(NLTAB)\
|
---|
1752 | @$(ECHO) " TARGET_$(target)=$(TARGET_$(target))" $(NLTAB)\
|
---|
1753 | @$(ECHO) " INSTARGET_$(target)=$(INSTARGET_$(target))" $(NLTAB)\
|
---|
1754 | $(foreach prop,$(PROPS_SINGLE) $(PROPS_ACCUMULATE) OBJS_ CLEAN, \
|
---|
1755 | $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))) \
|
---|
1756 | $(if $($(target)_$(prop).$(_tmp)),\
|
---|
1757 | @$(ECHO) " $(target)_$(prop).$(_tmp)=$($(target)_$(prop).$(_tmp))" $(NLTAB)) \
|
---|
1758 | $(if $($(target)_$(prop)), $(NLTAB)@$(ECHO) " $(target)_$(prop)=$($(target)_$(prop))" $(NLTAB)) \
|
---|
1759 | )\
|
---|
1760 | $(foreach prop,$(PROPS_DEFERRED), \
|
---|
1761 | $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))) \
|
---|
1762 | $(if $(value $(target)_$(prop).$(_tmp)),\
|
---|
1763 | @$(ECHO) ' $(target)_$(prop).$(_tmp)=$(value $(TARGET)_$(prop).$(_tmp))' $(NLTAB)) \
|
---|
1764 | $(if $(value $(target)_$(prop)), $(NLTAB)@$(ECHO) ' $(target)_$(prop)=$(value $(target)_$(prop))' $(NLTAB)) \
|
---|
1765 | ))
|
---|
1766 |
|
---|
1767 |
|
---|
1768 |
|
---|
1769 | #
|
---|
1770 | # Include dependency files.
|
---|
1771 | #
|
---|
1772 | $(foreach dep,$(wildcard $(_DEPFILES)),$(eval include $(dep)))
|
---|
1773 |
|
---|
1774 |
|
---|
1775 | # end-of-file-content
|
---|
1776 | __footer_kmk__ := target
|
---|
1777 | endif # __footer_kmk__
|
---|
1778 |
|
---|