source: trunk/kBuild/footer.kmk@ 724

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

Kicked the gnumake compatibility crap into separate files to speed things up. Added a slow stack implementation.

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