source: trunk/kBuild/footer.kmk@ 744

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

More sanity checks.

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