source: trunk/kBuild/footer.kmk@ 641

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

Resource file compilation.

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