source: trunk/kBuild/footer.kmk@ 481

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

Check for $(BUILD_TARGET).$(BUILD_TARGET_ARCH).

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