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
Line 
1# $Id: footer.kmk 353 2005-12-12 03:36:07Z bird $
2## @file
3#
4# kBuild - File included at top of makefile.
5#
6# Copyright (c) 2004-2005 knut st. osmundsen <bird-srcspam@anduin.net>
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
13# the Free Software Foundation; either version source of the License, or
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
23# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24#
25#
26
27ifndef __footer_kmk__
28# start-of-file-content
29
30#
31# Variables.
32# (Some of these need initialization before including definitions using them.)
33#
34
35# all targets.
36ALL_TARGETS += \
37 $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)) \
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)) \
43 $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)) \
44 $(OTHERS) $(OTHERS.$(BUILD_TARGET))
45
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
54# Files which only requires cleaning up.
55_CLEAN_FILES :=
56
57# all of a type
58_OBJS :=
59_BLDPROGS :=
60_LIBS :=
61_DLLS :=
62_PROGRAMS :=
63_SYSMODS :=
64_INSTALLS :=
65_OTHERS :=
66_DIRS := $(PATH_TARGET)/
67_IMPORT_LIBS :=
68
69# misc
70pass_prev :=
71
72
73#
74# Basic macros
75#
76
77## Figure out the tool for a source
78# @param $target source file
79# @param $source normalized main target
80# @param $type tooltype
81# @param bld_trg build target.
82_SOURCE_TOOL = $(strip $(firstword \
83 $($(target)_$(source)_$(type)TOOL.$(bld_trg)) \
84 $($(target)_$(source)_$(type)TOOL) \
85 $($(target)_$(source)_TOOL.$(bld_trg)) \
86 $($(target)_$(source)_TOOL) \
87 $($(target)_$(type)TOOL.$(bld_trg)) \
88 $($(target)_$(type)TOOL) \
89 $($(target)_TOOL.$(bld_trg)) \
90 $($(target)_TOOL) \
91 $($(source)_$(type)TOOL.$(bld_trg)) \
92 $($(source)_$(type)TOOL) \
93 $($(source)_TOOL.$(bld_trg)) \
94 $($(source)_TOOL) \
95 $($(type)TOOL.$(bld_trg)) \
96 $($(type)TOOL) \
97 $(TOOL.$(bld_trg)) \
98 $(TOOL) ))
99
100## Figure out the tool for a target.
101# @param $target normalized target.
102# @param $source tooltype.
103# @param bld_trg build target.
104_TARGET_TOOL = $(strip $(firstword \
105 $($(target)_$(source)TOOL.$(bld_trg)) \
106 $($(target)_$(source)TOOL) \
107 $($(target)_TOOL.$(bld_trg)) \
108 $($(target)_TOOL) \
109 $($(source)TOOL.$(bld_trg)) \
110 $($(source)TOOL) \
111 $(TOOL.$(bld_trg)) \
112 $(TOOL) \
113 ))
114
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)))
118
119## Removes the root slash from a path (if it has one)
120# @param $1 the path
121no-root-slash=$(patsubst /%,%,$(1))
122
123## Figure out where to put object files.
124# @param $1 source file
125# @param $2 normalized main target
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)))))))
131
132## Figure out where to put object files.
133# @param $1 real target name.
134# @param $2 normalized main target
135_TARGET_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(basename $(1))))
136
137
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
146#
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#
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)
175include $(firstword $(foreach path, $(TEMPLATE_PATHS) $(PATH_KBUILD)/templates/, $(wildcard $(path)/$(template).kmk)))
176endif
177endef
178$(foreach template, $(_TEMPLATES), $(eval $(def_templates)))
179
180
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
189ifndef $(target)_$(prop)
190ifndef $(target)_$(prop).$(BUILD_TARGET)
191ifdef $(prop)
192$$(eval $(target)_$(prop) := $($(prop)))
193endif
194ifdef $(prop).$(BUILD_TARGET)
195$$(eval $(target)_$(prop).$(BUILD_TARGET) := $($(prop).$(BUILD_TARGET)))
196endif
197endif
198endif
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
205#
206define def_inherit_defaults
207ifdef $(target)_TEMPLATE
208ifeq ($(strip $(TEMPLATE_$($(target)_TEMPLATE)_TOOL) $(TEMPLATE_$($(target)_TEMPLATE)_TOOL.$(BUILD_TARGET))),)
209$$(foreach prop,TOOL, $$(eval $$(def_inherit_defaults_one)))
210endif
211ifeq ($(strip $(TEMPLATE_$($(target)_TEMPLATE)_SDKS) $(TEMPLATE_$($(target)_TEMPLATE)_SDKS.$(BUILD_TARGET))),)
212$$(foreach prop,SDKS, $$(eval $$(def_inherit_defaults_one)))
213endif
214else
215$$(foreach prop,TEMPLATE TOOL SDKS, $$(eval $$(def_inherit_defaults_one)))
216endif
217endef
218# Inherit default properties.
219# !!!!!!THIS IS MESSY AND NOT NECESSARY!!!!!!
220$(foreach target, $(ALL_TARGETS),$(eval $(def_inherit_defaults)))
221
222
223## Inherit one template property in a non-accumulative manner.
224# @param $(prop) Property name
225# @param $(target) Target name
226# @todo fix the precedence order for some properties.
227define def_inherit_template_one
228ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
229ifndef $(target)_$(prop)
230$(target)_$(prop) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
231#$ (warning dbgtarget: $(target)_$(prop):='$(value $(target)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
232endif
233endif
234ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)
235ifndef $(target)_$(prop).$(BUILD_TARGET)
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))
238endif
239endif
240endef
241
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
262## Inherit one template property.
263# @param $(prop) Property name
264# @param $(target) Target name
265define def_inherit_template_one_accumulate
266ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
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)))
270endif
271ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)
272#$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
273$(target)_$(prop).$(BUILD_TYPE) := $($(target)_$(prop).$(BUILD_TYPE)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
274endif
275ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)
276#$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
277$(target)_$(prop).$(BUILD_TARGET) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
278endif
279ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU)
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))
282endif
283ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH)
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))
286endif
287endef
288
289## Inherit template properties for on target.
290# @param $(target) Target name.
291define def_inherit_template
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)))
295endef
296
297# Inherit template properties
298$(foreach target, $(ALL_TARGETS),$(eval $(value def_inherit_template)))
299
300
301#
302# Include tools
303#
304_TOOLS := $(TOOL)
305define def_tools_target_source
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))))
311endef
312
313define def_tools_target
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)))
322endef
323
324$(foreach target, $(ALL_TARGETS), $(eval $(value def_tools_target)))
325_TOOLS := $(sort $(_TOOLS))
326
327define def_tools_include
328ifndef TOOL_$(tool)
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)
332endif
333include $(TOOL_$(tool)_KMK_FILE)
334endif
335endef
336$(foreach tool, $(_TOOLS), $(eval $(value def_tools_include)))
337
338
339#
340# Include SDKs
341#
342_SDKS := $(SDKS)
343define def_sdks_target_source
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)), \
346 $(eval _SDKS += $(sdk)))
347endef
348define def_sdks_target
349$(foreach sdk, $($(target)_SDKS) $($(target)_SDKS.$(BUILD_TARGET)) $($(target)_SDKS.$(BUILD_TYPE))\
350 , $(eval _SDKS += $(sdk)))
351$(foreach source, $($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TYPE))\
352 , $(eval $(def_sdks_target_source)))
353endef
354$(foreach target, $(ALL_TARGETS), $(eval $(def_sdks_target)))
355_SDKS := $(sort $(_SDKS))
356
357define def_sdks_include_one
358ifndef SDK_$(sdk)
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)
362endif
363include $(SDK_$(sdk)_KMK_FILE)
364endif
365endef
366$(foreach sdk, $(_SDKS), $(eval $(value def_sdks_include_one)))
367
368#
369# Object processing.
370#
371
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
380
381
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}
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.
390#
391# @remark I've no clue why I've to $(eval ..) everything in this define. MAKE bug?
392# @remark I now have a clue. Have to use $$ if not.
393define def_target_source_c_cpp_asm
394#$ (warning dbg: def_target_source_c_cpp_asm: source='$(source)' target='$(target)' type='$(type)')
395
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 :=\
401 $(TOOL_$(tool)_DEFS)\
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))\
406 $(TOOL_$(tool)_$(type)DEFS)\
407 $(TOOL_$(tool)_$(type)DEFS.$(bld_type))\
408 $(foreach sdk, $(SDKS.$(bld_trg)) \
409 $(SDKS.$(bld_type)) \
410 $(SDKS),\
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)))\
421 $(DEFS)\
422 $(DEFS.$(bld_type))\
423 $(DEFS.$(bld_trg))\
424 $(DEFS.$(bld_trg_arch))\
425 $(DEFS.$(bld_trg_cpu))\
426 $($(type)DEFS)\
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)) \
433 $($(target)_SDKS),\
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)))\
444 $($(target)_DEFS)\
445 $($(target)_DEFS.$(bld_type))\
446 $($(target)_DEFS.$(bld_trg))\
447 $($(target)_DEFS.$(bld_trg_arch))\
448 $($(target)_DEFS.$(bld_trg_cpu))\
449 $($(target)_$(type)DEFS)\
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)) \
456 $($(source)_SDKS),\
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)))\
467 $($(source)_DEFS)\
468 $($(source)_DEFS.$(bld_type))\
469 $($(source)_DEFS.$(bld_trg))\
470 $($(source)_DEFS.$(bld_trg_arch))\
471 $($(source)_DEFS.$(bld_trg_cpu))\
472 $($(source)_$(type)DEFS)\
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)) \
479 $($(target)_$(source)_SDKS),\
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)))\
490 $($(target)_$(source)_DEFS)\
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))\
495 $($(target)_$(source)_$(type)DEFS)\
496 $($(target)_$(source)_$(type)DEFS.$(bld_type))\
497 $($(target)_$(source)_$(type)DEFS.$(bld_trg))\
498 $($(target)_$(source)_$(type)DEFS.$(bld_trg_arch))\
499 $($(target)_$(source)_$(type)DEFS.$(bld_trg_cpu))
500incs :=\
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))\
505 $($(target)_$(source)_$(type)INCS)\
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))\
510 $($(target)_$(source)_INCS)\
511 $(foreach sdk, $($(target)_$(source)_SDKS.$(bld_trg)) \
512 $($(target)_$(source)_SDKS.$(bld_type)) \
513 $($(target)_$(source)_SDKS),\
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))\
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))\
528 $($(source)_$(type)INCS)\
529 $($(source)_INCS.$(bld_trg_cpu))\
530 $($(source)_INCS.$(bld_trg_arch))\
531 $($(source)_INCS.$(bld_trg))\
532 $($(source)_INCS.$(bld_type))\
533 $($(source)_INCS)\
534 $(foreach sdk, $($(source)_SDKS.$(bld_trg)) \
535 $($(source)_SDKS.$(bld_type)) \
536 $($(source)_SDKS),\
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))\
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))\
551 $($(target)_$(type)INCS)\
552 $($(target)_INCS.$(bld_trg_cpu))\
553 $($(target)_INCS.$(bld_trg_arch))\
554 $($(target)_INCS.$(bld_trg))\
555 $($(target)_INCS.$(bld_type))\
556 $($(target)_INCS)\
557 $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
558 $($(target)_SDKS.$(bld_type)) \
559 $($(target)_SDKS),\
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))\
570 $(INCS.$(bld_trg_cpu))\
571 $(INCS.$(bld_trg_arch))\
572 $(INCS.$(bld_trg))\
573 $(INCS.$(bld_type))\
574 $(INCS)\
575 $(foreach sdk, $(SDKS.$(bld_trg)) \
576 $(SDKS.$(bld_type)) \
577 $(SDKS),\
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))\
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))\
592 $(TOOL_$(tool)_$(type)INCS)
593flags :=\
594 $(TOOL_$(tool)_$(type)FLAGS)\
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))\
599 $($(type)FLAGS)\
600 $($(type)FLAGS.$(bld_type))\
601 $($(type)FLAGS.$(bld_trg))\
602 $($(type)FLAGS.$(bld_trg_arch))\
603 $($(type)FLAGS.$(bld_trg_cpu))\
604 $($(target)_$(type)FLAGS)\
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))\
609 $($(source)_$(type)FLAGS)\
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))\
614 $($(target)_$(source)_$(type)FLAGS)\
615 $($(target)_$(source)_$(type)FLAGS.$(bld_type))\
616 $($(target)_$(source)_$(type)FLAGS.$(bld_trg))\
617 $($(target)_$(source)_$(type)FLAGS.$(bld_trg_arch))\
618 $($(target)_$(source)_$(type)FLAGS.$(bld_trg_cpu))
619objsuff := $(firstword \
620 $($(target)_$(source)_OBJSUFF.$(bld_trg))\
621 $($(target)_$(source)_OBJSUFF)\
622 $($(source)_OBJSUFF.$(bld_trg))\
623 $($(source)_OBJSUFF)\
624 $($(target)_OBJSUFF.$(bld_trg))\
625 $($(target)_OBJSUFF)\
626 $(TOOL_$(tool)_$(type)OBJSUFF.$(bld_trg))\
627 $(TOOL_$(tool)_$(type)OBJSUFF)\
628 $(SUFF_OBJ))
629obj := $(outbase)$(objsuff)
630dep := $(outbase)$(SUFF_DEP)
631deps := \
632 $($(target)_$(source)_DEPS)\
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))\
637 $($(source)_DEPS)\
638 $($(source)_DEPS.$(bld_type))\
639 $($(source)_DEPS.$(bld_trg))\
640 $($(source)_DEPS.$(bld_trg_arch))\
641 $($(source)_DEPS.$(bld_trg_cpu))\
642 $($(target)_DEPS)\
643 $($(target)_DEPS.$(bld_type))\
644 $($(target)_DEPS.$(bld_trg_arch))\
645 $($(target)_DEPS.$(bld_trg_cpu))
646
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))
649ifndef TOOL_$(tool)_COMPILE_$(type)
650$(warning kBuild: tools: \
651 1 $($(target)_$(source)_$(type)TOOL.$(bld_trg)) \
652 2 $($(target)_$(source)_$(type)TOOL) \
653 3 $($(target)_$(source)_TOOL.$(bld_trg)) \
654 4 $($(target)_$(source)_TOOL) \
655 5 $($(target)_$(type)TOOL.$(bld_trg)) \
656 6 $($(target)_$(type)TOOL) \
657 7 $($(target)_TOOL.$(bld_trg)) \
658 8 $($(target)_TOOL) \
659 9 $($(source)_$(type)TOOL.$(bld_trg)) \
660 10 $($(source)_$(type)TOOL) \
661 11 $($(source)_TOOL.$(bld_trg)) \
662 12 $($(source)_TOOL) \
663 13 $($(type)TOOL.$(bld_trg)) \
664 14 $($(type)TOOL) \
665 15 $(TOOL.$(bld_trg)) \
666 16 $(TOOL) )
667$(error kBuild: TOOL_$(tool)_COMPILE_$(type) is not defined. source=$(source) target=$(target) )
668endif
669
670# generate the rules
671$(eval $(TOOL_$(tool)_COMPILE_$(type)))
672
673$(eval $(def_target_obj_rule))
674
675$(target)_OBJS_ += $(obj)
676_DEPFILES += $(dep)
677
678endef
679
680## Generic macro for processing all target sources.
681# @param $(target) Normalized target name.
682define def_target_sources
683#$ (warning def_target_sources)
684# C sources
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)) )
688
689# C++ sources
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)) )
693
694# ASM sources
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
699endef
700
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
710
711
712
713## Generic macro for generating the install rule(s) for a target
714# and update the globals with default out.
715#
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)/))
725
726$(eval $(def_link_install_rule))
727
728_INSTALLS += $(INSTARGET_$(target))
729
730ifdef KBUILD_DO_AUTO_INSTALL
731$(typevar) += $(INSTARGET_$(target))
732else
733$(typevar) += $(out)
734endif
735else # _NOINST
736$(typevar) += $(out)
737endif
738
739_OUT_FILES += $(out)
740_CLEAN_FILES += $($(target)_CLEAN)
741_OBJS += $($(target)_OBJS_)
742
743endef
744
745
746
747#
748# LIBRARIES
749#
750
751## Library (one).
752# @param $(target) Normalized library (target) name.
753define def_lib
754# library basics
755## @todo prefix
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)
761ifeq ($(tool),)
762$(error kBuild: Library target $(target) does not have a tool defined!)
763endif
764outbase := $(call _TARGET_BASE,$(target),$(target))
765PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
766suff := $(firstword\
767 $($(target)_LIBSUFF.$(bld_trg))\
768 $($(target)_LIBSUFF)\
769 $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg))\
770 $(TOOL_$(tool)_ARLIBSUFF)\
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)))
780
781
782# source -> object
783$(eval $(value def_target_sources))
784
785# library linking
786tool := $(call _TARGET_TOOL,$(target),AR)
787outbase := $(call _TARGET_BASE,$(target),$(target))
788flags :=\
789 $(TOOL_$(tool)_ARFLAGS)\
790 $(TOOL_$(tool)_ARFLAGS.$(bld_type))\
791 $(ARFLAGS)\
792 $(ARFLAGS.$(bld_type))\
793 $($(target)_ARFLAGS)\
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)))
803## @todo fix dependencies on makefiles an such
804deps := $($(target)_DEPS)
805
806lib := $(out)
807libsuff := $(suff)
808$(eval $(TOOL_$(tool)_LINK_LIBRARY))
809
810# installing and globals
811definst := $(PATH_LIB)
812typevar :=_LIBS
813$(eval $(value def_target_install_pluss))
814endef
815
816# Process libraries
817$(foreach target, $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)), $(eval $(value def_lib)))
818
819
820#
821# Link operations.
822#
823
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))
837
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
855# source -> object
856$(eval $(value def_target_sources))
857
858# more library stuff.
859tool := $(call _TARGET_TOOL,$(target),LD)
860outbase := $(call _TARGET_BASE,$(target),$(target))
861flags :=\
862 $(TOOL_$(tool)_LDFLAGS)\
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))\
867 $(LDFLAGS)\
868 $(LDFLAGS.$(bld_type))\
869 $(LDFLAGS.$(bld_trg))\
870 $(LDFLAGS.$(bld_trg_arch))\
871 $(LDFLAGS.$(bld_trg_cpu))\
872 $($(target)_LDFLAGS)\
873 $($(target)_LDFLAGS.$(bld_type))\
874 $($(target)_LDFLAGS.$(bld_trg))\
875 $($(target)_LDFLAGS.$(bld_trg_arch))\
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 :=\
885 $($(target)_LIBS.$(bld_trg_cpu))\
886 $($(target)_LIBS.$(bld_trg_arch))\
887 $($(target)_LIBS.$(bld_trg))\
888 $($(target)_LIBS.$(bld_type))\
889 $($(target)_LIBS)\
890 $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
891 $($(target)_SDKS.$(bld_type)) \
892 $($(target)_SDKS),\
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))\
898 $(LIBS.$(bld_trg_cpu))\
899 $(LIBS.$(bld_trg_arch))\
900 $(LIBS.$(bld_trg))\
901 $(LIBS.$(bld_type))\
902 $(LIBS)\
903 $(foreach sdk, $(SDKS.$(bld_trg)) \
904 $(SDKS.$(bld_type)) \
905 $(SDKS),\
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))\
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))\
915 $(TOOL_$(tool)_LIBS)
916libpath :=\
917 $($(target)_LIBPATH.$(bld_trg_cpu))\
918 $($(target)_LIBPATH.$(bld_trg_arch))\
919 $($(target)_LIBPATH.$(bld_trg))\
920 $($(target)_LIBPATH.$(bld_type))\
921 $($(target)_LIBPATH)\
922 $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
923 $($(target)_SDKS.$(bld_type)) \
924 $($(target)_SDKS),\
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))\
930 $(LIBPATH.$(bld_trg_cpu))\
931 $(LIBPATH.$(bld_trg_arch))\
932 $(LIBPATH.$(bld_trg))\
933 $(LIBPATH.$(bld_type))\
934 $(LIBPATH)\
935 $(foreach sdk, $(SDKS.$(bld_trg)) \
936 $(SDKS.$(bld_type)) \
937 $(SDKS),\
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))\
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))\
947 $(TOOL_$(tool)_LIBPATH)
948dirdep := $(call DIRDEP,$(dir $(out)))
949## @todo fix dependencies
950deps := $($(target)_DEPS)
951
952## @todo this stuff can't be working.
953custom_pre := $(strip $(firstword \
954 $($(target)_CUSTOM_PRE.$(bld_trg).$(bld_type))\
955 $($(target)_CUSTOM_PRE.$(bld_trg))\
956 $($(target)_CUSTOM_PRE.$(bld_type))\
957 $($(target)_CUSTOM_PRE)\
958 $(CUSTOM_PRE.$(bld_trg).$(bld_type))\
959 $(CUSTOM_PRE.$(bld_trg))\
960 $(CUSTOM_PRE.$(bld_type))\
961 $(CUSTOM_PRE)\
962))
963custom_post := $(strip $(firstword \
964 $($(target)_CUSTOM_POST.$(bld_trg).$(bld_type))\
965 $($(target)_CUSTOM_POST.$(bld_trg))\
966 $($(target)_CUSTOM_POST.$(bld_type))\
967 $($(target)_CUSTOM_POST)\
968 $(CUSTOM_POST.$(bld_trg).$(bld_type))\
969 $(CUSTOM_POST.$(bld_trg))\
970 $(CUSTOM_POST.$(bld_type))\
971 $(CUSTOM_POST)\
972))
973
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
1065ifndef TOOL_$(tool)_LINK_DLL
1066$(warning kBuild: tools: \
1067 1 $($(target)_$(source)TOOL.$(bld_trg)) \
1068 2 $($(target)_$(source)TOOL) \
1069 3 $($(target)_TOOL.$(bld_trg)) \
1070 4 $($(target)_TOOL) \
1071 5 $($(source)TOOL) \
1072 6 $($(source)TOOL.$(bld_trg)) \
1073 7 $(TOOL.$(bld_trg)) \
1074 8 $(TOOL) )
1075$(error kBuild: TOOL_$(tool)_LINK_DLL is not defined. target=$(target) )
1076endif
1077$(eval $(TOOL_$(tool)_LINK_DLL))
1078
1079# epilog
1080$(eval $(value def_link_epilog))
1081
1082endef
1083
1084# Process dlls
1085EXT := DLL
1086EXTPRE :=
1087definst := $(PATH_DLL)
1088typevar := _DLLS
1089bld_trg_base_var := TARGET
1090$(foreach target, $(DLLS) $(DLLS.$(BUILD_TARGET)), $(eval $(value def_dll)))
1091
1092
1093
1094#
1095# Process import libraries.
1096#
1097# - On OS/2 and windows these are libraries.
1098# - On other platforms they are fake DLLs.
1099ifeq ($(subst win32,os2,$(BUILD_TARGET)),os2)
1100$(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval $(value def_lib)))
1101else
1102$(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval $(value def_dll)))
1103endif
1104$(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), \
1105 $(eval _IMPORT_LIBS += $(if $(INSTARGET_$(target)),$(INSTARGET_$(target)), $(TARGET_$(target)))))
1106
1107
1108#
1109# PROGRAMS
1110#
1111
1112## Program (one).
1113# @param $(target) Normalized target (program) name.
1114define def_program
1115
1116# prolog
1117$(eval $(value def_link_prolog))
1118
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
1132$(eval $(TOOL_$(tool)_LINK_PROGRAM))
1133
1134# epilog
1135$(eval $(value def_link_epilog))
1136
1137endef
1138
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)))
1146
1147
1148
1149#
1150# SYSMODS
1151#
1152
1153## System module (one).
1154# @param $(target) Normalized target (program) name.
1155define def_sysmod
1156
1157# prolog
1158$(eval $(value def_link_prolog))
1159
1160# body
1161ifndef TOOL_$(tool)_LINK_SYSMOD
1162$(warning kBuild: tools: \
1163 1 $($(target)_$(source)TOOL.$(bld_trg)) \
1164 2 $($(target)_$(source)TOOL) \
1165 3 $($(target)_TOOL.$(bld_trg)) \
1166 4 $($(target)_TOOL) \
1167 5 $($(source)TOOL) \
1168 6 $($(source)TOOL.$(bld_trg)) \
1169 7 $(TOOL.$(bld_trg)) \
1170 8 $(TOOL) )
1171$(error kBuild: TOOL_$(tool)_LINK_SYSMOD is not defined. target=$(target) )
1172endif
1173$(eval $(TOOL_$(tool)_LINK_SYSMOD))
1174
1175# epilog
1176$(eval $(value def_link_epilog))
1177
1178endef
1179
1180# Process sysmods
1181EXT := SYS
1182EXTPRE :=
1183definst := $(PATH_SYS)
1184typevar := _SYSMODS
1185bld_trg_base_var := TARGET
1186$(foreach target, $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)), $(eval $(value def_sysmod)))
1187
1188
1189#
1190# OTHERS
1191#
1192_OTHERS = $(OTHERS) $(OTHERS.$(BUILD_TARGET))
1193
1194
1195#
1196# INSTALLS
1197#
1198
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
1329#
1330# DOCS
1331#
1332
1333
1334#
1335# PACKING
1336#
1337packing::
1338
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 $$@
1349endef
1350
1351$(foreach directory,$(_DIR_ALL),$(eval $(def_mkdir_rule)))
1352
1353
1354#
1355# NOTHING
1356#
1357do-nothing:
1358 $(call MSG_L1,Did nothing in $(CURDIR))
1359
1360
1361#
1362# CLEAN UP
1363#
1364do-clean:
1365 $(RM) -f $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_CLEAN_FILES) $(OTHER_CLEAN)
1366
1367
1368#
1369# PASSES (including directory and makefile walking)
1370#
1371
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
1378pass_$(pass)$(tag):: $(dep)
1379 + $(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass)
1380endef
1381
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
1388pass_$(pass)$(tag):: $(dep)
1389 + $(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass)
1390endef
1391
1392## Execute a pass.
1393# @param $(pass) Lowercase pass name.
1394# @param $(PASS) Uppercase pass name.
1395define def_pass_old
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)))
1400
1401$(eval tag:=_before)
1402$(eval dep:=)
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)))
1405
1406$(eval tag:=_after)
1407$(eval dep:=pass_$(pass)_doit)
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)))
1410
1411.NOTPARALLEL: pass_$(pass)_before pass_$(pass)_after
1412.PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_doit pass_$(pass)_after
1413pass_$(pass)_doit: $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$(var))
1414pass_$(pass)_this: pass_$(pass)_before
1415 + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
1416pass_$(pass)_after:: pass_$(pass)_this
1417pass_$(pass): pass_$(pass)_after
1418
1419endef
1420
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)))
1426
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)))
1431
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)))
1436
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
1455
1456#$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))))
1457endef
1458
1459# Generate the defined passes.
1460$(foreach PASS, $(PASSES), \
1461 $(eval pass := $(PASS_$(PASS)_pass)) \
1462 $(eval $(def_pass)))
1463
1464## Pass order
1465# @param $(pass) Current pass name.
1466# @param $(prev_pass) The previous pass name.
1467define def_pass_order
1468ifdef KBUILD_SAFE_PARALLELL
1469.NOTPARALLEL: pass_$(pass)_order
1470.PHONY: pass_$(pass)_order
1471pass_$(pass)_order: $(pass_prev)
1472 $(call MSG_L1,Pass - $(if $(PASS_$(PASS)),$(PASS_$(PASS)),$(pass)))
1473 + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)
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
1484$(eval pass_prev := pass_$(pass)_order)
1485endef
1486
1487## PASS: order
1488# Use dependencies to ensure correct pass order.
1489pass_prev :=
1490$(foreach PASS,$(DEFAULT_PASSES),\
1491 $(eval pass := $(PASS_$(PASS)_pass)) \
1492 $(eval $(def_pass_order)))
1493
1494
1495#
1496# THE MAIN RULES
1497#
1498all_recursive: $(pass_prev)
1499
1500rebuild: clean
1501 + $(MAKE) -f $(firstword $(MAKEFILE_LIST)) all_recursive
1502
1503uninstall:
1504 $(RM) -f $(_INSTALLS)
1505
1506# misc shortcuts.
1507targets: bldprogs libraries dlls programs sysmods others install
1508objects: $(_OBJS)
1509bldprogs: $(_BLDPROGS)
1510libraries: $(_LIBS) $(_IMPORT_LIBS) $(_OTHER_LIBRARIES)
1511dlls: $(_DLLS)
1512programs: $(_PROGRAMS)
1513sysmods: $(_SYSMODS)
1514others: $(_OTHERS)
1515install: $(_INSTALLS)
1516
1517
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
1555# end-of-file-content
1556__footer_kmk__ := target
1557endif # __footer_kmk__
Note: See TracBrowser for help on using the repository browser.