source: trunk/kBuild/footer.kmk@ 828

Last change on this file since 828 was 828, checked in by bird, 18 years ago

Split the target list processing up into two passes so that it's possible to make use of the TARGET_xxxx and INSTARGET_xxxx variables in the properties of any other target.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 77.6 KB
Line 
1# $Id: footer.kmk 828 2007-02-03 02:26:03Z bird $
2## @file
3#
4# kBuild - File included at top of makefile.
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 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
27ifndef __footer_kmk__
28# start-of-file-content
29
30#
31# Make sure that the core variables we defined in recursive expansion mode
32# up in header.kmk get expanded before we really start using them. The kBuild
33# functions added to kmk to speed stuff up assumes that the variables are
34# expanded here.
35#
36PATH_OBJ := $(PATH_OBJ)
37PATH_TARGET := $(PATH_TARGET)
38PATH_INS := $(PATH_INS)
39PATH_BIN := $(PATH_BIN)
40PATH_DLL := $(PATH_DLL)
41PATH_SYS := $(PATH_SYS)
42PATH_LIB := $(PATH_LIB)
43PATH_DOC := $(PATH_DOC)
44
45#
46# Variables.
47# (Some of these need initialization before including definitions using them.)
48#
49
50# all targets.
51ALL_TARGETS += \
52 $(FETCHES) $(FETCHES.$(BUILD_TARGET)) $(FETCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
53 $(PATCHES) $(PATCHES.$(BUILD_TARGET)) $(PATCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
54 $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) $(BLDPROGS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)) \
55 $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) $(LIBRARIES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
56 $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
57 $(DLLS) $(DLLS.$(BUILD_TARGET)) $(DLLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
58 $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) $(PROGRAMS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
59 $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) $(SYSMODS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
60 $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) $(INSTALLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
61 $(OTHERS) $(OTHERS.$(BUILD_TARGET)) $(OTHERS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH))
62
63# all $(BUILD_TARGET) targets.
64_ALL_BUILD_TARGET_TARGETS += \
65 $(FETCHES) $(FETCHES.$(BUILD_TARGET)) $(FETCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
66 $(PATCHES) $(PATCHES.$(BUILD_TARGET)) $(PATCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
67 $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) $(LIBRARIES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
68 $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
69 $(DLLS) $(DLLS.$(BUILD_TARGET)) $(DLLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
70 $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) $(PROGRAMS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
71 $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) $(SYSMODS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
72 $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) $(INSTALLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
73 $(OTHERS) $(OTHERS.$(BUILD_TARGET)) $(OTHERS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH))
74
75# all $(BUILD_TARGET) targets.
76_ALL_BUILD_PLATFORM_TARGETS += \
77 $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) $(BLDPROGS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH))
78
79# all targets making use of srcname.
80_ALL_SRCNAME_TARGETS += \
81 $(FETCHES) $(FETCHES.$(BUILD_TARGET)) $(FETCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
82 $(PATCHES) $(PATCHES.$(BUILD_TARGET)) $(PATCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH))
83
84# dependency files.
85_DEPFILES :=
86
87# included dependency files.
88_DEPFILES_INCLUDED :=
89
90
91# All kind of output files except for _OBJS and _DEPFILES.
92# Compiling or linking definition outputting other things that $@ and any
93# required dependency file must add those output files to this variable.
94_OUT_FILES :=
95
96# Files which only requires cleaning up.
97_CLEAN_FILES :=
98
99# all of a type
100_OBJS :=
101_FETCHES :=
102_DOWNLOADS:=
103_UNPACKS :=
104_PATCHES :=
105_UNFETCHES:=
106_BLDPROGS :=
107_LIBS :=
108_DLLS :=
109_PROGRAMS :=
110_SYSMODS :=
111_INSTALLS :=
112_INSTALLS_FILES :=
113_INSTALLS_DIRS :=
114_OTHERS :=
115_PACKING :=
116_DIRS := $(PATH_TARGET)/ $(PATH_TARGET)
117_IMPORT_LIBS :=
118
119# misc
120pass_prev :=
121
122
123#
124# Basic macros
125#
126
127## Figure out the tool for a target.
128# @param $1 normalized target.
129# @param $2 tooltype.
130# @param bld_trg build target.
131# @param bld_trg_arch build target architecture.
132_TARGET_TOOL = $(strip $(firstword \
133 $($(1)_$(2)TOOL.$(bld_trg).$(bld_trg_arch)) \
134 $($(1)_$(2)TOOL.$(bld_trg)) \
135 $($(1)_$(2)TOOL) \
136 $($(1)_TOOL.$(bld_trg).$(bld_trg_arch)) \
137 $($(1)_TOOL.$(bld_trg)) \
138 $($(1)_TOOL) \
139 $($(2)TOOL.$(bld_trg).$(bld_trg_arch)) \
140 $($(2)TOOL.$(bld_trg)) \
141 $($(2)TOOL) \
142 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
143 $(TOOL.$(bld_trg)) \
144 $(TOOL) \
145 ))
146
147## Figure out the actual name of an installed file.
148# @param $1 The file to install.
149# @param $2 The target name.
150# @param $3 The _INST value (can be empty).
151# @param $4 The default directory to use when $3 is empty.
152_INSTALL_FILE = $(patsubst %/,%/$(notdir $(1)),$(if $(3),$(PATH_INS)/$(3),$(4)/))
153
154
155#
156# Include the additional footer macros when bootstrapping kBuild.
157#
158ifndef KMK_VERSION
159 include $(PATH_KBUILD)/gnumake-footer.kmk
160endif
161
162
163
164#
165# Check syntax which leads to weird syntax errors.
166#
167
168## Check
169# @param $(target) Target name.
170define def_check_target
171ifneq ("$($(target)_TEMPLATE)","$(strip $($(target)_TEMPLATE))")
172$$(error $(target) have an incorrect template name. Remove any tabs!)
173endif
174endef
175$(foreach target, $(ALL_TARGETS),$(eval $(def_check_target)))
176
177
178#
179# Include templates
180#
181_TEMPLATES := $(TEMPLATE)
182define def_templates
183ifdef $(target)_TEMPLATE
184_TEMPLATES += $($(target)_TEMPLATE)
185endif
186endef
187$(foreach target, $(ALL_TARGETS), $(eval $(def_templates)))
188_TEMPLATES := $(sort $(_TEMPLATES))
189# $ (warning dbg: _TEMPLATES=$(_TEMPLATES))
190
191define def_templates_include
192ifndef TEMPLATE_$(template)
193include $(firstword $(foreach path, $(TEMPLATE_PATHS) $(PATH_KBUILD)/templates/, $(wildcard $(path)/$(template).kmk)))
194endif
195endef
196$(foreach template, $(_TEMPLATES), $(eval $(def_templates)))
197
198
199#
200# Template Inheritance.
201#
202define def_template_extends_prop
203ifndef TEMPLATE_$(template)_$(prop)
204 ifdef TEMPLATE_$(parent)_$(prop)
205TEMPLATE_$(template)_$(prop) = $$(TEMPLATE_$(parent)_$(prop))
206 endif
207endif
208endef
209
210
211define def_template_extends
212ifdef TEMPLATE_$(template)_EXTENDS
213 ifndef TEMPLATE_$(template)_EXTENDS_STATUS_
214 TEMPLATE_$(template)_EXTENDS_STATUS_ := 0
215 parent := $(strip $(TEMPLATE_$(template)_EXTENDS))
216
217 # recursivly process the parent if it's inherting from somebody too.
218 ifdef TEMPLATE_$(parent)_EXTENDS
219 ifneq ($(TEMPLATE_$(parent)_EXTENDS_STATUS_),42)
220 # foreach will create 'template' in a new variable context hiding our current variable.
221 $(foreach template, $(parent), $(eval $(value def_template_extends)))
222 parent := $(strip $(TEMPLATE_$(template)_EXTENDS))
223 endif
224 endif
225
226 # inherit properties.
227 $(foreach prop, $(PROPS_SINGLE) $(PROPS_ACCUMULATE_R) $(PROPS_ACCUMULATE_L) $(PROPS_DEFERRED)\
228 $(addsuffix .$(BUILD_TARGET), $(PROPS_SINGLE) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R) $(PROPS_DEFERRED))\
229 $(addsuffix .$(BUILD_TARGET).$(BUILD_TARGET_ARCH), $(PROPS_SINGLE) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R) $(PROPS_DEFERRED))\
230 $(addsuffix .$(BUILD_TARGET_ARCH), $(PROPS_SINGLE) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R) $(PROPS_DEFERRED))\
231 $(addsuffix .$(BUILD_TARGET_CPU), $(PROPS_SINGLE) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R) $(PROPS_DEFERRED))\
232 $(addsuffix .$(BUILD_TYPE), $(PROPS_SINGLE) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R) $(PROPS_DEFERRED))\
233 ,$(eval $(def_template_extends_prop))) # exploits the 2 evaluation, so no value!
234
235 TEMPLATE_$(template)_EXTENDS_STATUS_ := 42
236 else
237 # protect against inheritance loops.
238 ifneq ($(TEMPLATE_$(template)_EXTENDS_STATUS_),42)
239 $(error kBuild: inheritance loop! template=$(template))
240 endif
241 endif
242endif
243endef
244
245# $ (foreach template, $(_TEMPLATES), $(if TEMPLATE_$(template)_EXTENDS, $(eval $(value def_template_extends))))
246$(foreach template, $(_TEMPLATES), $(eval $(value def_template_extends)))
247
248
249#
250# Common Inheritance
251#
252
253## Inherit one template property in a non-accumulative manner.
254# @param $(prop) Property name
255# @param $(target) Target name
256# @todo fix the precedence order for some properties.
257define def_inherit_template_one
258ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
259ifndef $(target)_$(prop)
260$(target)_$(prop) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
261#$ (warning dbgtarget: $(target)_$(prop):='$(value $(target)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
262endif
263endif
264ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
265ifndef $(target)_$(prop).$(bld_trg)
266#$ (warning dbgsource: $(target)_$(prop).$(bld_trg)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
267$(target)_$(prop).$(bld_trg) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
268endif
269endif
270ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
271ifndef $(target)_$(prop).$(bld_trg).$(bld_trg_arch)
272#$ (warning dbgsource: $(target)_$(prop).$(bld_trg).$(bld_trg_arch)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
273$(target)_$(prop).$(bld_trg).$(bld_trg_arch) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
274endif
275endif
276ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
277ifndef $(target)_$(prop).$(bld_trg_arch)
278#$ (warning dbgsource: $(target)_$(prop).$(bld_trg_arch)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
279$(target)_$(prop).$(bld_trg_arch) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
280endif
281endif
282ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
283ifndef $(target)_$(prop).$(bld_trg_cpu)
284#$ (warning dbgsource: $(target)_$(prop).$(bld_trg_cpu)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
285$(target)_$(prop).$(bld_trg_cpu) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
286endif
287endif
288endef
289
290## Inherit one template property in a non-accumulative manner, deferred expansion.
291# @param 1: $(prop) Property name
292# @param 2: $(target) Target name
293# @todo fix the precedence order for some properties.
294# @remark this define relies on double evaluation
295define def_inherit_template_one_deferred
296ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
297ifndef $(target)_$(prop)
298$(target)_$(prop) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
299#$ (warning dbgtarget: $(target)_$(prop):='$(value $(target)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
300endif
301endif
302ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
303ifndef $(target)_$(prop).$(bld_trg)
304#$ (warning dbgsource: $(target)_$(prop).$(bld_trg)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
305$(target)_$(prop).$(bld_trg) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
306endif
307endif
308ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
309ifndef $(target)_$(prop).$(bld_trg).$(bld_trg_arch)
310#$ (warning dbgsource: $(target)_$(prop).$(bld_trg).$(bld_trg_arch)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
311$(target)_$(prop).$(bld_trg).$(bld_trg_arch) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
312endif
313endif
314ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
315ifndef $(target)_$(prop).$(bld_trg_arch)
316#$ (warning dbgsource: $(target)_$(prop).$(bld_trg_arch)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
317$(target)_$(prop).$(bld_trg_arch) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
318endif
319endif
320ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
321ifndef $(target)_$(prop).$(bld_trg_cpu)
322#$ (warning dbgsource: $(target)_$(prop).$(bld_trg_cpu)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
323$(target)_$(prop).$(bld_trg_cpu) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
324endif
325endif
326endef
327
328## Inherit one acculumlative template property where the 'most significant' items are at the left end.
329# @param $(prop) Property name
330# @param $(target) Target name
331define def_inherit_template_one_accumulate_l
332ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
333#$ (warning dbgtype: TEMPLATE_$($(target)_TEMPLATE)_$(prop) $(target)_$(prop)=$($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
334$(target)_$(prop) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
335#$ (warning dbgtype: $(target)_$(prop)=$($(target)_$(prop)))
336endif
337ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)
338#$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
339$(target)_$(prop).$(BUILD_TYPE) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
340endif
341ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
342#$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
343$(target)_$(prop).$(bld_trg) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg))
344endif
345ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
346#$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
347$(target)_$(prop).$(bld_trg).$(bld_trg_arch) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch))
348endif
349ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
350#$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
351$(target)_$(prop).$(bld_trg_cpu) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu))
352endif
353ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
354#$ (warning dbg6: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
355$(target)_$(prop).$(bld_trg_arch) += $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch))
356endif
357endef
358
359## Inherit one acculumlative template property where the 'most significant' items are at the right end.
360# First pass, $(value) referenced.
361# @param $(prop) Property name
362# @param $(target) Target name
363define def_inherit_template_one_accumulate_r1
364ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
365$(eval _$(target)_$(prop)_R = $(value $(target)_$(prop)))
366endif
367ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)
368$(eval _$(target)_$(prop).$(BUILD_TYPE)_R = $(value $(target)_$(prop).$(BUILD_TYPE)))
369endif
370ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
371$(eval _$(target)_$(prop).$(bld_trg)_R = $(value $(target)_$(prop).$(bld_trg)))
372endif
373ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
374$(eval _$(target)_$(prop).$(bld_trg).$(bld_trg_arch)_R = $(value $(target)_$(prop).$(bld_trg).$(bld_trg_arch)))
375endif
376ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
377$(eval _$(target)_$(prop).$(bld_trg_cpu)_R = $(value $(target)_$(prop).$(bld_trg_cpu)))
378endif
379ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
380$(eval _$(target)_$(prop).$(bld_trg_arch)_R = $(value $(target)_$(prop).$(bld_trg_arch)))
381endif
382endef
383
384## Inherit one template property the other way around.
385# Second pass, not $(value) referenced.
386# @param $(prop) Property name
387# @param $(target) Target name
388define def_inherit_template_one_accumulate_r2
389ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
390$(target)_$(prop) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop)) $$(_$(target)_$(prop)_R)
391endif
392ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)
393$(target)_$(prop).$(BUILD_TYPE) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)) $$(_$(target)_$(prop).$(BUILD_TYPE)_R)
394endif
395ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)
396$(target)_$(prop).$(bld_trg) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg)) $$(_$(target)_$(prop).$(bld_trg)_R)
397endif
398ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)
399$(target)_$(prop).$(bld_trg).$(bld_trg_arch) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg).$(bld_trg_arch)) $$(_$(target)_$(prop).$(bld_trg).$(bld_trg_arch)_R)
400endif
401ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)
402$(target)_$(prop).$(bld_trg_cpu) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_cpu)) $$(_$(target)_$(prop).$(bld_trg_cpu)_R)
403endif
404ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)
405$(target)_$(prop).$(bld_trg_arch) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(bld_trg_arch)) $$(_$(target)_$(prop).$(bld_trg_arch)_R)
406endif
407endef
408
409
410## Inherit template properties for on target.
411# @param $(target) Target name.
412define def_inherit_template
413# sanity check.
414ifdef _$(target)_ALREADY_PROCESSED
415 $(error kBuild: The target $(target) appears more than once in the target lists! Please correct the makefile(s))
416endif
417_$(target)_ALREADY_PROCESSED := 1
418
419# Inherit any default template.
420ifdef TEMPLATE
421ifeq ($($(target)_TEMPLATE),)
422$(eval $(target)_TEMPLATE:=$(TEMPLATE))
423endif
424endif
425# Expand the template if specified.
426ifneq ($($(target)_TEMPLATE),)
427$(foreach prop,$(PROPS_SINGLE),$(eval $(value def_inherit_template_one)))
428$(foreach prop,$(PROPS_DEFERRED),$(eval $(def_inherit_template_one_deferred))) # exploits the 2 evaluation, so no value!
429$(foreach prop,$(PROPS_ACCUMULATE_L),$(eval $(def_inherit_template_one_accumulate_l))) # += works fine (better) without value.
430$(foreach prop,$(PROPS_ACCUMULATE_R),\
431$(eval $(value def_inherit_template_one_accumulate_r1))\
432$(eval $(def_inherit_template_one_accumulate_r2))\
433) # This is a hack! (but it appears to work)
434endif
435endef
436
437# Inherit template properties
438bld_trg := $(BUILD_TARGET)
439bld_trg_arch := $(BUILD_TARGET_ARCH)
440bld_trg_cpu := $(BUILD_TARGET_CPU)
441$(foreach target, $(_ALL_BUILD_TARGET_TARGETS),$(eval $(value def_inherit_template)))
442
443bld_trg := $(BUILD_PLATFORM)
444bld_trg_arch := $(BUILD_PLATFORM_ARCH)
445bld_trg_cpu := $(BUILD_PLATFORM_CPU)
446$(foreach target, $(_ALL_BUILD_PLATFORM_TARGETS),$(eval $(value def_inherit_template)))
447
448
449#
450# Include tools & sdks
451#
452_TOOLS := $(TOOL.$(BUILD_TARGET)) $(TOOL.$(BUILD_TARGET_ARCH)) $(TOOL.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
453 $(TOOL.$(BUILD_PLATFORM)) $(TOOL.$(BUILD_PLATFORM_ARCH)) $(TOOL.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)) \
454 $(TOOL)
455_SDKS := $(SDKS.$(BUILD_TARGET)) $(SDKS.$(BUILD_TARGET_ARCH)) $(SDKS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) \
456 $(SDKS.$(BUILD_PLATFORM)) $(SDKS.$(BUILD_PLATFORM_ARCH)) $(SDKS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)) \
457 $(SDKS.$(BUILD_TYPE)) \
458 $(SDKS)
459define def_tools_sdks_target_source
460$(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
461 $($(source)_$(prop).$(_bld_trg)) \
462 $($(target)_$(source)_$(prop).$(_bld_trg)) \
463 $($(source)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
464 $($(target)_$(source)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
465 $($(source)_$(prop).$(_bld_trg_arch)) \
466 $($(target)_$(source)_$(prop).$(_bld_trg_arch)) \
467 $($(source)_$(prop)) \
468 $($(target)_$(source)_$(prop))))
469$(eval _SDKS += \
470 $($(source)_SDKS.$(_bld_trg)) \
471 $($(target)_$(source)_SDKS.$(_bld_trg)) \
472 $($(source)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
473 $($(target)_$(source)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
474 $($(source)_SDKS.$(_bld_trg_arch)) \
475 $($(target)_$(source)_SDKS.$(_bld_trg_arch)) \
476 $($(source)_SDKS.$(BUILD_TYPE)) \
477 $($(target)_$(source)_SDKS.$(BUILD_TYPE)) \
478 $($(source)_SDKS) \
479 $($(target)_$(source)_SDKS))
480endef
481
482define def_tools_sdks_target
483_bld_trg := $(firstword $($(target)_BLD_TRG) $(bld_trg))
484_bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(bld_trg_arch))
485_bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(bld_trg_cpu))
486
487$(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
488 $($(target)_$(prop).$(_bld_trg)) \
489 $($(target)_$(prop).$(_bld_trg_arch)) \
490 $($(target)_$(prop).$(_bld_trg).$(_bld_trg_arch)) \
491 $($(target)_$(prop))))
492$(eval _SDKS += \
493 $($(target)_SDKS.$(_bld_trg)) \
494 $($(target)_SDKS.$(_bld_trg_arch)) \
495 $($(target)_SDKS.$(_bld_trg).$(_bld_trg_arch)) \
496 $($(target)_SDKS))
497$(foreach source, \
498 $($(target)_SOURCES.$(_bld_trg)) \
499 $($(target)_SOURCES.$(_bld_trg_arch)) \
500 $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \
501 $($(target)_SOURCES.$(_bld_trg_cpu)) \
502 $($(target)_SOURCES.$(BUILD_TYPE)) \
503 $($(target)_SOURCES) \
504 , $(eval $(value def_tools_sdks_target_source)))
505endef
506
507define def_tools_srcname_target
508_bld_trg := $(firstword $($(target)_BLD_TRG) $(bld_trg))
509_bld_trg_arch := $(firstword $($(target)_BLD_TRG_ARCH) $(bld_trg_arch))
510_bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(bld_trg_cpu))
511
512$(foreach source, $(notdir\
513 $($(target)_SOURCES.$(_bld_trg)) \
514 $($(target)_SOURCES.$(_bld_trg_arch)) \
515 $($(target)_SOURCES.$(_bld_trg).$(_bld_trg_arch)) \
516 $($(target)_SOURCES.$(_bld_trg_cpu)) \
517 $($(target)_SOURCES.$(BUILD_TYPE)) \
518 $($(target)_SOURCES) \
519 ), $(eval $(value def_tools_sdks_target_source)))
520endef
521
522bld_trg := $(BUILD_TARGET)
523bld_trg_arch := $(BUILD_TARGET_ARCH)
524bld_trg_cpu := $(BUILD_TARGET_CPU)
525$(foreach target, $(_ALL_BUILD_TARGET_TARGETS), $(eval $(value def_tools_sdks_target)))
526$(foreach target, $(_ALL_SRCNAME_TARGETS), $(eval $(value def_tools_srcname_target)))
527
528bld_trg := $(BUILD_PLATFORM)
529bld_trg_arch := $(BUILD_PLATFORM_ARCH)
530bld_trg_cpu := $(BUILD_PLATFORM_CPU)
531$(foreach target, $(_ALL_BUILD_PLATFORM_TARGETS), $(eval $(value def_tools_sdks_target)))
532
533
534# include TOOLS
535define def_tools_include
536ifndef TOOL_$(tool)
537TOOL_$(tool)_KMK_FILE := $(firstword $(foreach path, $(TOOL_PATHS) $(PATH_KBUILD)/tools, $(wildcard $(path)/$(tool).kmk)))
538ifeq ($(TOOL_$(tool)_KMK_FILE),)
539$(error kBuild: Cannot find include file for the tool '$(tool)'! Searched: $(TOOL_PATHS) $(PATH_KBUILD)/tools)
540endif
541include $(TOOL_$(tool)_KMK_FILE)
542endif
543endef
544
545_TOOLS := $(sort $(_TOOLS))
546$(foreach tool, $(_TOOLS), $(eval $(value def_tools_include)))
547
548
549# include SDKS
550define def_sdks_include_one
551ifndef SDK_$(sdk)
552SDK_$(sdk)_KMK_FILE := $(firstword $(foreach path, $(SDK_PATHS) $(PATH_KBUILD)/sdks, $(wildcard $(path)/$(sdk).kmk)))
553ifeq ($(SDK_$(sdk)_KMK_FILE),)
554$(error kBuild: Cannot find include file for the SDK '$(sdk)'! Searched: $(SDK_PATHS) $(PATH_KBUILD)/sdks)
555endif
556include $(SDK_$(sdk)_KMK_FILE)
557endif
558endef
559
560_SDKS := $(sort $(_SDKS))
561$(foreach sdk, $(_SDKS), $(eval $(value def_sdks_include_one)))
562
563
564
565#
566#
567# Target lists - Pass 1
568#
569# This pass is for defining variables that might be referenced in
570# properties of other targets.
571#
572#
573
574# Don't do anything for fetch targets (yet).
575
576##
577# Link prolog for Pass 1.
578#
579# @param $(target) Normalized target name.
580# @param $(EXT) EXE,DLL,SYS,LIB.
581# @param $(EXTPRE) HOST or nothing.
582# @param $(definst) The default _INST value.
583# @param $(tool_prefix) LD or AR.
584# @param $(bld_trg_base_var) TARGET or PLATFORM.
585define def_pass1_link_common
586
587bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
588bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var)))
589bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH))
590bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU))
591
592tool := $(call _TARGET_TOOL,$(target),$(tool_prefix))
593outbase := $(call TARGET_BASE,$(target),$(target))
594ifndef PATH_$(target)
595 PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
596else ifneq ($(PATH_$(target)),$(patsubst %/,%,$(dir $(outbase))))
597 $(error kBuild internal error: PATH_$(target)=$(PATH_$(target)) expected $(patsubst %/,%,$(dir $(outbase))))
598endif
599ifeq ($(tool_prefix),AR) ## @todo fix this mess!
600suff := $(firstword\
601 $($(target)_$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\
602 $($(target)_$(EXT)SUFF.$(bld_trg))\
603 $($(target)_$(EXT)SUFF)\
604 $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF.$(bld_trg).$(bld_trg_arch))\
605 $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF.$(bld_trg))\
606 $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF)\
607 $(SUFF_LIB))
608else
609suff := $(firstword \
610 $($(target)_$(EXT)SUFF) \
611 $($(target)_$(EXT)SUFF) \
612 $(TOOL_$(tool)_$(tool_prefix)$(EXT)SUFF) \
613 $($(EXTPRE)SUFF_$(EXT)))
614endif
615out := $(outbase)$(suff)
616
617# TARGET_*
618TARGET_$(target) := $(out)
619
620# INSTARGET_*
621ifndef $(target)_NOINST
622INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
623 $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
624
625else # NOINST
626INSTARGET_$(target) :=
627endif # NOINST
628
629endef
630
631
632#
633# BLDPROGS (Pass 1)
634#
635define def_pass1_bldprog
636# set NOINST if not forced installation before doing the usual stuff.
637ifndef $(target)_INST
638$(target)_NOINST := 1
639endif
640$(eval $(value def_pass1_link_common))
641endef
642
643EXT := EXE
644EXTPRE := HOST
645definst := $(PATH_BIN)
646tool_prefix := LD
647bld_trg_base_var := PLATFORM
648$(foreach target, $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) $(BLDPROGS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)), \
649 $(eval $(value def_pass1_bldprog)))
650
651
652#
653# LIBRARIES (Pass 1)
654#
655EXT := LIB
656EXTPRE :=
657definst := $(PATH_LIB)
658tool_prefix := AR
659bld_trg_base_var := TARGET
660$(foreach target, $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) $(LIBRARIES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
661 $(eval $(value def_pass1_link_common)))
662
663
664#
665# DLLS (Pass 1)
666#
667EXT := DLL
668EXTPRE :=
669definst := $(PATH_DLL)
670tool_prefix := LD
671bld_trg_base_var := TARGET
672$(foreach target, $(DLLS) $(DLLS.$(BUILD_TARGET)) $(DLLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
673 $(eval $(value def_pass1_link_common)))
674
675
676#
677# IMPORT LIBRARIES (Pass 1)
678#
679# - On OS/2 and windows these are libraries.
680# - On other platforms they are fake DLLs.
681#
682ifeq ($(filter-out nt os2 win win64 win32,$(BUILD_TARGET)),)
683 EXT := LIB
684 EXTPRE :=
685 definst := $(PATH_LIB)
686 tool_prefix := AR
687 bld_trg_base_var := TARGET
688 $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
689 $(eval $(value def_pass1_lib)))
690else
691 EXT := DLL
692 EXTPRE :=
693 definst := $(PATH_DLL)
694 tool_prefix := LD
695 bld_trg_base_var := TARGET
696 $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
697 $(eval $(value def_pass1_link_common)))
698endif
699
700
701#
702# PROGRAMS (Pass 1)
703#
704EXT := EXE
705EXTPRE :=
706definst := $(PATH_BIN)
707tool_prefix := LD
708bld_trg_base_var := TARGET
709$(foreach target, $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) $(PROGRAMS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
710 $(eval $(value def_pass1_link_common)))
711
712
713#
714# SYSMODS (Pass 1)
715#
716EXT := SYS
717EXTPRE :=
718definst := $(PATH_SYS)
719tool_prefix := LD
720bld_trg_base_var := TARGET
721$(foreach target, $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) $(SYSMODS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
722 $(eval $(value def_pass1_link_common)))
723
724
725#
726# INSTALLS (Pass 1)
727# Note! INSTARGET_* for INSTALLS aren't available until later.
728#
729define def_pass1_install
730bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
731bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))
732bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
733bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU))
734# TARGET_*
735TARGET_$(target) := $(PATH_TARGET)/$(target).ins
736# INSTARGET_ later.
737endef
738$(foreach target, $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) $(INSTALLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
739 $(eval $(value def_pass1_install)))
740
741
742
743
744#
745#
746# Target lists - Pass 2
747#
748#
749
750
751## @page pg_fetches Fetching Tools, Sources and Similar.
752#
753# The targets listed in the the FETCHES target list have the following attributes:
754# SOURCES
755# INST
756# FETCHTOOL
757# FETCHFLAGS
758# FETCHDIR
759# UNPACKTOOL
760# UNPACKFLAGS
761#
762# As usual the target name is an alias for 'creating' the target. Other
763# aliases are:
764# pass_fetches
765# fetch
766# unfetch
767# download
768# unpack
769#
770# @remark
771#
772# This is a little bit complex because we must guarantee that if a source file
773# changes only sligtly we must refetch it and to a proper unpacking of it. It
774# is also a desire that fetched archives and unpacked files can be deleted to
775# save space.
776#
777# Thus, we must be able to cleanup what we've unpacked should any of the
778# sources be removed. We do this by maintaining a file listing the files
779# and directories that was unpacked. This operation is named 'unfetch'.
780#
781# We make use of the SIZE and MD5 attributes for each of the sources to
782# create a digest that is stored in the primary target file. Subsequent
783# runswill compare their digest with it to decide if a refetch is required.
784# When a refetch is found necessary, an 'unfetch' is performed first to
785# clean out old files and directores. Note even changes in source order
786# will cause a refetch due to the way the digest is constructed and
787# evaluated.
788#
789# By not depending directly on the archives (nor on any unpacked files)
790# but on a goal made up from the archive name, size and md5, we allow
791# the user to delete the archives. Naturally, this means we'll have to
792# check and fetch missing archives before attempting to unpack them.
793#
794# @remark
795#
796# This feature will *NOT* work correctly with vanilla GNU make becuase
797# it makes use of includedep to avoid too many unnecessary files.
798#
799# @todo
800# 1. Port md5sum or some equivalent tool and include it in kBuild.
801# 2. Download corruption / continuation.
802# 3. It's quite possible that there is one too many indirect dependency now...
803#
804
805## @todo move this!
806MD5SUM := md5sum
807
808## generates the fetch rule
809define def_fetch_src_fetch_rule
810# Indirect goal for downloading something.
811.PRECIOUS: $(out)
812$(out) $($(target)_$(srcname)_FETCH_OUTPUT_): | $($(target)_$(srcname)_FETCH_DEPORD_)
813 $$(call MSG_FETCH_DL,$(target),$(source),$(out))
814 @## @todo do fancy stuff like download continuation.
815 $$(QUIET)$$(RM) -f $(out) $(out).md5
816 $($(target)_$(srcname)_FETCH_CMDS_)
817 $$(QUIET2)$(if $(md5),$$(APPEND) $(out).md5 "$(md5) *$(out)")
818 $$(QUIET)$(if $(md5),$$(MD5SUM) -c $(out).md5)
819
820
821
822# Intermediate goal for making sure the md5 and size matches. it will (re) fetch the archive if necessary.
823$(out).checked_$(md5)_$(size): $($(target)_$(srcname)_FETCH_DEPEND_) | $($(target)_$(srcname)_FETCH_DEPORD_)
824 $$(call MSG_FETCH_CHK,$(target),$(source),$(out))
825 $$(QUIET)$$(RM) -f $$@ $(out).md5
826 @# creates the .md5 we pass to md5sum.
827 $$(QUIET2)$(if $(md5),$$(APPEND) $(out).md5 "$(md5) *$(out)")
828 @# (re)fetch the file if it doesn't exist or if it doesn't matches the md5.
829 @## @todo do fancy stuff like download continuation.
830 $$(QUIET)( test -f $(out) && $(if $(md5),$$(MD5SUM) -c $(out).md5, true) ) \
831 || ( $$(RM_EXT) -f $(out) \
832 && $$(MAKE) $(out) -f $(MAKEFILE) --no-print-directory )
833 $$(QUIET2)$$(APPEND) $$@
834
835_TARGET_$(target)_FETCHED += $(out) $(out).checked_$(md5)_$(size)
836
837# Just a little precaution.
838.NOTPARALLEL: $(out) $(out).checked_$(md5)_$(size)
839
840endef
841
842## generates the unpack rule
843define def_fetch_src_unpack_rule
844# This is the unpack rule. it has an order-only dependency on the download check.
845$(out) $($(target)_$(srcname)_UNPACK_OUTPUT_): $($(target)_$(srcname)_UNPACK_DEPEND_) \
846 | $($(target)_$(srcname)_UNPACK_DEPORD_) $(archive).checked_$(md5)_$(size)
847 $$(call MSG_FETCH_UP,$(target),$(archive),$(inst))
848 $$(QUIET)$$(RM) -f $(out)
849 @# if the source archive doesn't exist fetch it (can have been deleted to save space).
850 $$(QUIET)test -f $(archive) \
851 || ( $$(RM_EXT) -f $(archive).checked_$(md5)_$(size) \
852 && $$(MAKE) $(archive).checked_$(md5)_$(size) -f $(MAKEFILE) --no-print-directory )
853 $($(target)_$(srcname)_UNPACK_CMDS_)
854 $$(QUIET2)$$(APPEND) $(out) $(notdir $(archive).checked_$(md5)_$(size))
855 $$(QUIET2)$$(APPEND) $(out) $(notdir $(out))
856
857$(eval _TARGET_$(target)_UNPACKED += $(out))
858_TARGET_$(target)_DIGEST := $(_TARGET_$(target)_DIGEST)-$(srcname)_$(md5)_$(size)
859
860.NOTPARALLEL: $(out)
861
862endef
863
864## Processes a fetch source
865#
866define def_fetch_src
867#$ (warning dbg: def_fetch_src: source='$(source)' target='$(target)')
868
869# common
870srcname := $(notdir $(source))
871inst := $(firstword \
872 $($(target)_$(source)_INST)\
873 $($(target)_$(srcname)_INST)\
874 $($(source)_INST)\
875 $($(srcname)_INST)\
876 $($(target)_INST)\
877)
878ifneq ($(patsubst %/,ok,$(inst)),ok)
879$(error kBuild: Bad or missing INST property for source '$(source)' in target '$(target)': $(inst))
880endif
881INSTARGET_$(target)_$(srcname) := $(inst)
882fetchdir := $(firstword \
883 $($(target)_$(source)_FETCHDIR)\
884 $($(target)_$(srcname)_FETCHDIR)\
885 $($(source)_FETCHDIR)\
886 $($(srcname)_FETCHDIR)\
887 $($(target)_FETCHDIR)\
888 $(FETCHDIR)\
889 $(PATH_TARGET)\
890)
891deps := \
892 $($(target)_$(source)_DEPS)\
893 $($(target)_$(srcname)_DEPS)\
894 $($(source)_DEPS)\
895 $($(srcname)_DEPS)\
896 $($(target)_DEPS)
897orderdeps := \
898 $($(target)_$(source)_ORDERDEPS)\
899 $($(target)_$(srcname)_ORDERDEPS)\
900 $($(source)_ORDERDEPS)\
901 $($(srcname)_ORDERDEPS)\
902 $($(target)_ORDERDEPS)
903md5 := $(firstword \
904 $($(target)_$(source)_MD5)\
905 $($(target)_$(srcname)_MD5)\
906 $($(source)_MD5)\
907 $($(srcname)_MD5)\
908 $($(target)_MD5)\
909)
910size := $(firstword \
911 $($(target)_$(source)_SIZE)\
912 $($(target)_$(srcname)_SIZE)\
913 $($(source)_SIZE)\
914 $($(srcname)_SIZE)\
915 $($(target)_SIZE)\
916)
917dep := # not legal for fetch and unpack tools
918
919
920#
921# The fetching.
922#
923out := $(fetchdir)/$(srcname)
924archive := $(out)
925TARGET_$(target)_$(srcname) := $(out)
926dirdep := $(call DIRDEP,$(fetchdir))
927tool := $(firstword \
928 $($(target)_$(source)_FETCHTOOL)\
929 $($(target)_$(srcname)_FETCHTOOL)\
930 $($(target)_$(source)_TOOL)\
931 $($(target)_$(srcname)_TOOL)\
932 $($(source)_FETCHTOOL)\
933 $($(srcname)_FETCHTOOL)\
934 $($(source)_TOOL)\
935 $($(srcname)_TOOL)\
936 $($(target)_FETCHTOOL)\
937 $($(target)_TOOL)\
938 )
939flags :=\
940 $(TOOL_$(tool)_FETCHFLAGS)\
941 $(FETCHFLAGS)\
942 $($(target)_FETCHFLAGS)\
943 $($(srcname)_FETCHFLAGS)\
944 $($(source)_FETCHFLAGS)\
945 $($(target)_$(srcname)_FETCHFLAGS)\
946 $($(target)_$(source)_FETCHFLAGS)
947
948#$ (warning dbg: target=$(target) source=$(source) $(srcname)=$(srcname) tool=$(tool) out=$(out) flags=$(flags) dirdep=$(dirdep) fetchdir=$(fetchdir) md5=$(md5) size=$(size))
949
950ifndef TOOL_$(tool)_FETCH_CMDS
951$(warning kBuild: tools: \
952 1 $($(target)_$(source)_FETCHTOOL)\
953 2 $($(target)_$(srcname)_FETCHTOOL)\
954 3 $($(target)_$(source)_TOOL)\
955 4 $($(target)_$(srcname)_TOOL)\
956 5 $($(source)_FETCHTOOL)\
957 6 $($(srcname)_FETCHTOOL)\
958 7 $($(source)_TOOL)\
959 8 $($(srcname)_TOOL)\
960 9 $($(target)_FETCHTOOL)\
961 10 $($(target)_TOOL) )
962$(error kBuild: TOOL_$(tool)_FETCH_CMDS is not defined. source=$(source) target=$(target) )
963endif
964
965# call the tool
966$(target)_$(srcname)_FETCH_CMDS_ := $(TOOL_$(tool)_FETCH_CMDS)
967$(target)_$(srcname)_FETCH_OUTPUT_ := $(TOOL_$(tool)_FETCH_OUTPUT)
968$(target)_$(srcname)_FETCH_DEPEND_ := $(TOOL_$(tool)_FETCH_DEPEND) $(deps)
969$(target)_$(srcname)_FETCH_DEPORD_ := $(TOOL_$(tool)_FETCH_DEPORD) $(dirdep) $(orderdeps)
970
971# generate the fetch rule.
972$(eval $(def_fetch_src_fetch_rule))
973
974
975#
976# The unpacking / installing.
977#
978out := $(inst)_kBuild_$(target)_$(srcname)_unpacked.lst
979dirdep := $(call DIRDEP,$(inst))
980tool := $(firstword \
981 $($(target)_$(source)_UNPACKTOOL)\
982 $($(target)_$(srcname)_UNPACKTOOL)\
983 $($(target)_$(source)_TOOL)\
984 $($(target)_$(srcname)_TOOL)\
985 $($(source)_UNPACKTOOL)\
986 $($(srcname)_UNPACKTOOL)\
987 $($(source)_TOOL)\
988 $($(srcname)_TOOL)\
989 $($(target)_UNPACKTOOL)\
990 $($(target)_TOOL) \
991 )
992ifeq ($(tool),)
993tool := $(toupper $(subst .,,$(suffix $(subst tar.,TAR,$(srcname)))))
994$(eval $(value def_tools_include))
995endif
996flags :=\
997 $(TOOL_$(tool)_UNPACKFLAGS)\
998 $(UNPACKFLAGS)\
999 $($(target)_UNPACKFLAGS)\
1000 $($(srcname)_UNPACKFLAGS)\
1001 $($(source)_UNPACKFLAGS)\
1002 $($(target)_$(srcname)_UNPACKFLAGS)\
1003 $($(target)_$(source)_UNPACKFLAGS)
1004
1005#$ (warning dbg: target=$(target) source=$(source) $(srcname)=$(srcname) tool=$(tool) out=$(out) flags=$(flags) dirdep=$(dirdep) inst=$(inst) md5=$(md5) size=$(size))
1006ifndef TOOL_$(tool)_UNPACK_CMDS
1007$(warning kBuild: tools: \
1008 1 $($(target)_$(source)_UNPACKTOOL)\
1009 2 $($(target)_$(srcname)_UNPACKTOOL)\
1010 3 $($(target)_$(source)_TOOL)\
1011 4 $($(target)_$(srcname)_TOOL)\
1012 5 $($(source)_UNPACKTOOL)\
1013 6 $($(srcname)_UNPACKTOOL)\
1014 7 $($(source)_TOOL)\
1015 8 $($(srcname)_TOOL)\
1016 9 $($(target)_UNPACKTOOL)\
1017 10 $($(target)_TOOL) \
1018 11 $(toupper $(subst tar.,TAR,$(ext $(srcname)))) \
1019 )
1020$(error kBuild: TOOL_$(tool)_UNPACK_CMDS is not defined. source=$(source) target=$(target) )
1021endif
1022
1023# call the tool
1024$(target)_$(srcname)_UNPACK_CMDS_ := $(TOOL_$(tool)_UNPACK_CMDS)
1025$(target)_$(srcname)_UNPACK_OUTPUT_ := $(TOOL_$(tool)_UNPACK_OUTPUT)
1026$(target)_$(srcname)_UNPACK_DEPEND_ := $(TOOL_$(tool)_UNPACK_DEPEND) $(deps)
1027$(target)_$(srcname)_UNPACK_DEPORD_ := $(TOOL_$(tool)_UNPACK_DEPORD) $(dirdep) $(orderdeps)
1028
1029# generate the fetch rule.
1030$(eval $(def_fetch_src_unpack_rule))
1031
1032_DIRS += $(inst) $(fetchdir)
1033
1034endef
1035
1036
1037##
1038# Define the target level rules for a fetch.
1039# @param target
1040# @param out
1041# @param inst
1042# @param _TARGET_$(target)_UNPACKED
1043# @param _TARGET_$(target)_DIGEST
1044# @param bld_trg
1045# @param bld_trg_arch
1046define def_fetch_rules
1047
1048$(out).lst: $(_TARGET_$(target)_UNPACKED) | $(call DIRDEP,$(inst))
1049 $$(call MSG_FETCH_OK,$(target))
1050 $$(QUIET)$$(RM) -f $$@ $$@.tmp
1051 $$(QUIET2)$$(APPEND) $$@.tmp "$(notdir $(out))"
1052 $$(QUIET)$(if $(_TARGET_$(target)_UNPACKED),$$(CAT_EXT) $(_TARGET_$(target)_UNPACKED) >> $$@.tmp)
1053 $$(QUIET)$$(MV) -f $$@.tmp $$@
1054
1055$(out)_unfetched:
1056 $$(call MSG_UNFETCH,$(target))
1057 $$(QUIET)$$(RM) -f $$(addprefix $(inst),$$(shell $$(CAT_EXT) $(out).lst 2> /dev/null | $$(SED) -e '/\/$$$$/d'))
1058 $$(QUIET)$$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist $$(dir $$@) \
1059 $$(addprefix $(inst),$$(sort $$(dir $$(shell $$(CAT_EXT) $(out).lst 2> /dev/null))))
1060 $$(QUIET)$$(RM) -f $(out).lst $(out)
1061 $$(QUIET)$$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist $$(dir $$@)
1062
1063$(out): $(comp-vars _TARGET_$(target)_DIGEST_PREV,_TARGET_$(target)_DIGEST,FORCE) | $(call DIRDEP,$(inst))
1064 $$(QUIET)$$(RM) -f $$@
1065 $$(if $$(_TARGET_$(target)_DIGEST),$$(if $$(wildcard $(out).lst)\
1066 ,$$(call MSG_REFETCH,$(target)),$$(call MSG_FETCH,$(target))),$$(call MSG_UNFETCH,$(target)))
1067 $$(QUIET)$$(if $$(wildcard $(out).lst ),$$(MAKE) -f $(MAKEFILE) --no-print-directory $(out)_unfetched)
1068 $$(QUIET)$$(if $$(_TARGET_$(target)_DIGEST),$$(MAKE) -f $(MAKEFILE) --no-print-directory $(out).lst,$$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist $$(dir $$@))
1069 $$(QUIET2)$$(if $$(_TARGET_$(target)_DIGEST),$$(APPEND) $$@ "_TARGET_$(target)_DIGEST_PREV := $(_TARGET_$(target)_DIGEST)")
1070
1071.NOTPARALLEL: $(out).lst $(out)_unfetched $(out)
1072
1073endef
1074
1075
1076##
1077# Deal with one fetch target.
1078# @param target
1079# @param bld_trg
1080# @param bld_trg_arch
1081define def_fetch
1082# common
1083INSTARGET_$(target) := $($(target)_INST)
1084ifneq ($(patsubst %/,ok,$(INSTARGET_$(target))),ok)
1085$(error kBuild: Bad or missing INST property for target '$(target)'. \
1086 $(target)_INST='$($(target)_INST)' ($(origin $(target)_INST)))
1087endif
1088_TARGET_$(target)_FETCHED :=
1089_TARGET_$(target)_UNPACKED :=
1090_TARGET_$(target)_DIGEST :=
1091
1092# The 'sources'.
1093#$ (warning dbg fetch: target=$(target) sources=$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TYPE)) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TARGET_ARCH)) $($(target)_SOURCES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)))
1094$(foreach source,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TYPE)) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TARGET_ARCH)) $($(target)_SOURCES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),\
1095 $(eval $(value def_fetch_src)))
1096
1097# The target.
1098inst := $(INSTARGET_$(target))
1099out := $(inst)_kBuild_fetch_$(target)
1100
1101$(eval includedep $(out))
1102
1103$(eval $(def_fetch_rules))
1104
1105# Define the aliases here (doesn't work if defined in def_fetch_rules, just like includedep).
1106$(target): $(out)
1107$(target)_unfetch: $(out)_unfetched
1108
1109_FETCHES += $(out)
1110_DOWNLOADS += $(_TARGET_$(target)_FETCHED)
1111_UNPACKS += $(_TARGET_$(target)_UNPACKED)
1112_UNFETCHES += $(out)_unfetched
1113_DIRS += $(inst)
1114
1115endef
1116
1117# Walk the FETCH target lists.
1118bld_trg := $(BUILD_TARGET)
1119bld_trg_arch := $(BUILD_TARGET_ARCH)
1120$(foreach target, $(FETCHES) $(FETCHES.$(BUILD_TARGET)) $(FETCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
1121 $(eval $(value def_fetch)))
1122
1123# some aliases.
1124download: $(_DOWNLOADS)
1125unpack: $(_UNPACKS)
1126fetch: $(_FETCHES)
1127unfetch: $(_UNFETCHES)
1128
1129
1130
1131##
1132## Patching.
1133##
1134##
1135#define def_patch_src
1136#
1137#endef
1138#
1139#
1140## Deal with one patch target.
1141#define def_patch
1142#
1143#$(foreach source,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TYPE)) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TARGET_ARCH)) $($(target)_SOURCES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),\
1144# $(eval $(value def_patch_src)))
1145#
1146#_PATCHES +=
1147#endef
1148#
1149#$(foreach target, $(PATCHES) $(PATCHES.$(BUILD_TARGET)) $(PATCHES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
1150# $(eval $(value def_patch)))
1151#
1152
1153
1154#
1155# Object processing.
1156#
1157
1158## wrapper the compile command dependency check.
1159ifndef NO_COMPILE_CMDS_DEPS
1160 _DEP_COMPILE_CMDS = $(comp-cmds $(target)_$(source)_CMDS_PREV_,$(target)_$(source)_CMDS_,FORCE)
1161else
1162 _DEP_COMPILE_CMDS =
1163endif
1164
1165## Generates the rules for building a specific object, and the aliases
1166# for building a source file.
1167# @param $(obj) The object file.
1168define def_target_source_rule
1169$(obj) $($(target)_$(source)_OUTPUT_): \
1170 $($(target)_$(source)_DEPEND_) \
1171 $(_DEP_COMPILE_CMDS) \
1172 | \
1173 $($(target)_$(source)_DEPORD_)
1174 $$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
1175 $$(QUIET)$$(RM) -f $(dep) $(obj) $($(target)_$(source)_OUTPUT_)
1176 $(custom_pre)
1177
1178$($(target)_$(source)_CMDS_)
1179
1180 $(custom_post)
1181ifndef NO_COMPILE_CMDS_DEPS
1182 $$(QUIET2)$$(APPEND) "$(dep)"
1183 $$(QUIET2)$$(APPEND) "$(dep)" 'define $(target)_$(source)_CMDS_PREV_'
1184ifeq ($(filter append-dash-n,$(KMK_FEATURES)),append-dash-n)
1185 $$(QUIET2)$$(APPEND) -v "$(dep)" '$(target)_$(source)_CMDS_'
1186else
1187 $$(QUIET2)$$(APPEND) "$(dep)" '$(subst $(NL),'$(NL)$(TAB)@$(APPEND) "$(dep)" ',$($(target)_$(source)_CMDS_))'
1188endif
1189 $$(QUIET2)$$(APPEND) "$(dep)" 'endef'
1190endif
1191
1192$(basename $(notdir $(obj))).o: $(obj)
1193$(basename $(notdir $(obj))).obj: $(obj)
1194endef
1195
1196
1197## wrapper the link command dependency check.
1198ifndef NO_COMPILE_CMDS_DEPS
1199 _DEP_LINK_CMDS = $(comp-cmds $(target)_CMDS_PREV_,$(target)_CMDS_,FORCE)
1200else
1201 _DEP_LINK_CMDS =
1202endif
1203
1204## Generate the link rule for a target.
1205# @param $(target) The normalized target name.
1206# @param $(dirdep) Directories we depend upon begin created before linking.
1207# @param $(dep) The name of the dependency file.
1208# @param $(out)
1209# @param $($(target)_OUTPUT_) Output files from the link.
1210# @param $($(target)_DEPEND_) Dependencies.
1211# @param $($(target)_DEPORD_) Dependencies which should only affect build order.
1212# @param $($(target)_CMDS_) The link commands.
1213# @param $($(target)_CMDS_PREV_) The link commands from the previous run.
1214define def_link_rule
1215$(out) $($(target)_OUTPUT_): \
1216 $($(target)_DEPEND_) \
1217 $(_DEP_LINK_CMDS) \
1218 | \
1219 $($(target)_DEPORD_)
1220 $$(call MSG_LINK,$(target),$$@,$(tool_do))
1221 $$(QUIET)$$(RM) -f $(dep) $(out) $($(target)_OUTPUT_)
1222 $(custom_pre)
1223
1224$($(target)_CMDS_)
1225
1226 $(custom_post)
1227ifndef NO_LINK_CMDS_DEPS
1228 $$(QUIET2)$$(APPEND) "$(dep)" 'define $(target)_CMDS_PREV_'
1229ifeq ($(filter append-dash-n,$(KMK_FEATURES)),append-dash-n)
1230 $$(QUIET2)$$(APPEND) -v "$(dep)" '$(target)_CMDS_'
1231else
1232 $$(QUIET2)$$(APPEND) "$(dep)" '$(subst $(NL),'$(NL)$(TAB)@$(APPEND) "$(dep)" ',$($(target)_CMDS_))'
1233endif
1234 $$(QUIET2)$$(APPEND) "$(dep)" 'endef'
1235endif
1236
1237$(basename $(notdir $(out))): $(out)
1238
1239endef
1240
1241
1242## Generate the link & lib install rule
1243# @param $(target) Normalized target name.
1244# @param $(out) The build target.
1245# @param $(INSTARGET_$(target)) The installation targets.
1246# @param $(mode) The file mode (optional)
1247define def_link_install_rule
1248$(INSTARGET_$(target)) : $(out) | $(call DIRDEP,$(dir $(INSTARGET_$(target))))
1249 $$(call MSG_INST_TRG,$(target),$(out),$$@)
1250 $$(QUIET)$$(INSTALL) $$(if $(mode),-m $(mode)) $(out) $$@
1251
1252ifdef KBUILD_DO_AUTO_INSTALL
1253$(basename $(notdir $(out))): $(INSTARGET_$(target))
1254endif
1255endef
1256
1257
1258## Generic macro for processing C, C++ and Assembly sources.
1259# @param $(target) Normalized target name.
1260# @param $(source) Source file name.
1261# @param $(type) Source type. {C,CXX,AS}
1262# @param bld_type Build type.
1263# @param bld_trg Build target.
1264# @param bld_trg_arch Build target arch.
1265# @param bld_trg_cpu Build target cpu.
1266def_target_source_c_cpp_asm_rc_new = $(kb-src-one )
1267ifdef KMK_VERSION
1268 def_target_source_c_cpp_asm_rc_var = def_target_source_c_cpp_asm_rc_new
1269else
1270 def_target_source_c_cpp_asm_rc_var = def_target_source_c_cpp_asm_rc_old
1271endif
1272
1273## Generic macro for processing all target sources.
1274# @param $(target) Normalized target name.
1275# @param $(defpath)
1276# @param much-more...
1277define def_target_sources
1278#$ (warning def_target_sources)
1279# C sources
1280type := C
1281$(foreach source, $(filter %.c , $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\
1282 ,$(eval $(value $(def_target_source_c_cpp_asm_rc_var))) )
1283
1284# C++ sources
1285type := CXX
1286$(foreach source, $(filter %.cpp %.cxx %.xx, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\
1287 ,$(eval $(value $(def_target_source_c_cpp_asm_rc_var))) )
1288
1289# ASM sources
1290type := AS
1291$(foreach source, $(filter %.asm %.s %.S , $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\
1292 ,$(eval $(value $(def_target_source_c_cpp_asm_rc_var))) )
1293
1294# Resource sources
1295type := RC
1296$(foreach source, $(filter %.rc , $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\
1297 ,$(eval $(value $(def_target_source_c_cpp_asm_rc_var))) )
1298
1299endef
1300
1301
1302
1303## Generic macro for generating the install rule(s) for a target
1304# and update the globals with default out.
1305#
1306# @param $(target) Normalized target name.
1307# @param $(out) The output file.
1308# @param $(definst) The default _INST value.
1309# @param $(typevar) The name of the variable with all the root targets of its type.
1310# @remark Only library uses this now.
1311define def_target_install_pluss
1312ifndef $(target)_NOINST
1313INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
1314 $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
1315
1316$(eval $(def_link_install_rule))
1317
1318_INSTALLS_FILES += $(INSTARGET_$(target))
1319
1320ifdef KBUILD_DO_AUTO_INSTALL
1321$(typevar) += $(INSTARGET_$(target))
1322else
1323$(typevar) += $(out)
1324endif
1325else # _NOINST
1326$(typevar) += $(out)
1327endif
1328
1329_OUT_FILES += $($(target)_OUTPUT_) $(out)
1330_CLEAN_FILES += $($(target)_CLEAN)
1331_OBJS += $($(target)_OBJS_)
1332
1333endef
1334
1335
1336
1337#
1338# LIBRARIES
1339#
1340
1341## Library (one).
1342# @param $(target) Normalized library (target) name.
1343define def_lib
1344# library basics
1345## @todo prefix
1346bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
1347bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))
1348bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
1349bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU))
1350tool := $(call _TARGET_TOOL,$(target),AR)
1351ifeq ($(tool),)
1352$(error kBuild: Library target $(target) does not have a tool defined!)
1353endif
1354outbase := $(call TARGET_BASE,$(target),$(target))
1355ifndef PATH_$(target)
1356 PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
1357else
1358 ifneq ($(PATH_$(target)),$(patsubst %/,%,$(dir $(outbase))))
1359 $(error kBuild internal error: PATH_$(target)=$(PATH_$(target)) expected $(patsubst %/,%,$(dir $(outbase))))
1360 endif
1361endif
1362suff := $(firstword\
1363 $($(target)_LIBSUFF.$(bld_trg).$(bld_trg_arch))\
1364 $($(target)_LIBSUFF.$(bld_trg))\
1365 $($(target)_LIBSUFF)\
1366 $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg).$(bld_trg_arch))\
1367 $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg))\
1368 $(TOOL_$(tool)_ARLIBSUFF)\
1369 $(SUFF_LIB))
1370out := $(outbase)$(suff)
1371TARGET_$(target) := $(out)
1372$(target)_OBJS_ :=
1373defpath := $($(target)_PATH)
1374
1375# source -> object
1376$(eval $(value def_target_sources))
1377
1378# library linking
1379tool := $(call _TARGET_TOOL,$(target),AR)
1380outbase := $(call TARGET_BASE,$(target),$(target))
1381flags :=\
1382 $(TOOL_$(tool)_ARFLAGS)\
1383 $(TOOL_$(tool)_ARFLAGS.$(bld_type))\
1384 $(ARFLAGS)\
1385 $(ARFLAGS.$(bld_type))\
1386 $($(target)_ARFLAGS)\
1387 $($(target)_ARFLAGS.$(bld_type)) \
1388 $($(target)_ARFLAGS.$(bld_trg)) \
1389 $($(target)_ARFLAGS.$(bld_trg_arch)) \
1390 $($(target)_ARFLAGS.$(bld_trg).$(bld_trg_arch)) \
1391 $($(target)_ARFLAGS.$(bld_trg_cpu))
1392othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,\
1393 $($(target)_SOURCES) \
1394 $($(target)_SOURCES.$(bld_trg)) \
1395 $($(target)_SOURCES.$(bld_trg_arch)) \
1396 $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
1397 $($(target)_SOURCES.$(bld_trg_cpu)) \
1398 $($(target)_SOURCES.$(bld_type)))
1399objs = $(filter %.o %.obj, \
1400 $($(target)_SOURCES) \
1401 $($(target)_SOURCES.$(bld_trg)) \
1402 $($(target)_SOURCES.$(bld_trg_arch)) \
1403 $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
1404 $($(target)_SOURCES.$(bld_trg_cpu)) \
1405 $($(target)_SOURCES.$(bld_type))) \
1406 $($(target)_OBJS_)
1407dirdep := $(call DIRDEP,$(dir $(out)))
1408deps := $($(target)_DEPS)
1409orderdeps := $($(target)_ORDERDEPS)
1410
1411# Adjust paths if we got a default path.
1412ifneq ($(defpath),)
1413 objs := $(call abspathex,$(objs),$(defpath))
1414 deps := $(call abspathex,$(deps),$(defpath))
1415 orderdeps := $(call abspathex,$(orderdeps),$(defpath))
1416 othersrc := $(call abspathex,$(othersrc),$(defpath))
1417endif
1418
1419# dependency file
1420dep := $(out)$(SUFF_DEP)
1421ifndef NO_LINK_CMDS_DEPS
1422_DEPFILES_INCLUDED += $(dep)
1423$(if $(wildcard $(dep)),$(eval include $(dep)))
1424endif
1425
1426# check that the tool is defined.
1427ifndef TOOL_$(tool)_LINK_LIBRARY_CMDS
1428$(warning kBuild: tools: \
1429 1 $($(target)_$(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
1430 2 $($(target)_$(source)TOOL.$(bld_trg)) \
1431 3 $($(target)_$(source)TOOL) \
1432 4 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
1433 5 $($(target)_TOOL.$(bld_trg)) \
1434 6 $($(target)_TOOL) \
1435 7 $($(source)TOOL) \
1436 8 $($(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
1437 9 $($(source)TOOL.$(bld_trg)) \
1438 10 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
1439 11 $(TOOL.$(bld_trg)) \
1440 12 $(TOOL) )
1441$(error kBuild: TOOL_$(tool)_LINK_LIBRARY_CMDS isn't defined! target=$(target) )
1442endif
1443
1444# call the tool
1445$(target)_CMDS_ := $(TOOL_$(tool)_LINK_LIBRARY_CMDS)
1446$(target)_OUTPUT_ := $(TOOL_$(tool)_LINK_LIBRARY_OUTPUT)
1447$(target)_DEPEND_ := $(TOOL_$(tool)_LINK_LIBRARY_DEPEND) $(deps) $(objs)
1448$(target)_DEPORD_ := $(TOOL_$(tool)_LINK_LIBRARY_DEPORD) $(dirdep) $(orderdeps)
1449
1450# generate the link rule.
1451$(eval $(def_link_rule))
1452
1453# installing and globals
1454definst := $(PATH_LIB)
1455typevar := _LIBS
1456$(eval $(value def_target_install_pluss))
1457endef
1458
1459# Process libraries
1460tool_do := LINK_LIBRARY
1461mode := 0644
1462$(foreach target, $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) $(LIBRARIES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_lib)))
1463
1464
1465#
1466# Link operations.
1467#
1468
1469##
1470# Link prolog
1471#
1472# @param $(target) Normalized target name.
1473# @param $(EXT) EXE,DLL,SYS.
1474# @param $(definst) The default _INST value.
1475# @param $(typevar) The name of the variable with all the root targets of its type.
1476define def_link_common
1477# basics
1478bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
1479bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var)))
1480bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH))
1481bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU))
1482
1483tool := $(call _TARGET_TOOL,$(target),LD)
1484outbase := $(call TARGET_BASE,$(target),$(target))
1485ifndef PATH_$(target)
1486 PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
1487else
1488 ifneq ($(PATH_$(target)),$(patsubst %/,%,$(dir $(outbase))))
1489 $(error kBuild internal error: PATH_$(target)=$(PATH_$(target)) expected $(patsubst %/,%,$(dir $(outbase))))
1490 endif
1491endif
1492suff := $(firstword \
1493 $($(target)_$(EXT)SUFF) \
1494 $($(target)_$(EXT)SUFF) \
1495 $(TOOL_$(tool)_LD$(EXT)SUFF) \
1496 $($(EXTPRE)SUFF_$(EXT)))
1497out := $(outbase)$(suff)
1498TARGET_$(target) := $(out)
1499$(target)_OBJS_ :=
1500defpath := $($(target)_PATH)
1501
1502# source -> object
1503$(eval $(value def_target_sources))
1504
1505# more link stuff.
1506tool := $(call _TARGET_TOOL,$(target),LD)
1507outbase := $(call TARGET_BASE,$(target),$(target))
1508flags :=\
1509 $(TOOL_$(tool)_LDFLAGS)\
1510 $(TOOL_$(tool)_LDFLAGS.$(bld_type))\
1511 $(TOOL_$(tool)_LDFLAGS.$(bld_trg))\
1512 $(TOOL_$(tool)_LDFLAGS.$(bld_trg_arch))\
1513 $(TOOL_$(tool)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
1514 $(TOOL_$(tool)_LDFLAGS.$(bld_trg_cpu))\
1515 $(LDFLAGS)\
1516 $(LDFLAGS.$(bld_type))\
1517 $(LDFLAGS.$(bld_trg))\
1518 $(LDFLAGS.$(bld_trg_arch))\
1519 $(LDFLAGS.$(bld_trg).$(bld_trg_arch))\
1520 $(LDFLAGS.$(bld_trg_cpu))\
1521 $($(target)_LDFLAGS)\
1522 $($(target)_LDFLAGS.$(bld_type))\
1523 $($(target)_LDFLAGS.$(bld_trg))\
1524 $($(target)_LDFLAGS.$(bld_trg_arch))\
1525 $($(target)_LDFLAGS.$(bld_trg).$(bld_trg_arch))\
1526 $($(target)_LDFLAGS.$(bld_trg_cpu))
1527othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,\
1528 $($(target)_SOURCES)\
1529 $($(target)_SOURCES.$(bld_trg)) \
1530 $($(target)_SOURCES.$(bld_trg_arch)) \
1531 $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
1532 $($(target)_SOURCES.$(bld_trg_cpu)) \
1533 $($(target)_SOURCES.$(bld_type)))
1534objs = $(filter %.o %.obj, \
1535 $($(target)_SOURCES) \
1536 $($(target)_SOURCES.$(bld_trg)) \
1537 $($(target)_SOURCES.$(bld_trg_arch)) \
1538 $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) \
1539 $($(target)_SOURCES.$(bld_trg_cpu)) \
1540 $($(target)_SOURCES.$(bld_type))) \
1541 $($(target)_OBJS_)
1542libs :=\
1543 $($(target)_LIBS.$(bld_trg_cpu))\
1544 $($(target)_LIBS.$(bld_trg).$(bld_trg_arch))\
1545 $($(target)_LIBS.$(bld_trg_arch))\
1546 $($(target)_LIBS.$(bld_trg))\
1547 $($(target)_LIBS.$(bld_type))\
1548 $($(target)_LIBS)\
1549 $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
1550 $($(target)_SDKS.$(bld_trg_arch)) \
1551 $($(target)_SDKS.$(bld_trg)) \
1552 $($(target)_SDKS.$(bld_type)) \
1553 $($(target)_SDKS),\
1554 $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
1555 $(SDK_$(sdk)_LIBS.$(bld_trg).$(bld_trg_arch))\
1556 $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
1557 $(SDK_$(sdk)_LIBS.$(bld_trg))\
1558 $(SDK_$(sdk)_LIBS.$(bld_type))\
1559 $(SDK_$(sdk)_LIBS))\
1560 $(LIBS.$(bld_trg_cpu))\
1561 $(LIBS.$(bld_trg).$(bld_trg_arch))\
1562 $(LIBS.$(bld_trg_arch))\
1563 $(LIBS.$(bld_trg))\
1564 $(LIBS.$(bld_type))\
1565 $(LIBS)\
1566 $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
1567 $(SDKS.$(bld_trg_arch)) \
1568 $(SDKS.$(bld_trg)) \
1569 $(SDKS.$(bld_type)) \
1570 $(SDKS),\
1571 $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
1572 $(SDK_$(sdk)_LIBS.$(bld_trg).$(bld_trg_arch))\
1573 $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
1574 $(SDK_$(sdk)_LIBS.$(bld_trg))\
1575 $(SDK_$(sdk)_LIBS.$(bld_type))\
1576 $(SDK_$(sdk)_LIBS))\
1577 $(TOOL_$(tool)_LIBS.$(bld_trg_cpu))\
1578 $(TOOL_$(tool)_LIBS.$(bld_trg).$(bld_trg_arch))\
1579 $(TOOL_$(tool)_LIBS.$(bld_trg_arch))\
1580 $(TOOL_$(tool)_LIBS.$(bld_trg))\
1581 $(TOOL_$(tool)_LIBS.$(bld_type))\
1582 $(TOOL_$(tool)_LIBS)
1583libpath :=\
1584 $($(target)_LIBPATH.$(bld_trg_cpu))\
1585 $($(target)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
1586 $($(target)_LIBPATH.$(bld_trg_arch))\
1587 $($(target)_LIBPATH.$(bld_trg))\
1588 $($(target)_LIBPATH.$(bld_type))\
1589 $($(target)_LIBPATH)\
1590 $(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
1591 $($(target)_SDKS.$(bld_trg_arch)) \
1592 $($(target)_SDKS.$(bld_trg)) \
1593 $($(target)_SDKS.$(bld_type)) \
1594 $($(target)_SDKS),\
1595 $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
1596 $(SDK_$(sdk)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
1597 $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
1598 $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
1599 $(SDK_$(sdk)_LIBPATH.$(bld_type))\
1600 $(SDK_$(sdk)_LIBPATH))\
1601 $(LIBPATH.$(bld_trg_cpu))\
1602 $(LIBPATH.$(bld_trg).$(bld_trg_arch))\
1603 $(LIBPATH.$(bld_trg_arch))\
1604 $(LIBPATH.$(bld_trg))\
1605 $(LIBPATH.$(bld_type))\
1606 $(LIBPATH)\
1607 $(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
1608 $(SDKS.$(bld_trg_arch)) \
1609 $(SDKS.$(bld_trg)) \
1610 $(SDKS.$(bld_type)) \
1611 $(SDKS),\
1612 $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
1613 $(SDK_$(sdk)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
1614 $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
1615 $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
1616 $(SDK_$(sdk)_LIBPATH.$(bld_type))\
1617 $(SDK_$(sdk)_LIBPATH))\
1618 $(TOOL_$(tool)_LIBPATH.$(bld_trg_cpu))\
1619 $(TOOL_$(tool)_LIBPATH.$(bld_trg).$(bld_trg_arch))\
1620 $(TOOL_$(tool)_LIBPATH.$(bld_trg_arch))\
1621 $(TOOL_$(tool)_LIBPATH.$(bld_trg))\
1622 $(TOOL_$(tool)_LIBPATH.$(bld_type))\
1623 $(TOOL_$(tool)_LIBPATH)
1624dirdep := $(call DIRDEP,$(dir $(out)))
1625deps := $($(target)_DEPS)
1626orderdeps := $($(target)_ORDERDEPS)
1627
1628# Adjust paths if we got a default path.
1629ifneq ($(defpath),)
1630 libpath := $(call abspathex,$(libpath),$(defpath))
1631 objs := $(call abspathex,$(objs),$(defpath))
1632 deps := $(call abspathex,$(deps),$(defpath))
1633 orderdeps := $(call abspathex,$(orderdeps),$(defpath))
1634 othersrc := $(call abspathex,$(othersrc),$(defpath))
1635 # libs are not subject to this because of the the -l<lib> stuff. Use $(<target>_PATH)/lib if relative to current dir!
1636endif
1637
1638## @todo this stuff can't be working.
1639custom_pre := $(strip $(firstword \
1640 $($(target)_CUSTOM_PRE.$(bld_trg).$(bld_trg_arch))\
1641 $($(target)_CUSTOM_PRE.$(bld_trg).$(bld_type))\
1642 $($(target)_CUSTOM_PRE.$(bld_trg))\
1643 $($(target)_CUSTOM_PRE.$(bld_type))\
1644 $($(target)_CUSTOM_PRE)\
1645 $(CUSTOM_PRE.$(bld_trg).$(bld_trg_arch))\
1646 $(CUSTOM_PRE.$(bld_trg).$(bld_type))\
1647 $(CUSTOM_PRE.$(bld_trg))\
1648 $(CUSTOM_PRE.$(bld_type))\
1649 $(CUSTOM_PRE)\
1650))
1651custom_post := $(strip $(firstword \
1652 $($(target)_CUSTOM_POST.$(bld_trg).$(bld_trg_arch))\
1653 $($(target)_CUSTOM_POST.$(bld_trg).$(bld_type))\
1654 $($(target)_CUSTOM_POST.$(bld_trg))\
1655 $($(target)_CUSTOM_POST.$(bld_type))\
1656 $($(target)_CUSTOM_POST)\
1657 $(CUSTOM_POST.$(bld_trg).$(bld_trg_arch))\
1658 $(CUSTOM_POST.$(bld_trg).$(bld_type))\
1659 $(CUSTOM_POST.$(bld_trg))\
1660 $(CUSTOM_POST.$(bld_type))\
1661 $(CUSTOM_POST)\
1662))
1663
1664# installation targets
1665ifndef $(target)_NOINST
1666INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
1667 $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
1668ifdef KBUILD_DO_AUTO_INSTALL
1669$(typevar) += $(INSTARGET_$(target))
1670else
1671$(typevar) += $(out)
1672endif
1673# generate the install rule
1674$(eval $(def_link_install_rule))
1675
1676else # NOINST
1677INSTARGET_$(target) :=
1678$(typevar) += $(out)
1679endif # NOINST
1680
1681# dependency file
1682dep := $(outbase)$(SUFF_DEP)
1683ifndef NO_LINK_CMDS_DEPS
1684_DEPFILES_INCLUDED += $(dep)
1685$(if $(wildcard $(dep)),$(eval include $(dep)))
1686endif
1687
1688# check that the tool is defined.
1689ifndef TOOL_$(tool)_$(tool_do)_CMDS
1690$(warning kBuild: tools: \
1691 1 $($(target)_$(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
1692 2 $($(target)_$(source)TOOL.$(bld_trg)) \
1693 3 $($(target)_$(source)TOOL) \
1694 4 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
1695 5 $($(target)_TOOL.$(bld_trg)) \
1696 6 $($(target)_TOOL) \
1697 7 $($(source)TOOL.$(bld_trg).$(bld_trg_arch)) \
1698 8 $($(source)TOOL.$(bld_trg)) \
1699 9 $($(source)TOOL) \
1700 10 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
1701 11 $(TOOL.$(bld_trg)) \
1702 12 $(TOOL) )
1703$(error kBuild: TOOL_$(tool)_$(tool_do)_CMDS isn't defined! target=$(target) )
1704endif
1705
1706# call the tool
1707$(target)_CMDS_ := $(TOOL_$(tool)_$(tool_do)_CMDS)
1708$(target)_OUTPUT_ := $(TOOL_$(tool)_$(tool_do)_OUTPUT)
1709$(target)_DEPEND_ := $(TOOL_$(tool)_$(tool_do)_DEPEND) $(deps) $(objs)
1710$(target)_DEPORD_ := $(TOOL_$(tool)_$(tool_do)_DEPORD) $(dirdep) $(orderdeps)
1711
1712# generate the link rule.
1713$(eval $(def_link_rule))
1714
1715
1716# Update globals.
1717_OBJS += $($(target)_OBJS_)
1718_OUT_FILES += $($(target)_OUTPUT_) $(out)
1719_CLEAN_FILES += $($(target)_CLEAN)
1720_INSTALLS_FILES += $(INSTARGET_$(target))
1721
1722endef
1723
1724
1725#
1726# BLDPROGS
1727#
1728
1729## Build program (one).
1730# @param $(target) Normalized target (program) name.
1731define def_bldprog
1732
1733# set NOINST if not forced installation.
1734ifndef $(target)_INST
1735$(target)_NOINST := 1
1736endif
1737
1738# do the usual stuff.
1739$(eval $(value def_link_common))
1740
1741endef
1742
1743# Process build programs.
1744EXT := EXE
1745EXTPRE := HOST
1746tool_do := LINK_PROGRAM
1747definst := $(PATH_BIN)
1748typevar := _BLDPROGS
1749mode := 0755
1750bld_trg_base_var := PLATFORM
1751$(foreach target, $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) $(BLDPROGS.$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)), $(eval $(value def_bldprog)))
1752
1753
1754
1755#
1756# DLLS
1757#
1758
1759# Process dlls
1760EXT := DLL
1761EXTPRE :=
1762tool_do := LINK_DLL
1763definst := $(PATH_DLL)
1764typevar := _DLLS
1765mode := 0755
1766bld_trg_base_var := TARGET
1767$(foreach target, $(DLLS) $(DLLS.$(BUILD_TARGET)) $(DLLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_link_common)))
1768
1769
1770#
1771# Process import libraries.
1772#
1773# - On OS/2 and windows these are libraries.
1774# - On other platforms they are fake DLLs.
1775ifeq ($(filter-out nt os2 win win64 win32,$(BUILD_TARGET)),)
1776$(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_lib)))
1777else
1778$(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_link_common)))
1779endif
1780$(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) $(IMPORT_LIBS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
1781 $(eval _IMPORT_LIBS += $(if $(INSTARGET_$(target)),$(INSTARGET_$(target)), $(TARGET_$(target)))))
1782
1783
1784#
1785# PROGRAMS
1786#
1787
1788# Process programs
1789EXT := EXE
1790EXTPRE :=
1791tool_do := LINK_PROGRAM
1792definst := $(PATH_BIN)
1793typevar := _PROGRAMS
1794mode := 0755
1795bld_trg_base_var := TARGET
1796$(foreach target, $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) $(PROGRAMS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_link_common)))
1797
1798
1799
1800#
1801# SYSMODS
1802#
1803
1804# Process sysmods
1805EXT := SYS
1806EXTPRE :=
1807tool_do := LINK_SYSMOD
1808definst := $(PATH_SYS)
1809typevar := _SYSMODS
1810mode := 0644
1811bld_trg_base_var := TARGET
1812$(foreach target, $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) $(SYSMODS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), $(eval $(value def_link_common)))
1813
1814
1815#
1816# OTHERS
1817#
1818_OTHERS = $(OTHERS) $(OTHERS.$(BUILD_TARGET)) $(OTHERS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH))
1819
1820
1821#
1822# INSTALLS
1823#
1824
1825## generate the install rule
1826define def_install_src_rule
1827# the install rule
1828$(insdst) : $(srcsrc) | $(call DIRDEP,$(dir $(insdst)))
1829 $$(call MSG_INST_FILE,$(srcsrc),$(insdst))
1830 $$(QUIET)$$(if $$(filter $(INSTALL),$(inscmd)),,$$(RM) -f $$@)
1831 $$(QUIET)$(inscmd)
1832endef
1833
1834## install one file
1835define def_install_src
1836
1837# deal with '=>' in the source file name.
1838srcdst := $(subst =>, ,$(src))
1839srcsrc := $(firstword $(srcdst))
1840srcdstdir := $(dir $(word 2,$(srcdst)))
1841srcdst := $(word $(words $(srcdst)),$(srcdst))
1842
1843# _INSTFUN
1844ifdef $(srcsrc)_INSTFUN
1845 instfun := $(srcsrc)_INSTFUN
1846else
1847 ifdef $(target)_INSTFUN
1848 instfun := $(target)_INSTFUN
1849 else
1850 instfun := _INSTALL_FILE
1851 endif
1852endif
1853
1854# _INST
1855ifdef $(srcsrc)_INST
1856 inst := $(patsubst %/,%,$($(srcsrc)_INST))/$(dir $(srcdstdir))
1857else
1858 ifdef $(target)_INST
1859 inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(srcdstdir))
1860 else
1861 inst := $(dir $(srcdstdir))
1862 endif
1863endif
1864
1865# calc target
1866insdst := $(call $(instfun),$(srcdst),$(target),$(inst),$(PATH_INS))
1867#$(warning instfun=$(instfun) srcdst=$(srcdst) target=$(target) inst=$(inst) => insdst=$(insdst))
1868
1869# mode, uid and gid
1870mode := $(firstword \
1871 $($(target)_$(srcsrc)_MODE.$(bld_trg).$(bld_trg_arch)) \
1872 $($(target)_$(srcsrc)_MODE.$(bld_trg)) \
1873 $($(target)_$(srcsrc)_MODE) \
1874 $($(target)_$(srcdst)_MODE.$(bld_trg).$(bld_trg_arch)) \
1875 $($(target)_$(srcdst)_MODE.$(bld_trg)) \
1876 $($(target)_$(srcdst)_MODE) \
1877 $($(srcsrc)_MODE.$(bld_trg).$(bld_trg_arch)) \
1878 $($(srcsrc)_MODE.$(bld_trg)) \
1879 $($(srcsrc)_MODE) \
1880 $($(srcdst)_MODE.$(bld_trg).$(bld_trg_arch)) \
1881 $($(srcdst)_MODE.$(bld_trg)) \
1882 $($(srcdst)_MODE) \
1883 $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \
1884 $($(target)_MODE.$(bld_trg)) \
1885 $($(target)_MODE))
1886uid := $(firstword \
1887 $($(target)_$(srcsrc)_UID.$(bld_trg).$(bld_trg_arch)) \
1888 $($(target)_$(srcsrc)_UID.$(bld_trg)) \
1889 $($(target)_$(srcsrc)_UID) \
1890 $($(target)_$(srcdst)_UID.$(bld_trg).$(bld_trg_arch)) \
1891 $($(target)_$(srcdst)_UID.$(bld_trg)) \
1892 $($(target)_$(srcdst)_UID) \
1893 $($(srcsrc)_UID.$(bld_trg).$(bld_trg_arch)) \
1894 $($(srcsrc)_UID.$(bld_trg)) \
1895 $($(srcsrc)_UID) \
1896 $($(srcdst)_UID.$(bld_trg).$(bld_trg_arch)) \
1897 $($(srcdst)_UID.$(bld_trg)) \
1898 $($(srcdst)_UID) \
1899 $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \
1900 $($(target)_UID.$(bld_trg)) \
1901 $($(target)_UID))
1902gid := $(firstword \
1903 $($(target)_$(srcsrc)_GID.$(bld_trg).$(bld_trg_arch)) \
1904 $($(target)_$(srcsrc)_GID.$(bld_trg)) \
1905 $($(target)_$(srcsrc)_GID) \
1906 $($(target)_$(srcdst)_GID.$(bld_trg).$(bld_trg_arch)) \
1907 $($(target)_$(srcdst)_GID.$(bld_trg)) \
1908 $($(target)_$(srcdst)_GID) \
1909 $($(srcsrc)_GID.$(bld_trg).$(bld_trg_arch)) \
1910 $($(srcsrc)_GID.$(bld_trg)) \
1911 $($(srcsrc)_GID) \
1912 $($(srcdst)_GID.$(bld_trg).$(bld_trg_arch)) \
1913 $($(srcdst)_GID.$(bld_trg)) \
1914 $($(srcdst)_GID) \
1915 $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \
1916 $($(target)_GID.$(bld_trg)) \
1917 $($(target)_GID))
1918
1919
1920# Adjust the source if we got a default PATH. (This must be done this late!)
1921ifdef $(target)_PATH
1922 srcsrc := $(call abspathex,$(srcsrc),$($(target)_PATH))
1923endif
1924
1925# create the command
1926ifdef $(srcsrc)_INSTALLER
1927 inscmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(insdst),$(target))
1928else
1929 ifdef $(target)_INSTALLER
1930 inscmd := $(call $(target)_INSTALLER,$(srcsrc),$(insdst),$(target))
1931 else
1932 inscmd := $$(INSTALL)\
1933 $(if $(uid),-o $(uid))\
1934 $(if $(gid),-g $(gid))\
1935 $(if $(mode),-m $(mode))\
1936 $(srcsrc) $(insdst)
1937 endif
1938endif
1939
1940# generate the rule (need double evaluation here)
1941$(eval $(def_install_src_rule))
1942
1943INSTARGET_$(target) += $(insdst)
1944endef
1945
1946
1947## generate the symlink rule
1948define def_install_symlink_rule
1949# the install rule
1950$(insdst) : | $(call DIRDEP,$(dir $(insdst)))
1951 $$(call MSG_INST_SYM,$(insdst),$(symdst))
1952 $$(QUIET)$$(RM) -f $$@
1953 $$(QUIET)$$(LN_SYMLINK) $(symdst) $(insdst)
1954endef
1955
1956## create one symlink
1957define def_install_symlink
1958
1959# deal with '=>' in the source file name.
1960symdst := $(subst =>, ,$(src))
1961symlnk := $(firstword $(symdst))
1962symdst := $(word $(words $(symdst)),$(symdst))
1963
1964# _INSTFUN
1965ifdef $(symlnk)_INSTFUN
1966 instfun := $(symlnk)_INSTFUN
1967else ifdef $(target)_INSTFUN
1968instfun := $(target)_INSTFUN
1969else
1970 instfun := _INSTALL_FILE
1971endif
1972
1973# _INST
1974ifdef $(symlnk)_INST
1975 inst := $(patsubst %/,%,$($(symlnk)_INST))/$(dir $(symlnk))
1976else ifdef $(target)_INST
1977 inst := $(patsubst %/,%,$($(target)_INST))/$(dir $(symlnk))
1978else
1979 inst := $(dir $(symlnk))
1980endif
1981
1982# calc target
1983insdst := $(call $(instfun),$(symlnk),$(target),$(inst),$(PATH_INS))
1984#$(warning symlnk=$(symlnk) symdst=$(symdst) insdst=$(insdst) instfun=$(instfun) inst='$(inst)')
1985
1986# generate the rule (need double evaluation here)
1987$(eval $(def_install_symlink_rule))
1988
1989INSTARGET_$(target) += $(insdst)
1990endef
1991
1992
1993## generate the install rule
1994define def_install_directory_rule
1995# the install rule
1996$(insdst):
1997 $$(call MSG_INST_DIR,$(insdst))
1998 $$(QUIET)$$(INSTALL) -d \
1999 $(if $(uid),-o $(uid))\
2000 $(if $(gid),-g $(gid))\
2001 $(if $(mode),-m $(mode))\
2002 $(insdst)
2003
2004.NOTPARALLEL: $(insdst)
2005endef
2006
2007
2008## create one directory
2009define def_install_directory
2010
2011# _INST
2012ifdef $(directory)_INST
2013 inst := $(PATH_INS)/$(patsubst %/,%,$($(directory)_INST))
2014else ifdef $(target)_INST
2015 inst := $(PATH_INS)/$(patsubst %/,%,$($(target)_INST))
2016else
2017 inst := $(PATH_INS)
2018endif
2019
2020mode := $(firstword \
2021 $($(target)_$(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \
2022 $($(target)_$(directory)_MODE.$(bld_trg)) \
2023 $($(target)_$(directory)_MODE) \
2024 $($(directory)_MODE.$(bld_trg).$(bld_trg_arch)) \
2025 $($(directory)_MODE.$(bld_trg)) \
2026 $($(directory)_MODE) \
2027 $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \
2028 $($(target)_MODE.$(bld_trg)) \
2029 $($(target)_MODE))
2030uid := $(firstword \
2031 $($(target)_$(directory)_UID.$(bld_trg).$(bld_trg_arch)) \
2032 $($(target)_$(directory)_UID.$(bld_trg)) \
2033 $($(target)_$(directory)_UID) \
2034 $($(directory)_UID.$(bld_trg).$(bld_trg_arch)) \
2035 $($(directory)_UID.$(bld_trg)) \
2036 $($(directory)_UID) \
2037 $($(target)_UID.$(bld_trg).$(bld_trg_arch)) \
2038 $($(target)_UID.$(bld_trg)) \
2039 $($(target)_UID))
2040gid := $(firstword \
2041 $($(target)_$(directory)_GID.$(bld_trg).$(bld_trg_arch)) \
2042 $($(target)_$(directory)_GID.$(bld_trg)) \
2043 $($(target)_$(directory)_GID) \
2044 $($(directory)_GID.$(bld_trg).$(bld_trg_arch)) \
2045 $($(directory)_GID.$(bld_trg)) \
2046 $($(directory)_GID) \
2047 $($(target)_GID.$(bld_trg).$(bld_trg_arch)) \
2048 $($(target)_GID.$(bld_trg)) \
2049 $($(target)_GID))
2050
2051insdst := $(inst)/$(directory)/
2052#$(warning directory=$(directory) inst=$(inst) insdst=$(insdst) mode=$(mode) gid=$(gid) uid=$(uid))
2053
2054# generate the rule (need double evaluation here)
2055$(eval $(def_install_directory_rule))
2056
2057INSTARGET_DIRS_$(target) += $(insdst)
2058endef
2059
2060
2061## process one install target.
2062define def_install
2063# the basics.
2064bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
2065bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))
2066bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
2067bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU))
2068
2069INSTARGET_$(target) := $($(target)_GOALS)
2070INSTARGET_DIRS_$(target) :=
2071
2072$(foreach directory,$($(target)_DIRS) $($(target)_DIRS.$(bld_trg)) $($(target)_DIRS.$(bld_trg).$(bld_trg_arch)) $($(target)_DIRS.$(bld_trg_arch)) $($(target)_DIRS.$(bld_trg_cpu)) $($(target)_DIRS.$(bld_type)), \
2073 $(eval $(value def_install_directory)))
2074
2075$(foreach src,$($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg).$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)), \
2076 $(eval $(value def_install_src)))
2077
2078$(foreach src,$($(target)_SYMLINKS) $($(target)_SYMLINKS.$(bld_trg)) $($(target)_SYMLINKS.$(bld_trg).$(bld_trg_arch)) $($(target)_SYMLINKS.$(bld_trg_arch)) $($(target)_SYMLINKS.$(bld_trg_cpu)) $($(target)_SYMLINKS.$(bld_type)), \
2079 $(eval $(value def_install_symlink)))
2080
2081# the collection target
2082TARGET_$(target) := $(PATH_TARGET)/$(target).ins
2083$(TARGET_$(target)): $(INSTARGET_$(target)) | $(INSTARGET_DIRS_$(target))
2084 @$(QUIET2)$(APPEND) $@
2085
2086$(target): $(TARGET_$(target))
2087
2088_INSTALLS += $(TARGET_$(target))
2089_INSTALLS_FILES += $(INSTARGET_$(target))
2090_INSTALLS_DIRS += $(INSTARGET_DIRS_$(target))
2091endef
2092
2093## process all install targets
2094$(foreach target, $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) $(INSTALLS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)), \
2095 $(eval $(value def_install)))
2096
2097
2098#
2099# PACKING
2100#
2101_PACKING += $(PACKING) $(PACKING.$(BUILD_TARGET)) $(PACKING.$(BUILD_TARGET).$(BUILD_TARGET_ARCH))
2102
2103
2104#
2105# DOCS
2106#
2107
2108
2109#
2110# DIRECTORIES
2111#
2112_DIR_ALL := $(sort $(addsuffix /,$(patsubst %/,%,$(_DIRS))) $(dir $(_OUT_FILES) $(_OBJS) $(_INSTALLS_FILES)))
2113$(foreach directory,$(_INSTALLS_DIRS), $(eval _DIR_ALL := $(filter-out $(directory),$(_DIR_ALL))))
2114
2115
2116define def_mkdir_rule
2117$(directory):
2118 $$(call MSG_MKDIR,$$@)
2119 $$(QUIET)$$(MKDIR) -p $$@
2120endef
2121
2122$(foreach directory,$(_DIR_ALL),$(eval $(def_mkdir_rule)))
2123
2124
2125#
2126# NOTHING
2127#
2128do-nothing:
2129 $(call MSG_NOTHING)
2130
2131
2132#
2133# CLEAN UP
2134#
2135do-clean:
2136 $(call MSG_CLEAN)
2137 $(QUIET)$(RM) -f $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_DEPFILES_INCLUDED) $(_CLEAN_FILES) $(OTHER_CLEAN)
2138
2139
2140#
2141# PASSES (including directory and makefile walking)
2142#
2143
2144## Subdir
2145# @param $(pass) Lowercase pass name.
2146# @param $(PASS) Uppercase pass name.
2147# @param $(subdir) Subdirectory
2148# @param $(tag) tag to attach to the rule name.
2149define def_pass_subdir
2150pass_$(pass)$(tag):: $(dep)
2151 + $$(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass)
2152endef
2153
2154## Submakefile
2155# @param $(pass) Lowercase pass name.
2156# @param $(PASS) Uppercase pass name.
2157# @param $(makefile) Makefile.
2158# @param $(tag) tag to attach to the rule name.
2159define def_pass_makefile
2160pass_$(pass)$(tag):: $(dep)
2161 + $$(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass)
2162endef
2163
2164## Execute a pass.
2165# @param $(pass) Lowercase pass name.
2166# @param $(PASS) Uppercase pass name.
2167define def_pass_old
2168$(eval SUBDIRS_$(PASS) ?= $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET)) $(SUBDIRS.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
2169$(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET)) $(SUBDIRS_AFTER.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
2170$(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)) $(MAKEFILES_BEFORE.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
2171$(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET)) $(MAKEFILES_AFTER.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
2172
2173$(eval tag:=_before)
2174$(eval dep:=)
2175$(foreach subdir,$(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(BUILD_TARGET)) $(SUBDIRS_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
2176$(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),$(eval $(def_pass_makefile)))
2177
2178$(eval tag:=_after)
2179$(eval dep:=pass_$(pass)_doit)
2180$(foreach subdir,$(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
2181$(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_makefile)))
2182
2183.NOTPARALLEL: pass_$(pass)_before pass_$(pass)_after
2184.PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_doit pass_$(pass)_after
2185pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$(var))
2186pass_$(pass)_this: pass_$(pass)_before
2187 + $$(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
2188pass_$(pass)_after:: pass_$(pass)_this
2189pass_$(pass): pass_$(pass)_after
2190
2191endef
2192
2193define def_pass
2194$(eval SUBDIRS_$(PASS) ?= $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET)) $(SUBDIRS.$(BUILD_TARGET.$(BUILD_TARGET_ARCH))) )
2195$(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET)) $(SUBDIRS_AFTER.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
2196$(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)) $(MAKEFILES_BEFORE.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
2197$(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET)) $(MAKEFILES_AFTER.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) )
2198
2199$(eval tag:=_before)
2200$(eval dep:=)
2201$(foreach subdir,$(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(BUILD_TARGET)) $(SUBDIRS_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
2202$(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),$(eval $(def_pass_makefile)))
2203
2204$(eval tag:=_after)
2205$(eval dep:=pass_$(pass)_doit)
2206$(foreach subdir,$(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_subdir)))
2207$(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET).$(BUILD_TARGET_ARCH)) ,$(eval $(def_pass_makefile)))
2208
2209ifdef KBUILD_SAFE_PARALLEL
2210.NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this
2211.PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this pass_$(pass)_doit
2212pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$(var))
2213pass_$(pass)_this: pass_$(pass)_before
2214 + $$(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
2215pass_$(pass)_after:: pass_$(pass)_this
2216pass_$(pass): pass_$(pass)_after
2217else
2218.NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
2219.PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
2220pass_$(pass)_doit: pass_$(pass)_before \
2221 $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var)))
2222pass_$(pass): \
2223 pass_$(pass)_before \
2224 pass_$(pass)_doit \
2225 pass_$(pass)_after
2226endif
2227
2228#$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))))
2229endef
2230
2231# Generate the defined passes.
2232$(foreach PASS, $(PASSES), \
2233 $(eval pass := $(PASS_$(PASS)_pass)) \
2234 $(eval $(def_pass)))
2235
2236## Pass order
2237# @param $(pass) Current pass name.
2238# @param $(prev_pass) The previous pass name.
2239define def_pass_order
2240ifdef KBUILD_SAFE_PARALLEL
2241.NOTPARALLEL: pass_$(pass)_order
2242.PHONY: pass_$(pass)_order
2243pass_$(pass)_order: $(pass_prev)
2244 $$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass)))
2245 + $$(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)
2246else
2247.NOTPARALLEL: pass_$(pass)_order pass_$(pass)_banner
2248.PHONY: pass_$(pass)_order pass_$(pass)_banner
2249pass_$(pass)_banner:
2250 $$(call MSG_PASS,$$(if $$(PASS_$(PASS)),$$(PASS_$(PASS)),$(pass)))
2251pass_$(pass)_order: \
2252 $(pass_prev) \
2253 pass_$(pass)_banner \
2254 pass_$(pass)
2255endif
2256$(eval pass_prev := pass_$(pass)_order)
2257endef
2258
2259## PASS: order
2260# Use dependencies to ensure correct pass order.
2261pass_prev :=
2262$(foreach PASS,$(DEFAULT_PASSES),\
2263 $(eval pass := $(PASS_$(PASS)_pass)) \
2264 $(eval $(def_pass_order)))
2265
2266
2267#
2268# THE MAIN RULES
2269#
2270all_recursive: $(pass_prev)
2271
2272rebuild: clean
2273 + $(MAKE) -f $(firstword $(MAKEFILE_LIST)) all_recursive
2274
2275# @todo make this a non-default pass!
2276uninstall:
2277 $(RM) -f $(_INSTALLS_FILES)
2278
2279install: pass_installs
2280
2281# misc shortcuts.
2282targets: bldprogs libraries dlls programs sysmods others installs
2283objects: $(_OBJS)
2284bldprogs: $(_BLDPROGS)
2285libraries: $(_LIBS) $(_IMPORT_LIBS) $(_OTHER_LIBRARIES)
2286dlls: $(_DLLS)
2287programs: $(_PROGRAMS)
2288sysmods: $(_SYSMODS)
2289others: $(_OTHERS)
2290installs: $(_INSTALLS)
2291
2292
2293#
2294# kBuild debugging stuff.
2295#
2296_SPACE := $(subst ., ,.)
2297_TAB := $(subst ., ,.)
2298define _NEWLINE
2299
2300
2301endef
2302NLTAB = $(_NEWLINE)$(TAB)
2303show_targets:
2304 @$(foreach target, $(ALL_TARGETS),\
2305 @$(ECHO) "target: $(target)" $(NLTAB)\
2306 @$(ECHO) " PATH_$(target)=$(PATH_$(target))" $(NLTAB)\
2307 @$(ECHO) " TARGET_$(target)=$(TARGET_$(target))" $(NLTAB)\
2308 @$(ECHO) " INSTARGET_$(target)=$(INSTARGET_$(target))" $(NLTAB)\
2309$(foreach prop,$(PROPS_SINGLE) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R) OBJS_ CLEAN, \
2310 $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))) \
2311 $(if $($(target)_$(prop).$(_tmp)),\
2312 @$(ECHO) " $(target)_$(prop).$(_tmp)=$($(target)_$(prop).$(_tmp))" $(NLTAB)) \
2313 $(if $($(target)_$(prop)), $(NLTAB)@$(ECHO) " $(target)_$(prop)=$($(target)_$(prop))" $(NLTAB)) \
2314)\
2315$(foreach prop,$(PROPS_DEFERRED), \
2316 $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))) \
2317 $(if $(value $(target)_$(prop).$(_tmp)),\
2318 @$(ECHO) ' $(target)_$(prop).$(_tmp)=$(value $(TARGET)_$(prop).$(_tmp))' $(NLTAB)) \
2319 $(if $(value $(target)_$(prop)), $(NLTAB)@$(ECHO) ' $(target)_$(prop)=$(value $(target)_$(prop))' $(NLTAB)) \
2320))
2321
2322
2323
2324#
2325# Include dependency files.
2326#
2327$(foreach dep,$(wildcard $(_DEPFILES)),$(eval include $(dep)))
2328
2329
2330# end-of-file-content
2331__footer_kmk__ := target
2332endif # __footer_kmk__
2333
2334
Note: See TracBrowser for help on using the repository browser.