source: trunk/kBuild/footer.kmk@ 357

Last change on this file since 357 was 353, checked in by bird, 20 years ago

Use fixed lot's of those $$$$(PATH_<target>) thingies. Better target install, install pass and install target type. Generic passes. And more.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 46.9 KB
RevLine 
[72]1# $Id: footer.kmk 353 2005-12-12 03:36:07Z 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 += \
[239]37 $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) \
[189]38 $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) \
39 $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) \
40 $(DLLS) $(DLLS.$(BUILD_TARGET)) \
41 $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) \
42 $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) \
[353]43 $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) \
[189]44 $(OTHERS) $(OTHERS.$(BUILD_TARGET))
[72]45
[75]46# dependency files.
47_DEPFILES :=
48
49# All kind of output files except for _OBJS and _DEPFILES.
50# Compiling or linking definition outputting other things that $@ and any
51# required dependency file must add those output files to this variable.
52_OUT_FILES :=
53
[353]54# Files which only requires cleaning up.
55_CLEAN_FILES :=
56
[72]57# all of a type
[219]58_OBJS :=
[222]59_BLDPROGS :=
[219]60_LIBS :=
61_DLLS :=
62_PROGRAMS :=
63_SYSMODS :=
[353]64_INSTALLS :=
65_OTHERS :=
66_DIRS := $(PATH_TARGET)/
[189]67_IMPORT_LIBS :=
[72]68
[220]69# misc
70pass_prev :=
71
72
[72]73#
[73]74# Basic macros
75#
76
77## Figure out the tool for a source
[106]78# @param $target source file
79# @param $source normalized main target
80# @param $type tooltype
[222]81# @param bld_trg build target.
[79]82_SOURCE_TOOL = $(strip $(firstword \
[222]83 $($(target)_$(source)_$(type)TOOL.$(bld_trg)) \
[106]84 $($(target)_$(source)_$(type)TOOL) \
[222]85 $($(target)_$(source)_TOOL.$(bld_trg)) \
[106]86 $($(target)_$(source)_TOOL) \
[222]87 $($(target)_$(type)TOOL.$(bld_trg)) \
[106]88 $($(target)_$(type)TOOL) \
[222]89 $($(target)_TOOL.$(bld_trg)) \
[106]90 $($(target)_TOOL) \
[222]91 $($(source)_$(type)TOOL.$(bld_trg)) \
[106]92 $($(source)_$(type)TOOL) \
[222]93 $($(source)_TOOL.$(bld_trg)) \
[106]94 $($(source)_TOOL) \
[222]95 $($(type)TOOL.$(bld_trg)) \
[106]96 $($(type)TOOL) \
[222]97 $(TOOL.$(bld_trg)) \
[106]98 $(TOOL) ))
[73]99
[78]100## Figure out the tool for a target.
[106]101# @param $target normalized target.
102# @param $source tooltype.
[222]103# @param bld_trg build target.
[79]104_TARGET_TOOL = $(strip $(firstword \
[222]105 $($(target)_$(source)TOOL.$(bld_trg)) \
[106]106 $($(target)_$(source)TOOL) \
[222]107 $($(target)_TOOL.$(bld_trg)) \
[106]108 $($(target)_TOOL) \
[238]109 $($(source)TOOL.$(bld_trg)) \
[106]110 $($(source)TOOL) \
[222]111 $(TOOL.$(bld_trg)) \
[106]112 $(TOOL) \
[79]113 ))
[183]114
[148]115## Removes the drive letter from a path (if it has one)
116# @param $1 the path
117no-drive=$(word $(words $(subst :, ,$(1))),$(subst :, ,$(1)))
[78]118
[148]119## Removes the root slash from a path (if it has one)
120# @param $1 the path
121no-root-slash=$(patsubst /%,%,$(1))
122
[73]123## Figure out where to put object files.
[110]124# @param $1 source file
125# @param $2 normalized main target
[316]126# @remark There are two major hacks here:
127# 1. Source files in the output directory are translated into a gen/ subdir.
128# 2. Catch anyone specifying $(PATH_CURRENT)/sourcefile.c.
129_OBJECT_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(basename \
130 $(patsubst $(PATH_ROOT)/%,%,$(patsubst $(PATH_CURRENT)/%,%,$(patsubst $(PATH_TARGET)/$(2)/%,gen/%,$(1)))))))
[73]131
132## Figure out where to put object files.
[110]133# @param $1 real target name.
134# @param $2 normalized main target
[148]135_TARGET_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(basename $(1))))
[73]136
137
[353]138## Figure out the actual name of an installed file.
139# @param $1 The file to install.
140# @param $2 The target name.
141# @param $3 The _INST value (can be empty).
142# @param $4 The default directory to use when $3 is empty.
143_INSTALL_FILE = $(patsubst %/,%/$(notdir $(1)),$(if $(3),$(PATH_INS)/$(3),$(4)/))
144
145
[73]146#
[185]147# Check syntax which leads to weird syntax errors.
148#
149
150## Check
151# @param $(target) Target name.
152define def_check_target
153ifneq ("$($(target)_TEMPLATE)","$(strip $($(target)_TEMPLATE))")
154$$(error $(target) have an incorrect template name. Remove any tabs!)
155endif
156endef
157$(foreach target, $(ALL_TARGETS),$(eval $(def_check_target)))
158
159
160#
[72]161# Include templates
162#
163_TEMPLATES := $(TEMPLATE)
164define def_templates
165ifdef $(target)_TEMPLATE
166_TEMPLATES += $($(target)_TEMPLATE)
167endif
168endef
169$(foreach target, $(ALL_TARGETS), $(eval $(def_templates)))
170_TEMPLATES := $(sort $(_TEMPLATES))
171# $ (warning dbg: _TEMPLATES=$(_TEMPLATES))
172
173define def_templates_include
174ifndef TEMPLATE_$(template)
[353]175include $(firstword $(foreach path, $(TEMPLATE_PATHS) $(PATH_KBUILD)/templates/, $(wildcard $(path)/$(template).kmk)))
[72]176endif
177endef
178$(foreach template, $(_TEMPLATES), $(eval $(def_templates)))
179
[74]180
[72]181#
182# Common Inheritance
183#
184
185## Inherit defaults property
186# @param $(prop) Property name
187# @param $(target) Target name.
188define def_inherit_defaults_one
[74]189ifndef $(target)_$(prop)
[109]190ifndef $(target)_$(prop).$(BUILD_TARGET)
[72]191ifdef $(prop)
[105]192$$(eval $(target)_$(prop) := $($(prop)))
[72]193endif
[109]194ifdef $(prop).$(BUILD_TARGET)
195$$(eval $(target)_$(prop).$(BUILD_TARGET) := $($(prop).$(BUILD_TARGET)))
[72]196endif
[109]197endif
198endif
[72]199endef
200
201## Inherit default properties for one target.
202# A bit tricky this one, but it depends a bit on whether or not TEMPLATE
203# is inherited from the default properties.
204# @param $(target) Target name
[78]205#
[72]206define def_inherit_defaults
207ifdef $(target)_TEMPLATE
[107]208ifeq ($(strip $(TEMPLATE_$($(target)_TEMPLATE)_TOOL) $(TEMPLATE_$($(target)_TEMPLATE)_TOOL.$(BUILD_TARGET))),)
[109]209$$(foreach prop,TOOL, $$(eval $$(def_inherit_defaults_one)))
[72]210endif
[107]211ifeq ($(strip $(TEMPLATE_$($(target)_TEMPLATE)_SDKS) $(TEMPLATE_$($(target)_TEMPLATE)_SDKS.$(BUILD_TARGET))),)
[109]212$$(foreach prop,SDKS, $$(eval $$(def_inherit_defaults_one)))
[72]213endif
214else
[109]215$$(foreach prop,TEMPLATE TOOL SDKS, $$(eval $$(def_inherit_defaults_one)))
[72]216endif
217endef
218# Inherit default properties.
[109]219# !!!!!!THIS IS MESSY AND NOT NECESSARY!!!!!!
[105]220$(foreach target, $(ALL_TARGETS),$(eval $(def_inherit_defaults)))
[72]221
222
[353]223## Inherit one template property in a non-accumulative manner.
[72]224# @param $(prop) Property name
225# @param $(target) Target name
[78]226# @todo fix the precedence order for some properties.
[72]227define def_inherit_template_one
[78]228ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
[72]229ifndef $(target)_$(prop)
[353]230$(target)_$(prop) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
231#$ (warning dbgtarget: $(target)_$(prop):='$(value $(target)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
[72]232endif
233endif
[79]234ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)
235ifndef $(target)_$(prop).$(BUILD_TARGET)
[353]236#$ (warning dbgsource: $(target)_$(prop).$(BUILD_TARGET)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
237$(target)_$(prop).$(BUILD_TARGET) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
[79]238endif
239endif
[72]240endef
241
[353]242## Inherit one template property in a non-accumulative manner, deferred expansion.
243# @param 1: $(prop) Property name
244# @param 2: $(target) Target name
245# @todo fix the precedence order for some properties.
246# @remark this define relies on double evaluation
247define def_inherit_template_one_deferred
248ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
249ifndef $(target)_$(prop)
250$(target)_$(prop) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
251#$ (warning dbgtarget: $(target)_$(prop):='$(value $(target)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
252endif
253endif
254ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)
255ifndef $(target)_$(prop).$(BUILD_TARGET)
256#$ (warning dbgsource: $(target)_$(prop).$(BUILD_TARGET)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
257$(target)_$(prop).$(BUILD_TARGET) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
258endif
259endif
260endef
261
[183]262## Inherit one template property.
[78]263# @param $(prop) Property name
264# @param $(target) Target name
265define def_inherit_template_one_accumulate
266ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
[353]267#$ (warning dbgtype: TEMPLATE_$($(target)_TEMPLATE)_$(prop) $(target)_$(prop)=$($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
268$(target)_$(prop) := $($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
269#$ (warning dbgtype: $(target)_$(prop)=$($(target)_$(prop)))
[78]270endif
[243]271ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)
[353]272#$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
273$(target)_$(prop).$(BUILD_TYPE) := $($(target)_$(prop).$(BUILD_TYPE)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
[243]274endif
[79]275ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)
[353]276#$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
277$(target)_$(prop).$(BUILD_TARGET) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
[79]278endif
279ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU)
[353]280#$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU))
281$(target)_$(prop).$(BUILD_TARGET_CPU) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU))
[79]282endif
283ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH)
[353]284#$ (warning dbg6: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH))
285$(target)_$(prop).$(BUILD_TARGET_ARCH) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH))
[79]286endif
[78]287endef
288
[72]289## Inherit template properties for on target.
290# @param $(target) Target name.
291define def_inherit_template
[353]292$(foreach prop,$(PROPS_SINGLE),$(eval $(value def_inherit_template_one)))
293$(foreach prop,$(PROPS_DEFERRED),$(eval $(def_inherit_template_one_deferred))) # exploits the 2 evaluation, so no value!
294$(foreach prop,$(PROPS_ACCUMULATE),$(eval $(value def_inherit_template_one_accumulate)))
[72]295endef
[353]296
[72]297# Inherit template properties
[353]298$(foreach target, $(ALL_TARGETS),$(eval $(value def_inherit_template)))
[72]299
300
301#
302# Include tools
[183]303#
[72]304_TOOLS := $(TOOL)
305define def_tools_target_source
[353]306$(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
307 $($(source)_$(prop).$(BUILD_TARGET)) \
308 $($(target)_$(source)_$(prop).$(BUILD_TARGET)) \
309 $($(source)_$(prop)) \
310 $($(target)_$(source)_$(prop))))
[72]311endef
[353]312
[72]313define def_tools_target
[353]314$(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
315 $($(target)_$(prop).$(BUILD_TARGET)) \
316 $($(target)_$(prop))))
317$(foreach source, \
318 $($(target)_SOURCES.$(BUILD_TARGET)) \
319 $($(target)_SOURCES.$(BUILD_TYPE)) \
320 $($(target)_SOURCES) \
321 , $(eval $(value def_tools_target_source)))
[72]322endef
[353]323
324$(foreach target, $(ALL_TARGETS), $(eval $(value def_tools_target)))
[72]325_TOOLS := $(sort $(_TOOLS))
326
327define def_tools_include
328ifndef TOOL_$(tool)
[353]329TOOL_$(tool)_KMK_FILE := $(firstword $(foreach path, $(TOOL_PATHS) $(PATH_KBUILD)/tools, $(wildcard $(path)/$(tool).kmk)))
330ifeq ($(TOOL_$(tool)_KMK_FILE),)
331$(error kBuild: Cannot find include file for the tool '$(tool)'! Searched: $(TOOL_PATHS) $(PATH_KBUILD)/tools)
[72]332endif
[353]333include $(TOOL_$(tool)_KMK_FILE)
334endif
[72]335endef
[353]336$(foreach tool, $(_TOOLS), $(eval $(value def_tools_include)))
[72]337
338
339#
340# Include SDKs
[73]341#
[72]342_SDKS := $(SDKS)
343define def_sdks_target_source
[220]344$(foreach sdk, $($(source)_SDKS) $($(source)_SDKS.$(BUILD_TARGET)) $($(source)_SDKS.$(BUILD_TYPE)) \
345 $($(target)_$(source)_SDKS) $($(target)_$(source)_SDKS.$(BUILD_TARGET)) $($(target)_$(source)_SDKS.$(BUILD_TYPE)), \
[72]346 $(eval _SDKS += $(sdk)))
347endef
348define def_sdks_target
[220]349$(foreach sdk, $($(target)_SDKS) $($(target)_SDKS.$(BUILD_TARGET)) $($(target)_SDKS.$(BUILD_TYPE))\
[122]350 , $(eval _SDKS += $(sdk)))
[220]351$(foreach source, $($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TYPE))\
[120]352 , $(eval $(def_sdks_target_source)))
[72]353endef
354$(foreach target, $(ALL_TARGETS), $(eval $(def_sdks_target)))
355_SDKS := $(sort $(_SDKS))
356
[122]357define def_sdks_include_one
[72]358ifndef SDK_$(sdk)
[353]359SDK_$(sdk)_KMK_FILE := $(firstword $(foreach path, $(SDK_PATHS) $(PATH_KBUILD)/sdks, $(wildcard $(path)/$(sdk).kmk)))
360ifeq ($(SDK_$(sdk)_KMK_FILE),)
361$(error kBuild: Cannot find include file for the SDK '$(sdk)'! Searched: $(SDK_PATHS) $(PATH_KBUILD)/sdks)
[72]362endif
[353]363include $(SDK_$(sdk)_KMK_FILE)
364endif
[72]365endef
[353]366$(foreach sdk, $(_SDKS), $(eval $(value def_sdks_include_one)))
[72]367
[73]368#
369# Object processing.
370#
[72]371
[353]372## Generates the '::' rule for building all objects of a source file.
373# @param $(obj) The object file.
374define def_target_obj_rule
375$(basename $(notdir $(obj))).o::
376 + $$(MAKE) -B -f $$(MAKEFILE) $(obj)
377$(basename $$(notdir $$(obj))).obj::
378 + $$(MAKE) -B -f $$(MAKEFILE) $(obj)
379endef
[205]380
[353]381
[73]382## Generic macro for processing C, C++ and Assembly sources.
383# @param $(target) Normalized target name.
384# @param $(source) Source file name.
385# @param $(type) Source type. {C,CXX,AS}
[221]386# @param bld_type Build type.
387# @param bld_trg Build target.
388# @param bld_trg_arch Build target arch.
389# @param bld_trg_cpu Build target cpu.
[72]390#
[73]391# @remark I've no clue why I've to $(eval ..) everything in this define. MAKE bug?
[105]392# @remark I now have a clue. Have to use $$ if not.
[73]393define def_target_source_c_cpp_asm
[105]394#$ (warning dbg: def_target_source_c_cpp_asm: source='$(source)' target='$(target)' type='$(type)')
[73]395
[353]396tool := $(call _SOURCE_TOOL,$(source),$(target),$(type))
397outbase := $(call _OBJECT_BASE,$(source),$(target))
398PATH_$(target)_$(source) := $(patsubst %/,%,$(dir $(outbase)))
399dirdep := $(call DIRDEP,$(dir $(outbase)))
400defs :=\
[78]401 $(TOOL_$(tool)_DEFS)\
[221]402 $(TOOL_$(tool)_DEFS.$(bld_type))\
403 $(TOOL_$(tool)_DEFS.$(bld_trg))\
404 $(TOOL_$(tool)_DEFS.$(bld_trg_arch))\
405 $(TOOL_$(tool)_DEFS.$(bld_trg_cpu))\
[74]406 $(TOOL_$(tool)_$(type)DEFS)\
[221]407 $(TOOL_$(tool)_$(type)DEFS.$(bld_type))\
408 $(foreach sdk, $(SDKS.$(bld_trg)) \
409 $(SDKS.$(bld_type)) \
[78]410 $(SDKS),\
[353]411 $(SDK_$(sdk)_DEFS)\
412 $(SDK_$(sdk)_DEFS.$(bld_type))\
413 $(SDK_$(sdk)_DEFS.$(bld_trg))\
414 $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
415 $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
416 $(SDK_$(sdk)_$(type)DEFS)\
417 $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
418 $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
419 $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
420 $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
[74]421 $(DEFS)\
[221]422 $(DEFS.$(bld_type))\
423 $(DEFS.$(bld_trg))\
424 $(DEFS.$(bld_trg_arch))\
425 $(DEFS.$(bld_trg_cpu))\
[78]426 $($(type)DEFS)\
[221]427 $($(type)DEFS.$(bld_type))\
428 $($(type)DEFS.$(bld_trg))\
429 $($(type)DEFS.$(bld_trg_arch))\
430 $($(type)DEFS.$(bld_trg_cpu))\
431 $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
432 $($(target)_SDKS.$(bld_type)) \
[78]433 $($(target)_SDKS),\
[353]434 $(SDK_$(sdk)_DEFS)\
435 $(SDK_$(sdk)_DEFS.$(bld_type))\
436 $(SDK_$(sdk)_DEFS.$(bld_trg))\
437 $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
438 $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
439 $(SDK_$(sdk)_$(type)DEFS)\
440 $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
441 $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
442 $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
443 $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
[74]444 $($(target)_DEFS)\
[221]445 $($(target)_DEFS.$(bld_type))\
446 $($(target)_DEFS.$(bld_trg))\
447 $($(target)_DEFS.$(bld_trg_arch))\
448 $($(target)_DEFS.$(bld_trg_cpu))\
[78]449 $($(target)_$(type)DEFS)\
[221]450 $($(target)_$(type)DEFS.$(bld_type))\
451 $($(target)_$(type)DEFS.$(bld_trg))\
452 $($(target)_$(type)DEFS.$(bld_trg_arch))\
453 $($(target)_$(type)DEFS.$(bld_trg_cpu))\
454 $(foreach sdk, $($(source)_SDKS.$(bld_trg)) \
455 $($(source)_SDKS.$(bld_type)) \
[78]456 $($(source)_SDKS),\
[353]457 $(SDK_$(sdk)_DEFS)\
458 $(SDK_$(sdk)_DEFS.$(bld_type))\
459 $(SDK_$(sdk)_DEFS.$(bld_trg))\
460 $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
461 $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
462 $(SDK_$(sdk)_$(type)DEFS)\
463 $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
464 $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
465 $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
466 $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
[74]467 $($(source)_DEFS)\
[221]468 $($(source)_DEFS.$(bld_type))\
469 $($(source)_DEFS.$(bld_trg))\
470 $($(source)_DEFS.$(bld_trg_arch))\
471 $($(source)_DEFS.$(bld_trg_cpu))\
[73]472 $($(source)_$(type)DEFS)\
[221]473 $($(source)_$(type)DEFS.$(bld_type))\
474 $($(source)_$(type)DEFS.$(bld_trg))\
475 $($(source)_$(type)DEFS.$(bld_trg_arch))\
476 $($(source)_$(type)DEFS.$(bld_trg_cpu))\
477 $(foreach sdk, $($(target)_$(source)_SDKS.$(bld_trg)) \
478 $($(target)_$(source)_SDKS.$(bld_type)) \
[78]479 $($(target)_$(source)_SDKS),\
[353]480 $(SDK_$(sdk)_DEFS)\
481 $(SDK_$(sdk)_DEFS.$(bld_type))\
482 $(SDK_$(sdk)_DEFS.$(bld_trg))\
483 $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
484 $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
485 $(SDK_$(sdk)_$(type)DEFS)\
486 $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
487 $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
488 $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
489 $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
[74]490 $($(target)_$(source)_DEFS)\
[221]491 $($(target)_$(source)_DEFS.$(bld_type))\
492 $($(target)_$(source)_DEFS.$(bld_trg))\
493 $($(target)_$(source)_DEFS.$(bld_trg_arch))\
494 $($(target)_$(source)_DEFS.$(bld_trg_cpu))\
[74]495 $($(target)_$(source)_$(type)DEFS)\
[221]496 $($(target)_$(source)_$(type)DEFS.$(bld_type))\
497 $($(target)_$(source)_$(type)DEFS.$(bld_trg))\
498 $($(target)_$(source)_$(type)DEFS.$(bld_trg_arch))\
[353]499 $($(target)_$(source)_$(type)DEFS.$(bld_trg_cpu))
500incs :=\
[221]501 $($(target)_$(source)_$(type)INCS.$(bld_trg_cpu))\
502 $($(target)_$(source)_$(type)INCS.$(bld_trg_arch))\
503 $($(target)_$(source)_$(type)INCS.$(bld_trg))\
504 $($(target)_$(source)_$(type)INCS.$(bld_type))\
[73]505 $($(target)_$(source)_$(type)INCS)\
[221]506 $($(target)_$(source)_INCS.$(bld_trg_cpu))\
507 $($(target)_$(source)_INCS.$(bld_trg_arch))\
508 $($(target)_$(source)_INCS.$(bld_trg))\
509 $($(target)_$(source)_INCS.$(bld_type))\
[73]510 $($(target)_$(source)_INCS)\
[221]511 $(foreach sdk, $($(target)_$(source)_SDKS.$(bld_trg)) \
512 $($(target)_$(source)_SDKS.$(bld_type)) \
[133]513 $($(target)_$(source)_SDKS),\
[353]514 $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
515 $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
516 $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
517 $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
518 $(SDK_$(sdk)_$(type)INCS)\
519 $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
520 $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
521 $(SDK_$(sdk)_INCS.$(bld_trg))\
522 $(SDK_$(sdk)_INCS.$(bld_type))\
523 $(SDK_$(sdk)_INCS))\
[221]524 $($(source)_$(type)INCS.$(bld_trg_cpu))\
525 $($(source)_$(type)INCS.$(bld_trg_arch))\
526 $($(source)_$(type)INCS.$(bld_trg))\
527 $($(source)_$(type)INCS.$(bld_type))\
[73]528 $($(source)_$(type)INCS)\
[221]529 $($(source)_INCS.$(bld_trg_cpu))\
530 $($(source)_INCS.$(bld_trg_arch))\
531 $($(source)_INCS.$(bld_trg))\
532 $($(source)_INCS.$(bld_type))\
[73]533 $($(source)_INCS)\
[221]534 $(foreach sdk, $($(source)_SDKS.$(bld_trg)) \
535 $($(source)_SDKS.$(bld_type)) \
[78]536 $($(source)_SDKS),\
[353]537 $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
538 $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
539 $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
540 $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
541 $(SDK_$(sdk)_$(type)INCS)\
542 $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
543 $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
544 $(SDK_$(sdk)_INCS.$(bld_trg))\
545 $(SDK_$(sdk)_INCS.$(bld_type))\
546 $(SDK_$(sdk)_INCS))\
[221]547 $($(target)_$(type)INCS.$(bld_trg_cpu))\
548 $($(target)_$(type)INCS.$(bld_trg_arch))\
549 $($(target)_$(type)INCS.$(bld_trg))\
550 $($(target)_$(type)INCS.$(bld_type))\
[73]551 $($(target)_$(type)INCS)\
[221]552 $($(target)_INCS.$(bld_trg_cpu))\
553 $($(target)_INCS.$(bld_trg_arch))\
554 $($(target)_INCS.$(bld_trg))\
555 $($(target)_INCS.$(bld_type))\
[73]556 $($(target)_INCS)\
[221]557 $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
558 $($(target)_SDKS.$(bld_type)) \
[78]559 $($(target)_SDKS),\
[353]560 $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
561 $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
562 $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
563 $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
564 $(SDK_$(sdk)_$(type)INCS)\
565 $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
566 $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
567 $(SDK_$(sdk)_INCS.$(bld_trg))\
568 $(SDK_$(sdk)_INCS.$(bld_type))\
569 $(SDK_$(sdk)_INCS))\
[221]570 $(INCS.$(bld_trg_cpu))\
571 $(INCS.$(bld_trg_arch))\
572 $(INCS.$(bld_trg))\
573 $(INCS.$(bld_type))\
[73]574 $(INCS)\
[221]575 $(foreach sdk, $(SDKS.$(bld_trg)) \
576 $(SDKS.$(bld_type)) \
[78]577 $(SDKS),\
[353]578 $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
579 $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
580 $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
581 $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
582 $(SDK_$(sdk)_$(type)INCS)\
583 $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
584 $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
585 $(SDK_$(sdk)_INCS.$(bld_trg))\
586 $(SDK_$(sdk)_INCS.$(bld_type))\
587 $(SDK_$(sdk)_INCS))\
[221]588 $(TOOL_$(tool)_$(type)INCS.$(bld_trg_cpu))\
589 $(TOOL_$(tool)_$(type)INCS.$(bld_trg_arch))\
590 $(TOOL_$(tool)_$(type)INCS.$(bld_trg))\
591 $(TOOL_$(tool)_$(type)INCS.$(bld_type))\
[353]592 $(TOOL_$(tool)_$(type)INCS)
593flags :=\
[73]594 $(TOOL_$(tool)_$(type)FLAGS)\
[221]595 $(TOOL_$(tool)_$(type)FLAGS.$(bld_type))\
596 $(TOOL_$(tool)_$(type)FLAGS.$(bld_trg))\
597 $(TOOL_$(tool)_$(type)FLAGS.$(bld_trg_arch))\
598 $(TOOL_$(tool)_$(type)FLAGS.$(bld_trg_cpu))\
[73]599 $($(type)FLAGS)\
[221]600 $($(type)FLAGS.$(bld_type))\
601 $($(type)FLAGS.$(bld_trg))\
602 $($(type)FLAGS.$(bld_trg_arch))\
603 $($(type)FLAGS.$(bld_trg_cpu))\
[73]604 $($(target)_$(type)FLAGS)\
[221]605 $($(target)_$(type)FLAGS.$(bld_type))\
606 $($(target)_$(type)FLAGS.$(bld_trg))\
607 $($(target)_$(type)FLAGS.$(bld_trg_arch))\
608 $($(target)_$(type)FLAGS.$(bld_trg_cpu))\
[73]609 $($(source)_$(type)FLAGS)\
[221]610 $($(source)_$(type)FLAGS.$(bld_type))\
611 $($(source)_$(type)FLAGS.$(bld_trg))\
612 $($(source)_$(type)FLAGS.$(bld_trg_arch))\
613 $($(source)_$(type)FLAGS.$(bld_trg_cpu))\
[73]614 $($(target)_$(source)_$(type)FLAGS)\
[221]615 $($(target)_$(source)_$(type)FLAGS.$(bld_type))\
616 $($(target)_$(source)_$(type)FLAGS.$(bld_trg))\
617 $($(target)_$(source)_$(type)FLAGS.$(bld_trg_arch))\
[353]618 $($(target)_$(source)_$(type)FLAGS.$(bld_trg_cpu))
619objsuff := $(firstword \
[221]620 $($(target)_$(source)_OBJSUFF.$(bld_trg))\
[74]621 $($(target)_$(source)_OBJSUFF)\
[221]622 $($(source)_OBJSUFF.$(bld_trg))\
[74]623 $($(source)_OBJSUFF)\
[221]624 $($(target)_OBJSUFF.$(bld_trg))\
[74]625 $($(target)_OBJSUFF)\
[221]626 $(TOOL_$(tool)_$(type)OBJSUFF.$(bld_trg))\
[74]627 $(TOOL_$(tool)_$(type)OBJSUFF)\
[353]628 $(SUFF_OBJ))
629obj := $(outbase)$(objsuff)
630dep := $(outbase)$(SUFF_DEP)
631deps := \
[184]632 $($(target)_$(source)_DEPS)\
[353]633 $($(target)_$(source)_DEPS.$(bld_type))\
634 $($(target)_$(source)_DEPS.$(bld_trg))\
635 $($(target)_$(source)_DEPS.$(bld_trg_arch))\
636 $($(target)_$(source)_DEPS.$(bld_trg_cpu))\
[184]637 $($(source)_DEPS)\
[221]638 $($(source)_DEPS.$(bld_type))\
639 $($(source)_DEPS.$(bld_trg))\
[353]640 $($(source)_DEPS.$(bld_trg_arch))\
641 $($(source)_DEPS.$(bld_trg_cpu))\
[184]642 $($(target)_DEPS)\
[353]643 $($(target)_DEPS.$(bld_type))\
[221]644 $($(target)_DEPS.$(bld_trg_arch))\
[353]645 $($(target)_DEPS.$(bld_trg_cpu))
[73]646
[184]647
648#$ (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))
[97]649ifndef TOOL_$(tool)_COMPILE_$(type)
[353]650$(warning kBuild: tools: \
[221]651 1 $($(target)_$(source)_$(type)TOOL.$(bld_trg)) \
[106]652 2 $($(target)_$(source)_$(type)TOOL) \
[221]653 3 $($(target)_$(source)_TOOL.$(bld_trg)) \
[106]654 4 $($(target)_$(source)_TOOL) \
[221]655 5 $($(target)_$(type)TOOL.$(bld_trg)) \
[106]656 6 $($(target)_$(type)TOOL) \
[221]657 7 $($(target)_TOOL.$(bld_trg)) \
[106]658 8 $($(target)_TOOL) \
[221]659 9 $($(source)_$(type)TOOL.$(bld_trg)) \
[106]660 10 $($(source)_$(type)TOOL) \
[221]661 11 $($(source)_TOOL.$(bld_trg)) \
[106]662 12 $($(source)_TOOL) \
[221]663 13 $($(type)TOOL.$(bld_trg)) \
[106]664 14 $($(type)TOOL) \
[221]665 15 $(TOOL.$(bld_trg)) \
[106]666 16 $(TOOL) )
[353]667$(error kBuild: TOOL_$(tool)_COMPILE_$(type) is not defined. source=$(source) target=$(target) )
[97]668endif
[353]669
670# generate the rules
[73]671$(eval $(TOOL_$(tool)_COMPILE_$(type)))
672
[353]673$(eval $(def_target_obj_rule))
[205]674
[353]675$(target)_OBJS_ += $(obj)
676_DEPFILES += $(dep)
[73]677
678endef
679
680## Generic macro for processing all target sources.
[74]681# @param $(target) Normalized target name.
[73]682define def_target_sources
683#$ (warning def_target_sources)
684# C sources
[353]685type := C
686$(foreach source, $(filter %.c, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\
687 ,$(eval $(value def_target_source_c_cpp_asm)) )
[73]688
689# C++ sources
[353]690type := CXX
691$(foreach source, $(filter %.cpp %.cxx %.xx, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\
692 ,$(eval $(value def_target_source_c_cpp_asm)) )
[73]693
694# ASM sources
[353]695type := AS
696$(foreach source, $(filter %.asm %.s %.S, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\
697 ,$(eval $(value def_target_source_c_cpp_asm)) )
698
[73]699endef
700
[353]701## Generate the link & lib install rule
702# @param $(target) Normalized target name.
703# @param $(out) The build target.
704# @param $(INSTARGET_$(target)) The installation targets.
705define def_link_install_rule
706$(INSTARGET_$(target)) : $(out) | $(call DIRDEP,$(dir $(INSTARGET_$(target))))
707 $(RM) -f $$@
708 $(CP) $(out) $$@
709endef
[73]710
[219]711
712
[353]713## Generic macro for generating the install rule(s) for a target
714# and update the globals with default out.
[219]715#
[353]716# @param $(target) Normalized target name.
717# @param $(out) The output file.
718# @param $(definst) The default _INST value.
719# @param $(typevar) The name of the variable with all the root targets of its type.
720# @obsolete
721define def_target_install_pluss
722ifndef $(target)_NOINST
723INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
724 $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
[219]725
[353]726$(eval $(def_link_install_rule))
[239]727
[353]728_INSTALLS += $(INSTARGET_$(target))
[272]729
[353]730ifdef KBUILD_DO_AUTO_INSTALL
731$(typevar) += $(INSTARGET_$(target))
[219]732else
[353]733$(typevar) += $(out)
[219]734endif
[353]735else # _NOINST
736$(typevar) += $(out)
737endif
738
739_OUT_FILES += $(out)
740_CLEAN_FILES += $($(target)_CLEAN)
741_OBJS += $($(target)_OBJS_)
742
[219]743endef
744
745
746
747#
[72]748# LIBRARIES
[73]749#
[72]750
751## Library (one).
[74]752# @param $(target) Normalized library (target) name.
[72]753define def_lib
[145]754# library basics
[222]755## @todo prefix
[353]756bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
757bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))
758bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
759bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU))
760tool := $(call _TARGET_TOOL,$(target),AR)
[78]761ifeq ($(tool),)
[353]762$(error kBuild: Library target $(target) does not have a tool defined!)
[78]763endif
[353]764outbase := $(call _TARGET_BASE,$(target),$(target))
765PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
766suff := $(firstword\
[221]767 $($(target)_LIBSUFF.$(bld_trg))\
[126]768 $($(target)_LIBSUFF)\
[221]769 $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg))\
[126]770 $(TOOL_$(tool)_ARLIBSUFF)\
[353]771 $(SUFF_LIB))
772out := $(outbase)$(suff)
773TARGET_$(target) := $(out)
774$(target)_OBJS_ := $(filter %.o %.obj, \
775 $($(target)_SOURCES) \
776 $($(target)_SOURCES.$(bld_trg)) \
777 $($(target)_SOURCES.$(bld_trg_arch)) \
778 $($(target)_SOURCES.$(bld_trg_cpu)) \
779 $($(target)_SOURCES.$(bld_type)))
[145]780
[353]781
[145]782# source -> object
[353]783$(eval $(value def_target_sources))
[145]784
785# library linking
[353]786tool := $(call _TARGET_TOOL,$(target),AR)
787outbase := $(call _TARGET_BASE,$(target),$(target))
788flags :=\
[74]789 $(TOOL_$(tool)_ARFLAGS)\
[221]790 $(TOOL_$(tool)_ARFLAGS.$(bld_type))\
[74]791 $(ARFLAGS)\
[221]792 $(ARFLAGS.$(bld_type))\
[74]793 $($(target)_ARFLAGS)\
[353]794 $($(target)_ARFLAGS.$(bld_type))
795othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,\
796 $($(target)_SOURCES) \
797 $($(target)_SOURCES.$(bld_trg)) \
798 $($(target)_SOURCES.$(bld_trg_arch)) \
799 $($(target)_SOURCES.$(bld_trg_cpu)) \
800 $($(target)_SOURCES.$(bld_type)))
801objs = $($(target)_OBJS_)
802dirdep := $(call DIRDEP,$(dir $(out)))
[78]803## @todo fix dependencies on makefiles an such
[353]804deps := $($(target)_DEPS)
[72]805
[353]806lib := $(out)
807libsuff := $(suff)
[73]808$(eval $(TOOL_$(tool)_LINK_LIBRARY))
[72]809
[353]810# installing and globals
811definst := $(PATH_LIB)
812typevar :=_LIBS
813$(eval $(value def_target_install_pluss))
[72]814endef
815
816# Process libraries
[353]817$(foreach target, $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)), $(eval $(value def_lib)))
[72]818
819
820#
[353]821# Link operations.
[72]822#
823
[353]824##
825# Link prolog
826#
827# @param $(target) Normalized target name.
828# @param $(EXT) EXE,DLL,SYS.
829# @param $(definst) The default _INST value.
830# @param $(typevar) The name of the variable with all the root targets of its type.
831define def_link_prolog
832# basics
833bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
834bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_$(bld_trg_base_var)))
835bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH))
836bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_$(bld_trg_base_var)_CPU))
[145]837
[353]838tool := $(call _TARGET_TOOL,$(target),LD)
839outbase := $(call _TARGET_BASE,$(target),$(target))
840suff := $(firstword \
841 $($(target)_$(EXT)SUFF) \
842 $($(target)_$(EXT)SUFF) \
843 $(TOOL_$(tool)_LD$(EXT)SUFF) \
844 $($(EXTPRE)SUFF_$(EXT)))
845out := $(outbase)$(suff)
846PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
847TARGET_$(target) := $(out)
848$(target)_OBJS_ := $(filter %.o %.obj, \
849 $($(target)_SOURCES) \
850 $($(target)_SOURCES.$(bld_trg)) \
851 $($(target)_SOURCES.$(bld_trg_arch)) \
852 $($(target)_SOURCES.$(bld_trg_cpu)) \
853 $($(target)_SOURCES.$(bld_type)))
854
[145]855# source -> object
[353]856$(eval $(value def_target_sources))
[145]857
[353]858# more library stuff.
859tool := $(call _TARGET_TOOL,$(target),LD)
860outbase := $(call _TARGET_BASE,$(target),$(target))
861flags :=\
[74]862 $(TOOL_$(tool)_LDFLAGS)\
[221]863 $(TOOL_$(tool)_LDFLAGS.$(bld_type))\
864 $(TOOL_$(tool)_LDFLAGS.$(bld_trg))\
865 $(TOOL_$(tool)_LDFLAGS.$(bld_trg_arch))\
866 $(TOOL_$(tool)_LDFLAGS.$(bld_trg_cpu))\
[74]867 $(LDFLAGS)\
[221]868 $(LDFLAGS.$(bld_type))\
869 $(LDFLAGS.$(bld_trg))\
870 $(LDFLAGS.$(bld_trg_arch))\
871 $(LDFLAGS.$(bld_trg_cpu))\
[74]872 $($(target)_LDFLAGS)\
[221]873 $($(target)_LDFLAGS.$(bld_type))\
874 $($(target)_LDFLAGS.$(bld_trg))\
875 $($(target)_LDFLAGS.$(bld_trg_arch))\
[353]876 $($(target)_LDFLAGS.$(bld_trg_cpu))
877othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,\
878 $($(target)_SOURCES)\
879 $($(target)_SOURCES.$(bld_trg)) \
880 $($(target)_SOURCES.$(bld_trg_arch)) \
881 $($(target)_SOURCES.$(bld_trg_cpu)) \
882 $($(target)_SOURCES.$(bld_type)))
883objs = $($(target)_OBJS_)
884libs :=\
[221]885 $($(target)_LIBS.$(bld_trg_cpu))\
886 $($(target)_LIBS.$(bld_trg_arch))\
887 $($(target)_LIBS.$(bld_trg))\
888 $($(target)_LIBS.$(bld_type))\
[74]889 $($(target)_LIBS)\
[221]890 $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
891 $($(target)_SDKS.$(bld_type)) \
[122]892 $($(target)_SDKS),\
[353]893 $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
894 $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
895 $(SDK_$(sdk)_LIBS.$(bld_trg))\
896 $(SDK_$(sdk)_LIBS.$(bld_type))\
897 $(SDK_$(sdk)_LIBS))\
[221]898 $(LIBS.$(bld_trg_cpu))\
899 $(LIBS.$(bld_trg_arch))\
900 $(LIBS.$(bld_trg))\
901 $(LIBS.$(bld_type))\
[74]902 $(LIBS)\
[221]903 $(foreach sdk, $(SDKS.$(bld_trg)) \
904 $(SDKS.$(bld_type)) \
[122]905 $(SDKS),\
[353]906 $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
907 $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
908 $(SDK_$(sdk)_LIBS.$(bld_trg))\
909 $(SDK_$(sdk)_LIBS.$(bld_type))\
910 $(SDK_$(sdk)_LIBS))\
[221]911 $(TOOL_$(tool)_LIBS.$(bld_trg_cpu))\
912 $(TOOL_$(tool)_LIBS.$(bld_trg_arch))\
913 $(TOOL_$(tool)_LIBS.$(bld_trg))\
914 $(TOOL_$(tool)_LIBS.$(bld_type))\
[353]915 $(TOOL_$(tool)_LIBS)
916libpath :=\
[221]917 $($(target)_LIBPATH.$(bld_trg_cpu))\
918 $($(target)_LIBPATH.$(bld_trg_arch))\
919 $($(target)_LIBPATH.$(bld_trg))\
920 $($(target)_LIBPATH.$(bld_type))\
[74]921 $($(target)_LIBPATH)\
[221]922 $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
923 $($(target)_SDKS.$(bld_type)) \
[122]924 $($(target)_SDKS),\
[353]925 $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
926 $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
927 $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
928 $(SDK_$(sdk)_LIBPATH.$(bld_type))\
929 $(SDK_$(sdk)_LIBPATH))\
[221]930 $(LIBPATH.$(bld_trg_cpu))\
931 $(LIBPATH.$(bld_trg_arch))\
932 $(LIBPATH.$(bld_trg))\
933 $(LIBPATH.$(bld_type))\
[74]934 $(LIBPATH)\
[221]935 $(foreach sdk, $(SDKS.$(bld_trg)) \
936 $(SDKS.$(bld_type)) \
[122]937 $(SDKS),\
[353]938 $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
939 $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
940 $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
941 $(SDK_$(sdk)_LIBPATH.$(bld_type))\
942 $(SDK_$(sdk)_LIBPATH))\
[221]943 $(TOOL_$(tool)_LIBPATH.$(bld_trg_cpu))\
944 $(TOOL_$(tool)_LIBPATH.$(bld_trg_arch))\
945 $(TOOL_$(tool)_LIBPATH.$(bld_trg))\
946 $(TOOL_$(tool)_LIBPATH.$(bld_type))\
[353]947 $(TOOL_$(tool)_LIBPATH)
948dirdep := $(call DIRDEP,$(dir $(out)))
[74]949## @todo fix dependencies
[353]950deps := $($(target)_DEPS)
951
952## @todo this stuff can't be working.
953custom_pre := $(strip $(firstword \
[221]954 $($(target)_CUSTOM_PRE.$(bld_trg).$(bld_type))\
955 $($(target)_CUSTOM_PRE.$(bld_trg))\
956 $($(target)_CUSTOM_PRE.$(bld_type))\
[74]957 $($(target)_CUSTOM_PRE)\
[221]958 $(CUSTOM_PRE.$(bld_trg).$(bld_type))\
959 $(CUSTOM_PRE.$(bld_trg))\
960 $(CUSTOM_PRE.$(bld_type))\
[74]961 $(CUSTOM_PRE)\
[353]962))
963custom_post := $(strip $(firstword \
[221]964 $($(target)_CUSTOM_POST.$(bld_trg).$(bld_type))\
965 $($(target)_CUSTOM_POST.$(bld_trg))\
966 $($(target)_CUSTOM_POST.$(bld_type))\
[74]967 $($(target)_CUSTOM_POST)\
[221]968 $(CUSTOM_POST.$(bld_trg).$(bld_type))\
969 $(CUSTOM_POST.$(bld_trg))\
970 $(CUSTOM_POST.$(bld_type))\
[74]971 $(CUSTOM_POST)\
[353]972))
[72]973
[353]974# installation targets
975ifndef $(target)_NOINST
976INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
977 $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
978ifdef KBUILD_DO_AUTO_INSTALL
979$(typevar) += $(INSTARGET_$(target))
980else
981$(typevar) += $(out)
982endif
983# generate the install rule
984$(eval $(def_link_install_rule))
985
986else # NOINST
987INSTARGET_$(target) :=
988$(typevar) += $(out)
989endif # NOINST
990
991endef
992
993
994##
995# Typical link epilog.
996#
997# @param $(target) Normalized target name.
998# @param $(out) The output file.
999define def_link_epilog
1000
1001_INSTALLS += $(INSTARGET_$(target))
1002_OBJS += $($(target)_OBJS_)
1003_OUT_FILES += $(out)
1004_CLEAN_FILES += $($(target)_CLEAN)
1005
1006endef
1007
1008
1009#
1010# BLDPROGS
1011#
1012
1013## Build program (one).
1014# @param $(target) Normalized target (program) name.
1015define def_bldprog
1016
1017# set NOINST if not forced installation.
1018ifndef $(target)_INST
1019$(target)_NOINST := 1
1020endif
1021
1022# prolog
1023$(eval $(value def_link_prolog))
1024
1025# body
1026ifndef TOOL_$(tool)_LINK_PROGRAM
1027$(warning kBuild: tools: \
1028 1 $($(target)_$(source)TOOL.$(bld_trg)) \
1029 2 $($(target)_$(source)TOOL) \
1030 3 $($(target)_TOOL.$(bld_trg)) \
1031 4 $($(target)_TOOL) \
1032 5 $(TOOL.$(bld_trg)) \
1033 6 $(TOOL) )
1034$(error kBuild: TOOL_$(tool)_LINK_PROGRAM is not defined. target=$(target) )
1035endif
1036$(eval $(TOOL_$(tool)_LINK_PROGRAM))
1037
1038# epilog
1039$(eval $(value def_link_epilog))
1040
1041endef
1042
1043# Process build programs.
1044EXT := EXE
1045EXTPRE := HOST
1046definst := $(PATH_BIN)
1047typevar := _BLDPROGS
1048bld_trg_base_var := PLATFORM
1049$(foreach target, $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)), $(eval $(value def_bldprog)))
1050
1051
1052
1053#
1054# DLLS
1055#
1056
1057## DLL (one).
1058# @param $(target) Normalized target (program) name.
1059define def_dll
1060
1061# prolog
1062$(eval $(value def_link_prolog))
1063
1064# body
[189]1065ifndef TOOL_$(tool)_LINK_DLL
[353]1066$(warning kBuild: tools: \
[221]1067 1 $($(target)_$(source)TOOL.$(bld_trg)) \
[189]1068 2 $($(target)_$(source)TOOL) \
[221]1069 3 $($(target)_TOOL.$(bld_trg)) \
[189]1070 4 $($(target)_TOOL) \
1071 5 $($(source)TOOL) \
[221]1072 6 $($(source)TOOL.$(bld_trg)) \
1073 7 $(TOOL.$(bld_trg)) \
[189]1074 8 $(TOOL) )
[353]1075$(error kBuild: TOOL_$(tool)_LINK_DLL is not defined. target=$(target) )
[189]1076endif
1077$(eval $(TOOL_$(tool)_LINK_DLL))
1078
[353]1079# epilog
1080$(eval $(value def_link_epilog))
[189]1081
[74]1082endef
1083
[189]1084# Process dlls
[353]1085EXT := DLL
1086EXTPRE :=
1087definst := $(PATH_DLL)
1088typevar := _DLLS
1089bld_trg_base_var := TARGET
1090$(foreach target, $(DLLS) $(DLLS.$(BUILD_TARGET)), $(eval $(value def_dll)))
[74]1091
1092
1093
[72]1094#
[189]1095# Process import libraries.
[72]1096#
[219]1097# - On OS/2 and windows these are libraries.
[189]1098# - On other platforms they are fake DLLs.
1099ifeq ($(subst win32,os2,$(BUILD_TARGET)),os2)
[353]1100$(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval $(value def_lib)))
[189]1101else
[353]1102$(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval $(value def_dll)))
[189]1103endif
[353]1104$(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), \
1105 $(eval _IMPORT_LIBS += $(if $(INSTARGET_$(target)),$(INSTARGET_$(target)), $(TARGET_$(target)))))
[72]1106
[189]1107
1108#
1109# PROGRAMS
1110#
1111
1112## Program (one).
[130]1113# @param $(target) Normalized target (program) name.
[189]1114define def_program
[145]1115
[353]1116# prolog
1117$(eval $(value def_link_prolog))
[145]1118
[353]1119# body
1120ifndef TOOL_$(tool)_LINK_PROGRAM
1121$(warning kBuild: tools: \
1122 1 $($(target)_$(source)TOOL.$(bld_trg)) \
1123 2 $($(target)_$(source)TOOL) \
1124 3 $($(target)_TOOL.$(bld_trg)) \
1125 4 $($(target)_TOOL) \
1126 5 $($(source)TOOL) \
1127 6 $($(source)TOOL.$(bld_trg)) \
1128 7 $(TOOL.$(bld_trg)) \
1129 8 $(TOOL) )
1130$(error kBuild: TOOL_$(tool)_LINK_PROGRAM is not defined. target=$(target) )
1131endif
[189]1132$(eval $(TOOL_$(tool)_LINK_PROGRAM))
[272]1133
[353]1134# epilog
1135$(eval $(value def_link_epilog))
[183]1136
[130]1137endef
1138
[353]1139# Process programs
1140EXT := EXE
1141EXTPRE :=
1142definst := $(PATH_BIN)
1143typevar := _PROGRAMS
1144bld_trg_base_var := TARGET
1145$(foreach target, $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)), $(eval $(value def_program)))
[130]1146
1147
[189]1148
[72]1149#
[83]1150# SYSMODS
[72]1151#
1152
[130]1153## System module (one).
[83]1154# @param $(target) Normalized target (program) name.
1155define def_sysmod
[145]1156
[353]1157# prolog
1158$(eval $(value def_link_prolog))
[145]1159
[353]1160# body
[106]1161ifndef TOOL_$(tool)_LINK_SYSMOD
[353]1162$(warning kBuild: tools: \
[221]1163 1 $($(target)_$(source)TOOL.$(bld_trg)) \
[106]1164 2 $($(target)_$(source)TOOL) \
[221]1165 3 $($(target)_TOOL.$(bld_trg)) \
[106]1166 4 $($(target)_TOOL) \
1167 5 $($(source)TOOL) \
[221]1168 6 $($(source)TOOL.$(bld_trg)) \
1169 7 $(TOOL.$(bld_trg)) \
[106]1170 8 $(TOOL) )
[353]1171$(error kBuild: TOOL_$(tool)_LINK_SYSMOD is not defined. target=$(target) )
[183]1172endif
[83]1173$(eval $(TOOL_$(tool)_LINK_SYSMOD))
1174
[353]1175# epilog
1176$(eval $(value def_link_epilog))
[183]1177
[83]1178endef
1179
[130]1180# Process sysmods
[353]1181EXT := SYS
1182EXTPRE :=
1183definst := $(PATH_SYS)
1184typevar := _SYSMODS
1185bld_trg_base_var := TARGET
1186$(foreach target, $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)), $(eval $(value def_sysmod)))
[83]1187
1188
[72]1189#
1190# OTHERS
1191#
[190]1192_OTHERS = $(OTHERS) $(OTHERS.$(BUILD_TARGET))
[72]1193
1194
[353]1195#
1196# INSTALLS
1197#
[72]1198
[353]1199## generate the install rule
1200define def_install_src_rule
1201# the install rule
1202$(insdst) : $(srcsrc) | $(call DIRDEP,$(dir $(insdst)))
1203 $$(RM) -f $$@
1204 $(inscmd)
1205endef
1206
1207## install one file
1208define def_install_src
1209
1210# deal with '=>' in the source file name.
1211srcdst := $(subst =>, ,$(src))
1212srcsrc := $(firstword $(srcdst))
1213srcdst := $(word $(words $(srcdst)),$(srcdst))
1214
1215# _INSTFUN
1216ifdef $(srcsrc)_INSTFUN
1217instfun := $(srcsrc)_INSTFUN
1218else
1219ifdef $(target)_INSTFUN
1220instfun := $(target)_INSTFUN
1221else
1222instfun := _INSTALL_FILE
1223endif
1224endif
1225
1226# _INST
1227ifdef $(srcsrc)_INST
1228inst = $(srcsrc)_INST
1229else
1230ifdef $(target)_INST
1231inst = $(target)_INST
1232else
1233inst =
1234endif
1235endif
1236
1237# calc target
1238insdst := $(call $(instfun),$(srcdst),$(target),$($(inst)),$(PATH_INS))
1239#$(warning instfun=$(instfun) srcdst=$(srcdst) target=$(target) srcdst=$(srcsrc) inst=$(inst) => insdst=$(insdst))
1240
1241# create the command
1242ifdef $(srcsrc)_INSTALLER
1243inscmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(insdst),$(target))
1244else
1245ifdef $(target)_INSTALLER
1246inscmd := $(call $(target)_INSTALLER,$(srcsrc),$(insdst),$(target))
1247else
1248inscmd := $$(CP) $(srcsrc) $(insdst)
1249endif
1250endif
1251
1252# generate the rule (need double evaluation here)
1253$(eval $(def_install_src_rule))
1254
1255INSTARGET_$(target) += $(insdst)
1256endef
1257
1258
1259## generate the symlink rule
1260define def_install_symlink_rule
1261# the install rule
1262$(insdst) : | $(call DIRDEP,$(dir $(insdst)))
1263 $$(RM) -f $$@
1264 $$(LN_SYMLINK) $(srcsrc) $(insdst)
1265endef
1266
1267## create one symlink
1268define def_install_symlink
1269
1270# deal with '=>' in the source file name.
1271srcdst := $(subst =>, ,$(src))
1272srcsrc := $(firstword $(srcdst))
1273srcdst := $(word $(words $(srcdst)),$(srcdst))
1274
1275# _INSTFUN
1276ifdef $(srcsrc)_INSTFUN
1277instfun := $(srcsrc)_INSTFUN
1278else
1279ifdef $(target)_INSTFUN
1280instfun := $(target)_INSTFUN
1281else
1282instfun := _INSTALL_FILE
1283endif
1284endif
1285
1286# _INST
1287ifdef $(srcsrc)_INST
1288inst = $(srcsrc)_INST
1289else
1290ifdef $(target)_INST
1291inst = $(target)_INST
1292else
1293inst =
1294endif
1295endif
1296
1297# calc target
1298insdst := $(call $(instfun),$(srcdst),$(target),$(inst),$(PATH_INS))
1299#$(warning srcsrc=$(srcsrc) srcdst=$(srcdst) insdst=$(insdst))
1300
1301# generate the rule (need double evaluation here)
1302$(eval $(def_install_symlink_rule))
1303
1304INSTARGET_$(target) += $(insdst)
1305endef
1306
1307## process one install target.
1308define def_install
1309bld_type := $(firstword $($(target)_BLD_TYPE) $(BUILD_TYPE))
1310bld_trg := $(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))
1311bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
1312bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU) $(BUILD_TARGET_CPU))
1313
1314INSTARGET_$(target) :=
1315$(foreach src,$($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)), \
1316 $(eval $(value def_install_src)))
1317
1318$(foreach src,$($(target)_SYMLINKS) $($(target)_SYMLINKS.$(bld_trg)) $($(target)_SYMLINKS.$(bld_trg_arch)) $($(target)_SYMLINKS.$(bld_trg_cpu)) $($(target)_SYMLINKS.$(bld_type)), \
1319 $(eval $(value def_install_symlink)))
1320
1321_INSTALLS += $(INSTARGET_$(target))
1322endef
1323
1324## process all install targets
1325$(foreach target, $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)), \
1326 $(eval $(value def_install)))
1327
1328
[72]1329#
1330# DOCS
1331#
1332
1333
1334#
[353]1335# PACKING
[72]1336#
[353]1337packing::
[72]1338
[353]1339
1340#
1341# DIRECTORIES
1342#
1343_DIR_ALL := $(sort $(addsuffix /,$(patsubst %/,%,$(_DIRS))) $(dir $(_OUT_FILES) $(_OBJS) $(_INSTALLS)))
1344
1345define def_mkdir_rule
1346$(directory):
1347 $(call MSG_L1,Creating directory $$@)
1348 $(MKDIR) -p $$@
[72]1349endef
1350
[353]1351$(foreach directory,$(_DIR_ALL),$(eval $(def_mkdir_rule)))
[72]1352
[183]1353
[72]1354#
[353]1355# NOTHING
[72]1356#
[353]1357do-nothing:
1358 $(call MSG_L1,Did nothing in $(CURDIR))
[72]1359
[183]1360
[75]1361#
[353]1362# CLEAN UP
[75]1363#
[353]1364do-clean:
1365 $(RM) -f $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_CLEAN_FILES) $(OTHER_CLEAN)
[72]1366
[98]1367
[353]1368#
1369# PASSES (including directory and makefile walking)
1370#
[221]1371
[75]1372## Subdir
1373# @param $(pass) Lowercase pass name.
1374# @param $(PASS) Uppercase pass name.
1375# @param $(subdir) Subdirectory
1376# @param $(tag) tag to attach to the rule name.
1377define def_pass_subdir
[219]1378pass_$(pass)$(tag):: $(dep)
1379 + $(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass)
[75]1380endef
[72]1381
[75]1382## Submakefile
1383# @param $(pass) Lowercase pass name.
1384# @param $(PASS) Uppercase pass name.
1385# @param $(makefile) Makefile.
1386# @param $(tag) tag to attach to the rule name.
1387define def_pass_makefile
[219]1388pass_$(pass)$(tag):: $(dep)
1389 + $(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass)
[75]1390endef
[73]1391
[75]1392## Execute a pass.
1393# @param $(pass) Lowercase pass name.
1394# @param $(PASS) Uppercase pass name.
[353]1395define def_pass_old
[183]1396$(eval SUBDIRS_$(PASS) ?= $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET)))
1397$(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET)))
1398$(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)))
1399$(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET)))
[75]1400
1401$(eval tag:=_before)
[219]1402$(eval dep:=)
[183]1403$(foreach subdir,$(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_subdir)))
1404$(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)),$(eval $(def_pass_makefile)))
[75]1405
1406$(eval tag:=_after)
[219]1407$(eval dep:=pass_$(pass)_doit)
[183]1408$(foreach subdir,$(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_subdir)))
1409$(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_makefile)))
[75]1410
1411.NOTPARALLEL: pass_$(pass)_before pass_$(pass)_after
1412.PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_doit pass_$(pass)_after
[353]1413pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$(var))
[272]1414pass_$(pass)_this: pass_$(pass)_before
[220]1415 + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
1416pass_$(pass)_after:: pass_$(pass)_this
[219]1417pass_$(pass): pass_$(pass)_after
[75]1418
[183]1419endef
1420
[353]1421define def_pass
1422$(eval SUBDIRS_$(PASS) ?= $(SUBDIRS) $(SUBDIRS.$(BUILD_TARGET)))
1423$(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER) $(SUBDIRS_AFTER.$(BUILD_TARGET)))
1424$(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)))
1425$(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER) $(MAKEFILES_AFTER.$(BUILD_TARGET)))
[183]1426
[353]1427$(eval tag:=_before)
1428$(eval dep:=)
1429$(foreach subdir,$(SUBDIRS_$(PASS)) $(SUBDIRS_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_subdir)))
1430$(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)),$(eval $(def_pass_makefile)))
[75]1431
[353]1432$(eval tag:=_after)
1433$(eval dep:=pass_$(pass)_doit)
1434$(foreach subdir,$(SUBDIRS_AFTER_$(PASS)) $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_subdir)))
1435$(foreach makefile,$(MAKEFILES_AFTER_$(PASS)) $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_makefile)))
[75]1436
[353]1437ifdef KBUILD_SAFE_PARALLELL
1438.NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this
1439.PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this pass_$(pass)_doit
1440pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$(var))
1441pass_$(pass)_this: pass_$(pass)_before
1442 + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
1443pass_$(pass)_after:: pass_$(pass)_this
1444pass_$(pass): pass_$(pass)_after
1445else
1446.NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after
1447.PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
1448pass_$(pass)_doit: pass_$(pass)_before \
1449 $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var)))
1450pass_$(pass): \
1451 pass_$(pass)_before \
1452 pass_$(pass)_doit \
1453 pass_$(pass)_after
1454endif
[189]1455
[353]1456#$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))))
1457endef
[75]1458
[353]1459# Generate the defined passes.
1460$(foreach PASS, $(PASSES), \
1461 $(eval pass := $(PASS_$(PASS)_pass)) \
1462 $(eval $(def_pass)))
[75]1463
[219]1464## Pass order
1465# @param $(pass) Current pass name.
1466# @param $(prev_pass) The previous pass name.
1467define def_pass_order
[353]1468ifdef KBUILD_SAFE_PARALLELL
1469.NOTPARALLEL: pass_$(pass)_order
1470.PHONY: pass_$(pass)_order
[219]1471pass_$(pass)_order: $(pass_prev)
[353]1472 $(call MSG_L1,Pass - $(if $(PASS_$(PASS)),$(PASS_$(PASS)),$(pass)))
[219]1473 + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)
[353]1474else
1475.NOTPARALLEL: pass_$(pass)_order pass_$(pass)_banner
1476.PHONY: pass_$(pass)_order pass_$(pass)_banner
1477pass_$(pass)_banner:
1478 $(call MSG_L1,Pass - $(if $(PASS_$(PASS)),$(PASS_$(PASS)),$(pass)))
1479pass_$(pass)_order: \
1480 $(pass_prev) \
1481 pass_$(pass)_banner \
1482 pass_$(pass)
1483endif
[219]1484$(eval pass_prev := pass_$(pass)_order)
1485endef
[183]1486
[219]1487## PASS: order
1488# Use dependencies to ensure correct pass order.
1489pass_prev :=
[353]1490$(foreach PASS,$(DEFAULT_PASSES),\
1491 $(eval pass := $(PASS_$(PASS)_pass)) \
1492 $(eval $(def_pass_order)))
[219]1493
[272]1494
[75]1495#
1496# THE MAIN RULES
1497#
[219]1498all_recursive: $(pass_prev)
[75]1499
[130]1500rebuild: clean
[219]1501 + $(MAKE) -f $(firstword $(MAKEFILE_LIST)) all_recursive
[78]1502
[353]1503uninstall:
1504 $(RM) -f $(_INSTALLS)
[78]1505
[75]1506# misc shortcuts.
[353]1507targets: bldprogs libraries dlls programs sysmods others install
[75]1508objects: $(_OBJS)
[222]1509bldprogs: $(_BLDPROGS)
[189]1510libraries: $(_LIBS) $(_IMPORT_LIBS) $(_OTHER_LIBRARIES)
[205]1511dlls: $(_DLLS)
[219]1512programs: $(_PROGRAMS)
[205]1513sysmods: $(_SYSMODS)
[353]1514others: $(_OTHERS)
1515install: $(_INSTALLS)
[75]1516
1517
[353]1518#
1519# kBuild debugging stuff.
1520#
1521_SPACE := $(subst ., ,.)
1522_TAB := $(subst ., ,.)
1523define _NEWLINE
1524
1525
1526endef
1527NLTAB = $(_NEWLINE)$(TAB)
1528show_targets:
1529 @$(foreach target, $(ALL_TARGETS),\
1530 @$(ECHO) "target: $(target)" $(NLTAB)\
1531 @$(ECHO) " PATH_$(target)=$(PATH_$(target))" $(NLTAB)\
1532 @$(ECHO) " TARGET_$(target)=$(TARGET_$(target))" $(NLTAB)\
1533 @$(ECHO) " INSTARGET_$(target)=$(INSTARGET_$(target))" $(NLTAB)\
1534$(foreach prop,$(PROPS_SINGLE) $(PROPS_ACCUMULATE) OBJS_, \
1535 $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))) \
1536 $(if $($(target)_$(prop).$(_tmp)),\
1537 @$(ECHO) " $(target)_$(prop).$(_tmp)=$($(target)_$(prop).$(_tmp))" $(NLTAB)) \
1538 $(if $($(target)_$(prop)), $(NLTAB)@$(ECHO) " $(target)_$(prop)=$($(target)_$(prop))" $(NLTAB)) \
1539)\
1540$(foreach prop,$(PROPS_DEFERRED), \
1541 $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))) \
1542 $(if $(value $(target)_$(prop).$(_tmp)),\
1543 @$(ECHO) ' $(target)_$(prop).$(_tmp)=$(value $(TARGET)_$(prop).$(_tmp))' $(NLTAB)) \
1544 $(if $(value $(target)_$(prop)), $(NLTAB)@$(ECHO) ' $(target)_$(prop)=$(value $(target)_$(prop))' $(NLTAB)) \
1545))
1546
1547
1548
1549#
1550# Include dependency files.
1551#
1552$(foreach dep,$(wildcard $(_DEPFILES)),$(eval include $(dep)))
1553
1554
[72]1555# end-of-file-content
[106]1556__footer_kmk__ := target
[72]1557endif # __footer_kmk__
Note: See TracBrowser for help on using the repository browser.