source: trunk/kBuild/footer.kmk@ 144

Last change on this file since 144 was 140, checked in by bird, 21 years ago

others.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 42.9 KB
RevLine 
[72]1# $Id: footer.kmk 140 2004-08-17 14:45:14Z bird $
2## @file
3#
4# kBuild - File included at top of makefile.
5#
[106]6# Copyright (c) source004 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
[106]23# Foundation, Inc., 59 Temple Place, Suite typetype0, Boston, MA 0sourcetargettargettarget-targettype07 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.
[138]36ALL_TARGETS := \
37 $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)) \
38 $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)) \
39 $(DLLS) $(DLLS.$(BUILD_TARGET)) \
40 $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)) \
41 $(OTHERS) $(OTHERS.$(BUILD_TARGET))
[72]42
[75]43# dependency files.
44_DEPFILES :=
45
46# All kind of output files except for _OBJS and _DEPFILES.
47# Compiling or linking definition outputting other things that $@ and any
48# required dependency file must add those output files to this variable.
49_OUT_FILES :=
50
[72]51# all of a type
52_OBJS :=
53_LIBS :=
54_DLLS :=
55_EXES :=
[83]56_SYSMODS:=
[72]57_DIRS :=
58
59# all objs of a specific target
60define def_objs_var
[106]61_OBJS_$target :=
[72]62endef
63$(foreach target, $(ALL_TARGETS), $(eval _OBJS_$(target) := ))
64
65#
[73]66# Basic macros
67#
68
69## Figure out the tool for a source
[106]70# @param $target source file
71# @param $source normalized main target
72# @param $type tooltype
[79]73_SOURCE_TOOL = $(strip $(firstword \
[106]74 $($(target)_$(source)_$(type)TOOL.$(BUILD_TARGET)) \
75 $($(target)_$(source)_$(type)TOOL) \
76 $($(target)_$(source)_TOOL.$(BUILD_TARGET)) \
77 $($(target)_$(source)_TOOL) \
78 $($(target)_$(type)TOOL.$(BUILD_TARGET)) \
79 $($(target)_$(type)TOOL) \
80 $($(target)_TOOL.$(BUILD_TARGET)) \
81 $($(target)_TOOL) \
82 $($(source)_$(type)TOOL.$(BUILD_TARGET)) \
83 $($(source)_$(type)TOOL) \
84 $($(source)_TOOL.$(BUILD_TARGET)) \
85 $($(source)_TOOL) \
86 $($(type)TOOL.$(BUILD_TARGET)) \
87 $($(type)TOOL) \
88 $(TOOL.$(BUILD_TARGET)) \
89 $(TOOL) ))
[73]90
[106]91_SOURCE_TOOL_OLD = $(strip $(firstword \
92 $($(target)_$(source)_$(type)TOOL.$(BUILD_TARGET)) $($(target)_$(source)_TOOL.$(BUILD_TARGET)) \
93 $($(target)_$(source)_$(type)TOOL) $($target_$source_TOOL) \
94 $($(target)_$(type)TOOL.$(BUILD_TARGET)) $($(target)_TOOL.$(BUILD_TARGET)) \
95 $($(target)_$(type)TOOL) $($target_TOOL) \
96 $($(source)_$(type)TOOL.$(BUILD_TARGET)) $($(source)_TOOL.$(BUILD_TARGET)) \
97 $($(source)_$(type)TOOL) $($(source)_TOOL) \
98 $($(type)TOOL.$(BUILD_TARGET)) $(TOOL.$(BUILD_TARGET)) \
99 $($(type)TOOL) $(TOOL) ))
100
[78]101## Figure out the tool for a target.
[106]102# @param $target normalized target.
103# @param $source tooltype.
[79]104_TARGET_TOOL = $(strip $(firstword \
[106]105 $($(target)_$(source)TOOL.$(BUILD_TARGET)) \
106 $($(target)_$(source)TOOL) \
107 $($(target)_TOOL.$(BUILD_TARGET)) \
108 $($(target)_TOOL) \
109 $($(source)TOOL) \
110 $($(source)TOOL.$(BUILD_TARGET)) \
111 $(TOOL.$(BUILD_TARGET)) \
112 $(TOOL) \
[79]113 ))
[78]114
[73]115## Figure out where to put object files.
[110]116# @param $1 source file
117# @param $2 normalized main target
118_OBJECT_BASE = $(PATH_TARGET)/$(2)/$(basename $(1))
[73]119
120## Figure out where to put object files.
[110]121# @param $1 real target name.
122# @param $2 normalized main target
123_TARGET_BASE = $(PATH_TARGET)/$(2)/$(basename $(1))
[73]124
125
126#
[72]127# Include templates
128#
129_TEMPLATES := $(TEMPLATE)
130define def_templates
131ifdef $(target)_TEMPLATE
132_TEMPLATES += $($(target)_TEMPLATE)
133endif
134endef
135$(foreach target, $(ALL_TARGETS), $(eval $(def_templates)))
136_TEMPLATES := $(sort $(_TEMPLATES))
137# $ (warning dbg: _TEMPLATES=$(_TEMPLATES))
138
139define def_templates_include
140ifndef TEMPLATE_$(template)
141include $(firstword $(wildcard $(PATH_KBUILD)/templates/$(template).kmk))
142endif
143endef
144$(foreach template, $(_TEMPLATES), $(eval $(def_templates)))
145
[74]146
[72]147#
148# Common Inheritance
149#
150
151## Inherit defaults property
152# @param $(prop) Property name
153# @param $(target) Target name.
154define def_inherit_defaults_one
[74]155ifndef $(target)_$(prop)
[109]156ifndef $(target)_$(prop).$(BUILD_TARGET)
[72]157ifdef $(prop)
[105]158$$(eval $(target)_$(prop) := $($(prop)))
[72]159endif
[109]160ifdef $(prop).$(BUILD_TARGET)
161$$(eval $(target)_$(prop).$(BUILD_TARGET) := $($(prop).$(BUILD_TARGET)))
[72]162endif
[109]163endif
164endif
[72]165endef
166
167## Inherit default properties for one target.
168# A bit tricky this one, but it depends a bit on whether or not TEMPLATE
169# is inherited from the default properties.
170# @param $(target) Target name
[78]171#
[72]172define def_inherit_defaults
173ifdef $(target)_TEMPLATE
[107]174ifeq ($(strip $(TEMPLATE_$($(target)_TEMPLATE)_TOOL) $(TEMPLATE_$($(target)_TEMPLATE)_TOOL.$(BUILD_TARGET))),)
[109]175$$(foreach prop,TOOL, $$(eval $$(def_inherit_defaults_one)))
[72]176endif
[107]177ifeq ($(strip $(TEMPLATE_$($(target)_TEMPLATE)_SDKS) $(TEMPLATE_$($(target)_TEMPLATE)_SDKS.$(BUILD_TARGET))),)
[109]178$$(foreach prop,SDKS, $$(eval $$(def_inherit_defaults_one)))
[72]179endif
180else
[109]181$$(foreach prop,TEMPLATE TOOL SDKS, $$(eval $$(def_inherit_defaults_one)))
[72]182endif
183endef
184# Inherit default properties.
[109]185# !!!!!!THIS IS MESSY AND NOT NECESSARY!!!!!!
[105]186$(foreach target, $(ALL_TARGETS),$(eval $(def_inherit_defaults)))
[72]187
188
[78]189## Inherit one template property in a accumulative manner.
[72]190# @param $(prop) Property name
191# @param $(target) Target name
[78]192# @todo fix the precedence order for some properties.
[72]193define def_inherit_template_one
[78]194ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
[72]195ifndef $(target)_$(prop)
[106]196#$$ (warning dbgtarget: $(target)_$(prop):='$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
[105]197$$(target)_$$(prop) := $$(TEMPLATE_$$($$(target)_TEMPLATE)_$$(prop))
[72]198endif
199endif
[79]200ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)
201ifndef $(target)_$(prop).$(BUILD_TARGET)
[106]202#$$ (warning dbgsource: $(target)_$(prop).$(BUILD_TARGET)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
[105]203$$(target)_$$(prop).$$(BUILD_TARGET) := $$(TEMPLATE_$$($$(target)_TEMPLATE)_$$(prop).$$(BUILD_TARGET))
[79]204endif
205endif
[72]206endef
207
[78]208## Inherit one template property.
209# @param $(prop) Property name
210# @param $(target) Target name
211define def_inherit_template_one_accumulate
212ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
[106]213#$$ (warning dbgtype: TEMPLATE_$($(target)_TEMPLATE)_$(prop) $(target)_$(prop)=$($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
[105]214$$(eval $(target)_$(prop) := $($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
[106]215#$$ (warning dbgtype: $(target)_$(prop)=$($(target)_$(prop)))
[78]216endif
[79]217ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)
[105]218#$$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
219$$(eval $(target)_$(prop).$(BUILD_TARGET) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)))
[79]220endif
221ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU)
[105]222#$$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU))
223$$(eval $(target)_$(prop).$(BUILD_TARGET_CPU) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU)))
[79]224endif
225ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH)
[105]226#$$ (warning dbg6: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH))
227$$(eval $(target)_$(prop).$(BUILD_TARGET_ARCH) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH)))
[79]228endif
[78]229endef
230
[106]231
[72]232## Inherit template properties for on target.
233# @param $(target) Target name.
234define def_inherit_template
[105]235$$(foreach prop, TOOL ARTOOL CTOOL CXXTOOL ASTOOL LDTOOL\
236 ,$$(eval $$(def_inherit_template_one)))
237$$(foreach prop,SDKS DEFS INCS COPTS CFLAGS CDEFS CINCS CXXOPTS CXXFLAGS CXXDEFS CXXINCS ASOPTS ASFLAGS ASDEFS ASINCS LDFLAGS LIBS LIBPATH \
238 ,$$(eval $$(def_inherit_template_one_accumulate)))
[72]239endef
240# Inherit template properties
[105]241$(foreach target, $(ALL_TARGETS),$(eval $(def_inherit_template)))
[72]242
243
244#
245# Include tools
246#
247_TOOLS := $(TOOL)
248define def_tools_target_source
[78]249$(foreach tool,\
[79]250 $($(source)_TOOL.$(BUILD_TARGET)) $($(target)_$(source)_TOOL.$(BUILD_TARGET))\
[78]251 $($(source)_TOOL) $($(target)_$(source)_TOOL)\
[79]252 $($(source)_CTOOL.$(BUILD_TARGET)) $($(target)_$(source)_CTOOL.$(BUILD_TARGET))\
[78]253 $($(source)_CTOOL) $($(target)_$(source)_CTOOL)\
[79]254 $($(source)_CXXTOOL.$(BUILD_TARGET)) $($(target)_$(source)_CXXTOOL.$(BUILD_TARGET))\
[78]255 $($(source)_CXXTOOL) $($(target)_$(source)_CXXTOOL)\
[79]256 $($(source)_ASTOOL.$(BUILD_TARGET)) $($(target)_$(source)_ASTOOL.$(BUILD_TARGET))\
[78]257 $($(source)_ASTOOL) $($(target)_$(source)_ASTOOL)\
[79]258 $($(source)_ARTOOL.$(BUILD_TARGET)) $($(target)_$(source)_ARTOOL.$(BUILD_TARGET))\
[78]259 $($(source)_ARTOOL) $($(target)_$(source)_ARTOOL)\
[79]260 $($(source)_LDTOOL.$(BUILD_TARGET)) $($(target)_$(source)_LDTOOL.$(BUILD_TARGET))\
[78]261 $($(source)_LDTOOL) $($(target)_$(source)_LDTOOL)\
262 ,$(eval _TOOLS += $(tool)))
[72]263endef
264define def_tools_target
[78]265$(foreach tool,\
[79]266 $($(target)_TOOL.$(BUILD_TARGET))\
[78]267 $($(target)_TOOL)\
[79]268 $($(target)_CTOOL.$(BUILD_TARGET))\
[78]269 $($(target)_CTOOL)\
[79]270 $($(target)_CXXTOOL.$(BUILD_TARGET))\
[78]271 $($(target)_CXXTOOL)\
[79]272 $($(target)_ASTOOL.$(BUILD_TARGET))\
[78]273 $($(target)_ASTOOL)\
[79]274 $($(target)_ARTOOL.$(BUILD_TARGET))\
[78]275 $($(target)_ARTOOL)\
[79]276 $($(target)_LDTOOL.$(BUILD_TARGET))\
[78]277 $($(target)_LDTOOL)\
[79]278 ,$(eval _TOOLS += $(tool)))
[120]279$(foreach source, $($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE)) \
280 , $(eval $(def_tools_target_source)))
[72]281endef
282$(foreach target, $(ALL_TARGETS), $(eval $(def_tools_target)))
283_TOOLS := $(sort $(_TOOLS))
284
285define def_tools_include
286ifndef TOOL_$(tool)
287include $(firstword $(wildcard $(PATH_KBUILD)/tools/$(tool).kmk))
288endif
289endef
290$(foreach tool, $(_TOOLS), $(eval $(def_tools_include)))
291
292
293#
294# Include SDKs
[73]295#
[72]296_SDKS := $(SDKS)
297define def_sdks_target_source
[122]298$(foreach sdk, $($(source)_SDKS) $($(source)_SDKS.$(BUILD_TARGET)) $($(source)_SDKS.$(BUILD_MODE)) \
299 $($(target)_$(source)_SDKS) $($(target)_$(source)_SDKS.$(BUILD_TARGET)) $($(target)_$(source)_SDKS.$(BUILD_MODE)), \
[72]300 $(eval _SDKS += $(sdk)))
301endef
302define def_sdks_target
[122]303$(foreach sdk, $($(target)_SDKS) $($(target)_SDKS.$(BUILD_TARGET)) $($(target)_SDKS.$(BUILD_MODE))\
304 , $(eval _SDKS += $(sdk)))
[120]305$(foreach source, $($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE))\
306 , $(eval $(def_sdks_target_source)))
[72]307endef
308$(foreach target, $(ALL_TARGETS), $(eval $(def_sdks_target)))
309_SDKS := $(sort $(_SDKS))
310
[122]311define def_sdks_include_one
[72]312ifndef SDK_$(sdk)
313include $(firstword $(wildcard $(PATH_KBUILD)/sdks/$(sdk).kmk))
314endif
315endef
[122]316$(foreach sdk, $(_SDKS), $(eval $(def_sdks_include_one)))
[72]317
[73]318#
319# Object processing.
320#
[72]321
[73]322## Generic macro for processing C, C++ and Assembly sources.
323# @param $(target) Normalized target name.
324# @param $(source) Source file name.
325# @param $(type) Source type. {C,CXX,AS}
[72]326#
[73]327# @remark I've no clue why I've to $(eval ..) everything in this define. MAKE bug?
[105]328# @remark I now have a clue. Have to use $$ if not.
[73]329define def_target_source_c_cpp_asm
[105]330#$ (warning dbg: def_target_source_c_cpp_asm: source='$(source)' target='$(target)' type='$(type)')
[73]331
[78]332$(eval tool:=$(call _SOURCE_TOOL,$(source),$(target),$(type)))
[111]333$(eval outbase := $(call _OBJECT_BASE,$(source),$(target)))
334$(eval PATH_$(target)_$(source) := $(patsubst %/,%,$(dir $(outbase))))
335$(eval dirdep := $(dir $(outbase)).dir_created)
[73]336$(eval defs :=\
[78]337 $(TOOL_$(tool)_DEFS)\
338 $(TOOL_$(tool)_DEFS.$(BUILD_TYPE))\
339 $(TOOL_$(tool)_DEFS.$(BUILD_TARGET))\
340 $(TOOL_$(tool)_DEFS.$(BUILD_TARGET_ARCH))\
341 $(TOOL_$(tool)_DEFS.$(BUILD_TARGET_CPU))\
[74]342 $(TOOL_$(tool)_$(type)DEFS)\
343 $(TOOL_$(tool)_$(type)DEFS.$(BUILD_TYPE))\
[78]344 $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
345 $(SDKS.$(BUILD_TYPE)) \
346 $(SDKS),\
347 $(SDK_$(sdk)_DEFS)\
348 $(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
349 $(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
350 $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
[133]351 $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))\
[78]352 $(SDK_$(sdk)_$(type)DEFS)\
353 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
354 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
355 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
356 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
[74]357 $(DEFS)\
358 $(DEFS.$(BUILD_TYPE))\
[78]359 $(DEFS.$(BUILD_TARGET))\
360 $(DEFS.$(BUILD_TARGET_ARCH))\
361 $(DEFS.$(BUILD_TARGET_CPU))\
362 $($(type)DEFS)\
363 $($(type)DEFS.$(BUILD_TYPE))\
364 $($(type)DEFS.$(BUILD_TARGET))\
365 $($(type)DEFS.$(BUILD_TARGET_ARCH))\
366 $($(type)DEFS.$(BUILD_TARGET_CPU))\
367 $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
368 $($(target)_SDKS.$(BUILD_TYPE)) \
369 $($(target)_SDKS),\
370 $(SDK_$(sdk)_DEFS)\
371 $(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
372 $(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
373 $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
[133]374 $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))\
[78]375 $(SDK_$(sdk)_$(type)DEFS)\
376 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
377 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
378 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
379 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
[74]380 $($(target)_DEFS)\
381 $($(target)_DEFS.$(BUILD_TYPE))\
382 $($(target)_DEFS.$(BUILD_TARGET))\
[78]383 $($(target)_DEFS.$(BUILD_TARGET_ARCH))\
384 $($(target)_DEFS.$(BUILD_TARGET_CPU))\
385 $($(target)_$(type)DEFS)\
386 $($(target)_$(type)DEFS.$(BUILD_TYPE))\
387 $($(target)_$(type)DEFS.$(BUILD_TARGET))\
388 $($(target)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
389 $($(target)_$(type)DEFS.$(BUILD_TARGET_CPU))\
390 $(foreach sdk, $($(source)_SDKS.$(BUILD_TARGET)) \
391 $($(source)_SDKS.$(BUILD_TYPE)) \
392 $($(source)_SDKS),\
393 $(SDK_$(sdk)_DEFS)\
394 $(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
395 $(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
396 $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
[133]397 $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))\
[78]398 $(SDK_$(sdk)_$(type)DEFS)\
399 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
400 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
401 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
402 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
[74]403 $($(source)_DEFS)\
404 $($(source)_DEFS.$(BUILD_TYPE))\
405 $($(source)_DEFS.$(BUILD_TARGET))\
[78]406 $($(source)_DEFS.$(BUILD_TARGET_ARCH))\
407 $($(source)_DEFS.$(BUILD_TARGET_CPU))\
[73]408 $($(source)_$(type)DEFS)\
[74]409 $($(source)_$(type)DEFS.$(BUILD_TYPE))\
410 $($(source)_$(type)DEFS.$(BUILD_TARGET))\
[78]411 $($(source)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
412 $($(source)_$(type)DEFS.$(BUILD_TARGET_CPU))\
413 $(foreach sdk, $($(target)_$(source)_SDKS.$(BUILD_TARGET)) \
414 $($(target)_$(source)_SDKS.$(BUILD_TYPE)) \
415 $($(target)_$(source)_SDKS),\
416 $(SDK_$(sdk)_DEFS)\
417 $(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
418 $(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
419 $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
[133]420 $(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))\
[78]421 $(SDK_$(sdk)_$(type)DEFS)\
422 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
423 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
424 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
425 $(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
[74]426 $($(target)_$(source)_DEFS)\
427 $($(target)_$(source)_DEFS.$(BUILD_TYPE))\
428 $($(target)_$(source)_DEFS.$(BUILD_TARGET))\
[78]429 $($(target)_$(source)_DEFS.$(BUILD_TARGET_ARCH))\
430 $($(target)_$(source)_DEFS.$(BUILD_TARGET_CPU))\
[74]431 $($(target)_$(source)_$(type)DEFS)\
432 $($(target)_$(source)_$(type)DEFS.$(BUILD_TYPE))\
433 $($(target)_$(source)_$(type)DEFS.$(BUILD_TARGET))\
[78]434 $($(target)_$(source)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
435 $($(target)_$(source)_$(type)DEFS.$(BUILD_TARGET_CPU))\
[73]436 )
437$(eval incs :=\
[78]438 $($(target)_$(source)_$(type)INCS.$(BUILD_TARGET_CPU))\
439 $($(target)_$(source)_$(type)INCS.$(BUILD_TARGET_ARCH))\
[74]440 $($(target)_$(source)_$(type)INCS.$(BUILD_TARGET))\
441 $($(target)_$(source)_$(type)INCS.$(BUILD_TYPE))\
[73]442 $($(target)_$(source)_$(type)INCS)\
[78]443 $($(target)_$(source)_INCS.$(BUILD_TARGET_CPU))\
444 $($(target)_$(source)_INCS.$(BUILD_TARGET_ARCH))\
[74]445 $($(target)_$(source)_INCS.$(BUILD_TARGET))\
446 $($(target)_$(source)_INCS.$(BUILD_TYPE))\
[73]447 $($(target)_$(source)_INCS)\
[78]448 $(foreach sdk, $($(target)_$(source)_SDKS.$(BUILD_TARGET)) \
449 $($(target)_$(source)_SDKS.$(BUILD_TYPE)) \
[133]450 $($(target)_$(source)_SDKS),\
[78]451 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
452 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
453 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
454 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
455 $(SDK_$(sdk)_$(type)INCS)\
456 $(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
457 $(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
458 $(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
459 $(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
460 $(SDK_$(sdk)_INCS))\
461 $($(source)_$(type)INCS.$(BUILD_TARGET_CPU))\
462 $($(source)_$(type)INCS.$(BUILD_TARGET_ARCH))\
[74]463 $($(source)_$(type)INCS.$(BUILD_TARGET))\
464 $($(source)_$(type)INCS.$(BUILD_TYPE))\
[73]465 $($(source)_$(type)INCS)\
[78]466 $($(source)_INCS.$(BUILD_TARGET_CPU))\
467 $($(source)_INCS.$(BUILD_TARGET_ARCH))\
[74]468 $($(source)_INCS.$(BUILD_TARGET))\
469 $($(source)_INCS.$(BUILD_TYPE))\
[73]470 $($(source)_INCS)\
[78]471 $(foreach sdk, $($(source)_SDKS.$(BUILD_TARGET)) \
472 $($(source)_SDKS.$(BUILD_TYPE)) \
473 $($(source)_SDKS),\
474 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
475 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
476 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
477 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
478 $(SDK_$(sdk)_$(type)INCS)\
479 $(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
480 $(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
481 $(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
482 $(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
483 $(SDK_$(sdk)_INCS))\
484 $($(target)_$(type)INCS.$(BUILD_TARGET_CPU))\
485 $($(target)_$(type)INCS.$(BUILD_TARGET_ARCH))\
[74]486 $($(target)_$(type)INCS.$(BUILD_TARGET))\
487 $($(target)_$(type)INCS.$(BUILD_TYPE))\
[73]488 $($(target)_$(type)INCS)\
[78]489 $($(target)_INCS.$(BUILD_TARGET_CPU))\
490 $($(target)_INCS.$(BUILD_TARGET_ARCH))\
[74]491 $($(target)_INCS.$(BUILD_TARGET))\
492 $($(target)_INCS.$(BUILD_TYPE))\
[73]493 $($(target)_INCS)\
[78]494 $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
495 $($(target)_SDKS.$(BUILD_TYPE)) \
496 $($(target)_SDKS),\
497 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
498 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
499 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
500 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
501 $(SDK_$(sdk)_$(type)INCS)\
502 $(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
503 $(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
504 $(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
505 $(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
506 $(SDK_$(sdk)_INCS))\
507 $(INCS.$(BUILD_TARGET_CPU))\
508 $(INCS.$(BUILD_TARGET_ARCH))\
[74]509 $(INCS.$(BUILD_TARGET))\
510 $(INCS.$(BUILD_TYPE))\
[73]511 $(INCS)\
[78]512 $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
513 $(SDKS.$(BUILD_TYPE)) \
514 $(SDKS),\
515 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
516 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
517 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
518 $(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
519 $(SDK_$(sdk)_$(type)INCS)\
520 $(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
521 $(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
522 $(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
523 $(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
524 $(SDK_$(sdk)_INCS))\
525 $(TOOL_$(tool)_$(type)INCS.$(BUILD_TARGET_CPU))\
526 $(TOOL_$(tool)_$(type)INCS.$(BUILD_TARGET_ARCH))\
[74]527 $(TOOL_$(tool)_$(type)INCS.$(BUILD_TARGET))\
528 $(TOOL_$(tool)_$(type)INCS.$(BUILD_TYPE))\
[73]529 $(TOOL_$(tool)_$(type)INCS)\
530 )
531$(eval flags :=\
532 $(TOOL_$(tool)_$(type)FLAGS)\
533 $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TYPE))\
[74]534 $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TARGET))\
[78]535 $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
536 $(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
[73]537 $($(type)FLAGS)\
538 $($(type)FLAGS.$(BUILD_TYPE))\
[74]539 $($(type)FLAGS.$(BUILD_TARGET))\
[78]540 $($(type)FLAGS.$(BUILD_TARGET_ARCH))\
541 $($(type)FLAGS.$(BUILD_TARGET_CPU))\
[73]542 $($(target)_$(type)FLAGS)\
543 $($(target)_$(type)FLAGS.$(BUILD_TYPE))\
[74]544 $($(target)_$(type)FLAGS.$(BUILD_TARGET))\
[78]545 $($(target)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
546 $($(target)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
[73]547 $($(source)_$(type)FLAGS)\
548 $($(source)_$(type)FLAGS.$(BUILD_TYPE))\
[74]549 $($(source)_$(type)FLAGS.$(BUILD_TARGET))\
[78]550 $($(source)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
551 $($(source)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
[73]552 $($(target)_$(source)_$(type)FLAGS)\
553 $($(target)_$(source)_$(type)FLAGS.$(BUILD_TYPE))\
[74]554 $($(target)_$(source)_$(type)FLAGS.$(BUILD_TARGET))\
[78]555 $($(target)_$(source)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
556 $($(target)_$(source)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
[73]557 )
[74]558$(eval objsuff := $(firstword \
559 $($(target)_$(source)_OBJSUFF.$(BUILD_TARGET))\
560 $($(target)_$(source)_OBJSUFF)\
561 $($(source)_OBJSUFF.$(BUILD_TARGET))\
562 $($(source)_OBJSUFF)\
563 $($(target)_OBJSUFF.$(BUILD_TARGET))\
564 $($(target)_OBJSUFF)\
565 $(TOOL_$(tool)_$(type)OBJSUFF.$(BUILD_TARGET))\
566 $(TOOL_$(tool)_$(type)OBJSUFF)\
567 $(SUFF_OBJ)\
568 ))
[73]569$(eval obj := $(outbase)$(objsuff))
[74]570$(eval dep := $(outbase)$(SUFF_DEP))
[73]571
572#$ (warning dbg: target=$(target) source=$(source) tool=$(tool) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff))
[97]573ifndef TOOL_$(tool)_COMPILE_$(type)
574$$(warning kBuild: TOOL_$(tool)_COMPILE_$(type) is not defined. source=$(source) target=$(target) )
575$$(warning kBuild: tools: \
[106]576 1 $($(target)_$(source)_$(type)TOOL.$(BUILD_TARGET)) \
577 2 $($(target)_$(source)_$(type)TOOL) \
578 3 $($(target)_$(source)_TOOL.$(BUILD_TARGET)) \
579 4 $($(target)_$(source)_TOOL) \
580 5 $($(target)_$(type)TOOL.$(BUILD_TARGET)) \
581 6 $($(target)_$(type)TOOL) \
582 7 $($(target)_TOOL.$(BUILD_TARGET)) \
583 8 $($(target)_TOOL) \
584 9 $($(source)_$(type)TOOL.$(BUILD_TARGET)) \
585 10 $($(source)_$(type)TOOL) \
586 11 $($(source)_TOOL.$(BUILD_TARGET)) \
587 12 $($(source)_TOOL) \
588 13 $($(type)TOOL.$(BUILD_TARGET)) \
589 14 $($(type)TOOL) \
590 15 $(TOOL.$(BUILD_TARGET)) \
591 16 $(TOOL) )
[97]592endif
[73]593$(eval $(TOOL_$(tool)_COMPILE_$(type)))
594
595$(eval _OBJS_$(target) += $(obj))
596$(eval _DEPFILES += $(dep))
597
598endef
599
600## Generic macro for processing all target sources.
[74]601# @param $(target) Normalized target name.
[73]602define def_target_sources
603#$ (warning def_target_sources)
604# C sources
[120]605$(foreach type,C,$(foreach source, $(filter %.c, $($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE)))\
[73]606 ,$(eval $(def_target_source_c_cpp_asm)) ))
607
608# C++ sources
[120]609$(foreach type,CXX,$(foreach source, $(filter %.cpp %.cxx %.xx, $($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE)))\
[73]610 ,$(eval $(def_target_source_c_cpp_asm)) ))
611
612# ASM sources
[120]613$(foreach type,AS,$(foreach source, $(filter %.asm %.s %.S, $($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE)))\
[73]614 ,$(eval $(def_target_source_c_cpp_asm)) ))
615endef
616
617
618#
[72]619# LIBRARIES
[73]620#
[72]621
622## Library (one).
[74]623# @param $(target) Normalized library (target) name.
[72]624define def_lib
[73]625# source -> object
626$(eval $(def_target_sources))
[72]627
[73]628# library
[78]629$(eval tool := $(call _TARGET_TOOL,$(target),AR))
630ifeq ($(tool),)
631$$(error kBuild: Library target $(target) doesn't have a tool defined!)
632endif
[111]633## @todo prefix
634$(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
635$(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
[126]636$(eval libsuff := $(firstword\
637 $($(target)_LIBSUFF.$(BUILD_TARGET))\
638 $($(target)_LIBSUFF)\
639 $(TOOL_$(tool)_ARLIBSUFF.$(BUILD_TARGET))\
640 $(TOOL_$(tool)_ARLIBSUFF)\
641 $(SUFF_LIB)\
642))
[111]643$(eval lib := $(outbase)$(libsuff))
[74]644$(eval flags :=\
645 $(TOOL_$(tool)_ARFLAGS)\
646 $(TOOL_$(tool)_ARFLAGS.$(BUILD_TYPE))\
647 $(ARFLAGS)\
648 $(ARFLAGS.$(BUILD_TYPE))\
649 $($(target)_ARFLAGS)\
650 $($(target)_ARFLAGS.$(BUILD_TYPE))\
651 )
[73]652$(eval objs = $(_OBJS_$(target)))
[120]653$(eval othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE))))
[73]654$(eval dirdep := $(dir $(lib)).dir_created)
[78]655## @todo fix dependencies on makefiles an such
[73]656$(eval deps := )
[72]657
[73]658$(eval $(TOOL_$(tool)_LINK_LIBRARY))
[72]659
[126]660# publish rule (still need work)
[131]661ifndef $(target)_NOINST
[126]662$(eval publib := $(PATH_LIB)/$(notdir $(lib)))
663$(publib) : $(lib) $(dir $(publib)).dir_created
[130]664 $(CP) $(lib) $(publib)
[126]665
666_LIBS += $(publib)
667_OUT_FILES += $(lib) $(publib)
668else
[73]669_LIBS += $(lib)
[75]670_OUT_FILES += $(lib)
[126]671endif
672_OBJS += $(_OBJS_$(target))
[72]673endef
674
675# Process libraries
[138]676$(foreach target, $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)), $(eval $(def_lib)))
[72]677
678
679
680#
681# PROGRAMS
682#
683
[74]684## Program (one).
685# @param $(target) Normalized target (program) name.
686define def_program
687# source -> object
688$(eval $(def_target_sources))
[72]689
[74]690# library
[78]691$(eval tool := $(call _TARGET_TOOL,$(target),LD))
[111]692$(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
693$(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
694$(eval exesuff := $(firstword $($(target)_EXESUFF) $($(target)_EXESUFF) $(TOOL_$(tool)_LDEXESUFF) $(SUFF_EXE)))
695$(eval exe := $(outbase)$(exesuff))
696$(eval objs = $(_OBJS_$(target)))
[74]697$(eval flags :=\
698 $(TOOL_$(tool)_LDFLAGS)\
699 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TYPE))\
[89]700 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET))\
701 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_ARCH))\
702 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_CPU))\
[74]703 $(LDFLAGS)\
704 $(LDFLAGS.$(BUILD_TYPE))\
[89]705 $(LDFLAGS.$(BUILD_TARGET))\
706 $(LDFLAGS.$(BUILD_TARGET_ARCH))\
707 $(LDFLAGS.$(BUILD_TARGET_CPU))\
[74]708 $($(target)_LDFLAGS)\
709 $($(target)_LDFLAGS.$(BUILD_TYPE))\
[89]710 $($(target)_LDFLAGS.$(BUILD_TARGET))\
711 $($(target)_LDFLAGS.$(BUILD_TARGET_ARCH))\
712 $($(target)_LDFLAGS.$(BUILD_TARGET_CPU))\
[74]713)
714$(eval libs :=\
[87]715 $($(target)_LIBS.$(BUILD_TARGET_CPU))\
716 $($(target)_LIBS.$(BUILD_TARGET_ARCH))\
717 $($(target)_LIBS.$(BUILD_TARGET))\
[74]718 $($(target)_LIBS.$(BUILD_TYPE))\
719 $($(target)_LIBS)\
[122]720 $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
721 $($(target)_SDKS.$(BUILD_TYPE)) \
722 $($(target)_SDKS),\
723 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
724 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
725 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
726 $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
727 $(SDK_$(sdk)_LIBS))\
[87]728 $(LIBS.$(BUILD_TARGET_CPU))\
729 $(LIBS.$(BUILD_TARGET_ARCH))\
730 $(LIBS.$(BUILD_TARGET))\
[74]731 $(LIBS.$(BUILD_TYPE))\
732 $(LIBS)\
[122]733 $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
734 $(SDKS.$(BUILD_TYPE)) \
735 $(SDKS),\
736 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
737 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
738 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
739 $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
740 $(SDK_$(sdk)_LIBS))\
741 $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_CPU))\
742 $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_ARCH))\
743 $(TOOL_$(tool)_LIBS.$(BUILD_TARGET))\
[74]744 $(TOOL_$(tool)_LIBS.$(BUILD_TYPE))\
745 $(TOOL_$(tool)_LIBS)\
746)
747$(eval libpath :=\
[87]748 $($(target)_LIBPATH.$(BUILD_TARGET_CPU))\
749 $($(target)_LIBPATH.$(BUILD_TARGET_ARCH))\
750 $($(target)_LIBPATH.$(BUILD_TARGET))\
[74]751 $($(target)_LIBPATH.$(BUILD_TYPE))\
752 $($(target)_LIBPATH)\
[122]753 $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
754 $($(target)_SDKS.$(BUILD_TYPE)) \
755 $($(target)_SDKS),\
756 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
757 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
758 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
759 $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
760 $(SDK_$(sdk)_LIBPATH))\
[87]761 $(LIBPATH.$(BUILD_TARGET_CPU))\
762 $(LIBPATH.$(BUILD_TARGET_ARCH))\
763 $(LIBPATH.$(BUILD_TARGET))\
[74]764 $(LIBPATH.$(BUILD_TYPE))\
765 $(LIBPATH)\
[122]766 $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
767 $(SDKS.$(BUILD_TYPE)) \
768 $(SDKS),\
769 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
770 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
771 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
772 $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
773 $(SDK_$(sdk)_LIBPATH))\
[87]774 $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_CPU))\
775 $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_ARCH))\
776 $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET))\
[74]777 $(TOOL_$(tool)_LIBPATH.$(BUILD_TYPE))\
778 $(TOOL_$(tool)_LIBPATH)\
779)
780$(eval dirdep := $(dir $(exe)).dir_created)
781## @todo fix dependencies
782$(eval deps := )
783#
784$(eval custom_pre := $(strip $(firstword
785 $($(target)_CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
786 $($(target)_CUSTOM_PRE.$(BUILD_TARGET))\
787 $($(target)_CUSTOM_PRE.$(BUILD_TYPE))\
788 $($(target)_CUSTOM_PRE)\
789 $(CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
790 $(CUSTOM_PRE.$(BUILD_TARGET))\
791 $(CUSTOM_PRE.$(BUILD_TYPE))\
792 $(CUSTOM_PRE)\
793)))
794$(eval custom_post := $(strip $(firstword
795 $($(target)_CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
796 $($(target)_CUSTOM_POST.$(BUILD_TARGET))\
797 $($(target)_CUSTOM_POST.$(BUILD_TYPE))\
798 $($(target)_CUSTOM_POST)\
799 $(CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
800 $(CUSTOM_POST.$(BUILD_TARGET))\
801 $(CUSTOM_POST.$(BUILD_TYPE))\
802 $(CUSTOM_POST)\
803)))
[120]804$(eval othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE))))
[72]805
[74]806$(eval $(TOOL_$(tool)_LINK_PROGRAM))
[130]807# publish rule (still need work)
[131]808ifndef $(target)_NOINST
809$(eval pubexe := $(PATH_BIN)/$(notdir $(exe)))
[130]810$(pubexe) : $(exe) $(dir $(pubexe)).dir_created
811 $(CP) $(exe) $(pubexe)
812
813_DLLS += $(pubexe)
814_OUT_FILES += $(exe) $(pubexe)
815else
816_DLLS += $(exe)
817_OUT_FILES += $(exe)
818endif
[74]819_OBJS += $(_OBJS_$(target))
820endef
821
822# Process libraries
[138]823$(foreach target, $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)), $(eval $(def_program)))
[74]824
825
826
[72]827#
828# DLLS
829#
830
[130]831## DLL (one).
832# @param $(target) Normalized target (program) name.
833define def_dll
834# source -> object
835$(eval $(def_target_sources))
[72]836
[130]837# dllmod
838$(eval tool := $(call _TARGET_TOOL,$(target),LD))
839$(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
840$(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
841$(eval dllsuff := $(firstword $($(target)_DLLSUFF) $($(target)_DLLSUFF) $(TOOL_$(tool)_LDDLLSUFF) $(SUFF_DLL)))
842$(eval dll := $(outbase)$(dllsuff))
843$(eval objs = $(_OBJS_$(target)))
844$(eval flags :=\
845 $(TOOL_$(tool)_LDFLAGS)\
846 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TYPE))\
847 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET))\
848 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_ARCH))\
849 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_CPU))\
850 $(LDFLAGS)\
851 $(LDFLAGS.$(BUILD_TYPE))\
852 $(LDFLAGS.$(BUILD_TARGET))\
853 $(LDFLAGS.$(BUILD_TARGET_ARCH))\
854 $(LDFLAGS.$(BUILD_TARGET_CPU))\
855 $($(target)_LDFLAGS)\
856 $($(target)_LDFLAGS.$(BUILD_TYPE))\
857 $($(target)_LDFLAGS.$(BUILD_TARGET))\
858 $($(target)_LDFLAGS.$(BUILD_TARGET_ARCH))\
859 $($(target)_LDFLAGS.$(BUILD_TARGET_CPU))\
860)
861$(eval libs :=\
862 $($(target)_LIBS.$(BUILD_TARGET_CPU))\
863 $($(target)_LIBS.$(BUILD_TARGET_ARCH))\
864 $($(target)_LIBS.$(BUILD_TARGET))\
865 $($(target)_LIBS.$(BUILD_TYPE))\
866 $($(target)_LIBS)\
867 $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
868 $($(target)_SDKS.$(BUILD_TYPE)) \
869 $($(target)_SDKS),\
870 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
871 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
872 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
873 $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
874 $(SDK_$(sdk)_LIBS))\
875 $(LIBS.$(BUILD_TARGET_CPU))\
876 $(LIBS.$(BUILD_TARGET_ARCH))\
877 $(LIBS.$(BUILD_TARGET))\
878 $(LIBS.$(BUILD_TYPE))\
879 $(LIBS)\
880 $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
881 $(SDKS.$(BUILD_TYPE)) \
882 $(SDKS),\
883 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
884 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
885 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
886 $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
887 $(SDK_$(sdk)_LIBS))\
888 $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_CPU))\
889 $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_ARCH))\
890 $(TOOL_$(tool)_LIBS.$(BUILD_TARGET))\
891 $(TOOL_$(tool)_LIBS.$(BUILD_TYPE))\
892 $(TOOL_$(tool)_LIBS)\
893)
894$(eval libpath :=\
895 $($(target)_LIBPATH.$(BUILD_TARGET_CPU))\
896 $($(target)_LIBPATH.$(BUILD_TARGET_ARCH))\
897 $($(target)_LIBPATH.$(BUILD_TARGET))\
898 $($(target)_LIBPATH.$(BUILD_TYPE))\
899 $($(target)_LIBPATH)\
900 $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
901 $($(target)_SDKS.$(BUILD_TYPE)) \
902 $($(target)_SDKS),\
903 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
904 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
905 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
906 $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
907 $(SDK_$(sdk)_LIBPATH))\
908 $(LIBPATH.$(BUILD_TARGET_CPU))\
909 $(LIBPATH.$(BUILD_TARGET_ARCH))\
910 $(LIBPATH.$(BUILD_TARGET))\
911 $(LIBPATH.$(BUILD_TYPE))\
912 $(LIBPATH)\
913 $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
914 $(SDKS.$(BUILD_TYPE)) \
915 $(SDKS),\
916 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
917 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
918 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
919 $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
920 $(SDK_$(sdk)_LIBPATH))\
921 $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_CPU))\
922 $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_ARCH))\
923 $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET))\
924 $(TOOL_$(tool)_LIBPATH.$(BUILD_TYPE))\
925 $(TOOL_$(tool)_LIBPATH)\
926)
927$(eval dirdep := $(dir $(dll)).dir_created)
928## @todo fix dependencies
929$(eval deps := )
930#
931$(eval custom_pre := $(strip $(firstword
932 $($(target)_CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
933 $($(target)_CUSTOM_PRE.$(BUILD_TARGET))\
934 $($(target)_CUSTOM_PRE.$(BUILD_TYPE))\
935 $($(target)_CUSTOM_PRE)\
936 $(CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
937 $(CUSTOM_PRE.$(BUILD_TARGET))\
938 $(CUSTOM_PRE.$(BUILD_TYPE))\
939 $(CUSTOM_PRE)\
940)))
941$(eval custom_post := $(strip $(firstword
942 $($(target)_CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
943 $($(target)_CUSTOM_POST.$(BUILD_TARGET))\
944 $($(target)_CUSTOM_POST.$(BUILD_TYPE))\
945 $($(target)_CUSTOM_POST)\
946 $(CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
947 $(CUSTOM_POST.$(BUILD_TARGET))\
948 $(CUSTOM_POST.$(BUILD_TYPE))\
949 $(CUSTOM_POST)\
950)))
951$(eval othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE))))
[72]952
[130]953ifndef TOOL_$(tool)_LINK_DLL
954$$(warning kBuild: TOOL_$(tool)_LINK_DLL is not defined. target=$(target) )
955$$(warning kBuild: tools: \
956 1 $($(target)_$(source)TOOL.$(BUILD_TARGET)) \
957 2 $($(target)_$(source)TOOL) \
958 3 $($(target)_TOOL.$(BUILD_TARGET)) \
959 4 $($(target)_TOOL) \
960 5 $($(source)TOOL) \
961 6 $($(source)TOOL.$(BUILD_TARGET)) \
962 7 $(TOOL.$(BUILD_TARGET)) \
963 8 $(TOOL) )
964endif
965
966$(eval $(TOOL_$(tool)_LINK_DLL))
967
968
969# publish rule (still need work)
[131]970ifndef $(target)_NOINST
971$(eval pubdll := $(PATH_BIN)/$(notdir $(dll)))
[130]972$(pubdll) : $(dll) $(dir $(pubdll)).dir_created
973 $(CP) $(dll) $(pubdll)
974
975_DLLS += $(pubdll)
976_OUT_FILES += $(dll) $(pubdll)
977else
978_DLLS += $(dll)
979_OUT_FILES += $(dll)
980endif
981_OBJS += $(_OBJS_$(target))
982endef
983
984# Process dlls
[138]985$(foreach target, $(DLLS) $(DLLS.$(BUILD_TARGET)), $(eval $(def_dll)))
[130]986
987
[72]988#
[83]989# SYSMODS
[72]990#
991
[130]992## System module (one).
[83]993# @param $(target) Normalized target (program) name.
994define def_sysmod
995# source -> object
996$(eval $(def_target_sources))
[72]997
[110]998# sysmod
[83]999$(eval tool := $(call _TARGET_TOOL,$(target),LD))
[111]1000$(eval outbase := $(call _TARGET_BASE,$(target),$(target)))
1001$(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
1002$(eval syssuff := $(firstword $($(target)_SYSSUFF) $($(target)_SYSSUFF) $(TOOL_$(tool)_LDSYSSUFF) $(SUFF_SYS)))
1003$(eval sys := $(outbase)$(syssuff))
1004$(eval objs = $(_OBJS_$(target)))
[83]1005$(eval flags :=\
1006 $(TOOL_$(tool)_LDFLAGS)\
1007 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TYPE))\
[89]1008 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET))\
1009 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_ARCH))\
1010 $(TOOL_$(tool)_LDFLAGS.$(BUILD_TARGET_CPU))\
[83]1011 $(LDFLAGS)\
1012 $(LDFLAGS.$(BUILD_TYPE))\
[89]1013 $(LDFLAGS.$(BUILD_TARGET))\
1014 $(LDFLAGS.$(BUILD_TARGET_ARCH))\
1015 $(LDFLAGS.$(BUILD_TARGET_CPU))\
[83]1016 $($(target)_LDFLAGS)\
1017 $($(target)_LDFLAGS.$(BUILD_TYPE))\
[89]1018 $($(target)_LDFLAGS.$(BUILD_TARGET))\
1019 $($(target)_LDFLAGS.$(BUILD_TARGET_ARCH))\
1020 $($(target)_LDFLAGS.$(BUILD_TARGET_CPU))\
[83]1021)
1022$(eval libs :=\
[87]1023 $($(target)_LIBS.$(BUILD_TARGET_CPU))\
1024 $($(target)_LIBS.$(BUILD_TARGET_ARCH))\
1025 $($(target)_LIBS.$(BUILD_TARGET))\
[83]1026 $($(target)_LIBS.$(BUILD_TYPE))\
1027 $($(target)_LIBS)\
[122]1028 $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
1029 $($(target)_SDKS.$(BUILD_TYPE)) \
1030 $($(target)_SDKS),\
1031 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
1032 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
1033 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
1034 $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
1035 $(SDK_$(sdk)_LIBS))\
[87]1036 $(LIBS.$(BUILD_TARGET_CPU))\
1037 $(LIBS.$(BUILD_TARGET_ARCH))\
1038 $(LIBS.$(BUILD_TARGET))\
[83]1039 $(LIBS.$(BUILD_TYPE))\
1040 $(LIBS)\
[122]1041 $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
1042 $(SDKS.$(BUILD_TYPE)) \
1043 $(SDKS),\
1044 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_CPU))\
1045 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET_ARCH))\
1046 $(SDK_$(sdk)_LIBS.$(BUILD_TARGET))\
1047 $(SDK_$(sdk)_LIBS.$(BUILD_TYPE))\
1048 $(SDK_$(sdk)_LIBS))\
1049 $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_CPU))\
1050 $(TOOL_$(tool)_LIBS.$(BUILD_TARGET_ARCH))\
1051 $(TOOL_$(tool)_LIBS.$(BUILD_TARGET))\
[83]1052 $(TOOL_$(tool)_LIBS.$(BUILD_TYPE))\
1053 $(TOOL_$(tool)_LIBS)\
1054)
1055$(eval libpath :=\
[87]1056 $($(target)_LIBPATH.$(BUILD_TARGET_CPU))\
1057 $($(target)_LIBPATH.$(BUILD_TARGET_ARCH))\
1058 $($(target)_LIBPATH.$(BUILD_TARGET))\
[83]1059 $($(target)_LIBPATH.$(BUILD_TYPE))\
1060 $($(target)_LIBPATH)\
[122]1061 $(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
1062 $($(target)_SDKS.$(BUILD_TYPE)) \
1063 $($(target)_SDKS),\
1064 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
1065 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
1066 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
1067 $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
1068 $(SDK_$(sdk)_LIBPATH))\
[87]1069 $(LIBPATH.$(BUILD_TARGET_CPU))\
1070 $(LIBPATH.$(BUILD_TARGET_ARCH))\
1071 $(LIBPATH.$(BUILD_TARGET))\
[83]1072 $(LIBPATH.$(BUILD_TYPE))\
1073 $(LIBPATH)\
[122]1074 $(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
1075 $(SDKS.$(BUILD_TYPE)) \
1076 $(SDKS),\
1077 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_CPU))\
1078 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET_ARCH))\
1079 $(SDK_$(sdk)_LIBPATH.$(BUILD_TARGET))\
1080 $(SDK_$(sdk)_LIBPATH.$(BUILD_TYPE))\
1081 $(SDK_$(sdk)_LIBPATH))\
[87]1082 $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_CPU))\
1083 $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET_ARCH))\
1084 $(TOOL_$(tool)_LIBPATH.$(BUILD_TARGET))\
[83]1085 $(TOOL_$(tool)_LIBPATH.$(BUILD_TYPE))\
1086 $(TOOL_$(tool)_LIBPATH)\
1087)
1088$(eval dirdep := $(dir $(sys)).dir_created)
1089## @todo fix dependencies
1090$(eval deps := )
1091#
1092$(eval custom_pre := $(strip $(firstword
1093 $($(target)_CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
1094 $($(target)_CUSTOM_PRE.$(BUILD_TARGET))\
1095 $($(target)_CUSTOM_PRE.$(BUILD_TYPE))\
1096 $($(target)_CUSTOM_PRE)\
1097 $(CUSTOM_PRE.$(BUILD_TARGET).$(BUILD_TYPE))\
1098 $(CUSTOM_PRE.$(BUILD_TARGET))\
1099 $(CUSTOM_PRE.$(BUILD_TYPE))\
1100 $(CUSTOM_PRE)\
1101)))
1102$(eval custom_post := $(strip $(firstword
1103 $($(target)_CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
1104 $($(target)_CUSTOM_POST.$(BUILD_TARGET))\
1105 $($(target)_CUSTOM_POST.$(BUILD_TYPE))\
1106 $($(target)_CUSTOM_POST)\
1107 $(CUSTOM_POST.$(BUILD_TARGET).$(BUILD_TYPE))\
1108 $(CUSTOM_POST.$(BUILD_TARGET))\
1109 $(CUSTOM_POST.$(BUILD_TYPE))\
1110 $(CUSTOM_POST)\
1111)))
[120]1112$(eval othersrc := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_MODE))))
[72]1113
[106]1114ifndef TOOL_$(tool)_LINK_SYSMOD
1115$$(warning kBuild: TOOL_$(tool)_LINK_SYSMOD is not defined. target=$(target) )
1116$$(warning kBuild: tools: \
1117 1 $($(target)_$(source)TOOL.$(BUILD_TARGET)) \
1118 2 $($(target)_$(source)TOOL) \
1119 3 $($(target)_TOOL.$(BUILD_TARGET)) \
1120 4 $($(target)_TOOL) \
1121 5 $($(source)TOOL) \
1122 6 $($(source)TOOL.$(BUILD_TARGET)) \
1123 7 $(TOOL.$(BUILD_TARGET)) \
1124 8 $(TOOL) )
1125endif
1126
[83]1127$(eval $(TOOL_$(tool)_LINK_SYSMOD))
1128
[130]1129# publish rule (still need work)
[131]1130ifndef $(target)_NOINST
1131$(eval pubsys := $(PATH_BIN)/$(notdir $(sys)))
1132$(pubsys): $(sys) $(dir $(pubsys)).dir_created
[130]1133 $(CP) $(sys) $(pubsys)
1134
[131]1135$(eval _SYSMODS += $(pubsys))
1136$(eval _OUT_FILES += $(sys) $(pubsys))
[130]1137else
[131]1138$(eval _SYSMODS += $(sys))
1139$(eval _OUT_FILES += $(sys))
[130]1140endif
1141_OBJS += $(_OBJS_$(target))
[83]1142endef
1143
[130]1144# Process sysmods
[138]1145$(foreach target, $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)), $(eval $(def_sysmod)))
[83]1146
1147
1148
[72]1149#
1150# OTHERS
1151#
[140]1152_OTHERS = $(OTHERS)
[72]1153
1154
1155
1156#
1157# DOCS
1158#
1159
1160
1161#
1162# Directories.
1163#
[130]1164_DIRFILES := $(sort $(addsuffix /.dir_created,$(_DIRS)) $(addsuffix .dir_created,$(sort $(dir $(_OUT_FILES) $(_OBJS)))))
[72]1165
1166define def_createdir
1167$(dirfile):
[106]1168 $(call MSG_Ltarget,Creating directory $$(@D))
[72]1169 $(MKDIR) -p $$(@D)
[73]1170 @echo dir_created > $$@
[72]1171endef
1172
1173$(foreach dirfile,$(_DIRFILES),$(eval $(def_createdir)))
1174
[75]1175
[72]1176#
[75]1177# Include dependency files.
[72]1178#
[75]1179$(foreach dep,$(wildcard $(_DEPFILES)),$(eval include $(dep)))
[72]1180
[75]1181
1182#
1183# PASSES (including directory and makefile walking)
1184#
1185# Do all the default passes if it's unspecified.
[72]1186
[98]1187#PASSES ?= needed libraries binaries others publish
[139]1188PASSES ?= libraries binaries others
[98]1189
[75]1190## Proritized list of the default makefile when walking subdirectories.
1191# The user can overload this list.
1192DEFAULT_MAKEFILE ?= Makefile.kmk makefile.kmk Makefile makefile
[72]1193
[75]1194## Subdir
1195# @param $(pass) Lowercase pass name.
1196# @param $(PASS) Uppercase pass name.
1197# @param $(subdir) Subdirectory
1198# @param $(tag) tag to attach to the rule name.
1199define def_pass_subdir
1200pass_$(pass)$(tag)::
1201 $(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass)
1202endef
[72]1203
[75]1204## Submakefile
1205# @param $(pass) Lowercase pass name.
1206# @param $(PASS) Uppercase pass name.
1207# @param $(makefile) Makefile.
1208# @param $(tag) tag to attach to the rule name.
1209define def_pass_makefile
1210pass_$(pass)$(tag)::
1211 $(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass)
1212endef
[73]1213
[74]1214
[75]1215## Execute a pass.
1216# @param $(pass) Lowercase pass name.
1217# @param $(PASS) Uppercase pass name.
1218define def_pass
1219$(eval SUBDIRS_$(PASS) ?= $(SUBDIRS))
1220$(eval SUBDIRS_AFTER_$(PASS) ?= $(SUBDIRS_AFTER))
1221$(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE))
1222$(eval MAKEFILES_AFTER_$(PASS) ?= $(MAKEFILES_AFTER))
1223
1224$(eval tag:=_before)
1225$(foreach subdir,$(SUBDIRS_$(PASS)),$(eval $(def_pass_subdir)))
1226$(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)),$(eval $(def_pass_makefile)))
1227
1228$(eval tag:=_after)
1229$(foreach subdir,$(SUBDIRS_AFTER_$(PASS)),$(eval $(def_pass_subdir)))
1230$(foreach makefile,$(MAKEFILES_AFTER_$(PASS)),$(eval $(def_pass_makefile)))
1231
1232.NOTPARALLEL: pass_$(pass)_before pass_$(pass)_after
1233.PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_doit pass_$(pass)_after
1234pass_$(pass): \
1235 pass_$(pass)_before \
1236 pass_$(pass)_doit \
1237 pass_$(pass)_after
1238
1239endef
1240
[76]1241
[75]1242## PASS: needed
1243# This pass builds targets which are required for building the rest.
1244pass_needed_doit: $(_NEEDEDS)
1245pass := needed
1246PASS := NEEDED
1247$(eval $(def_pass))
1248
1249## PASS: libraries
1250# This pass builds library targets.
1251pass_libraries_doit: $(_LIBS) $(_IMPORT_LIBS) $(_OTHER_LIBRARIES)
1252pass := libraries
1253PASS := LIBRARIES
1254$(eval $(def_pass))
1255
1256## PASS: binaries
[83]1257# This pass builds binary targets, i.e. programs, dlls, system modules and stuff.
1258pass_binaries_doit: $(_DLLS) $(_EXES) $(_SYSMODS) $(_OTHER_BINARIES)
[75]1259pass := binaries
1260PASS := BINARIES
1261$(eval $(def_pass))
1262
1263## PASS: others
[83]1264# This pass builds other targets.
[75]1265pass_others_doit: $(_OTHERS)
1266pass := others
1267PASS := OTHERS
1268$(eval $(def_pass))
1269
1270## PASS: publish
1271# This pass installs the built entities to a sandbox area.
1272pass_publish_doit: publish
1273publish::
1274pass := publish
1275PASS := PUBLISH
[76]1276# $(sort).. not nice.
[75]1277SUBDIRS_PUBLISH ?= $(sort $(SUBDIRS) $(SUBDIRS_LIBRARIES) $(SUBDIRS_BINARIES) $(SUBDIRS_OTHERS))
1278SUBDIRS_AFTER_PUBLISH ?= $(sort $(SUBDIRS_AFTER) $(SUBDIRS_AFTER_LIBRARIES) $(SUBDIRS_AFTER_BINARIES) $(SUBDIRS_AFTER_OTHERS))
1279MAKEFILES_BEFORE_PUBLISH?= $(sort $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE_LIBRARIES) $(MAKEFILES_BEFORE_BINARIES) $(MAKEFILES_BEFORE_OTHERS))
1280MAKEFILES_AFTER_PUBLISH ?= $(sort $(MAKEFILES_AFTER) $(MAKEFILES_AFTER_LIBRARIES) $(MAKEFILES_AFTER_BINARIES) $(MAKEFILES_AFTER_OTHERS))
1281$(eval $(def_pass))
1282
1283## PASS: packing
1284# This pass processes custom packing rules.
1285pass_packing_doit: packing
1286packing::
1287pass := packing
1288PASS := PACKING
1289$(eval $(def_pass))
1290
1291## PASS: clean
1292# This pass removes all generated files.
1293pass_clean_doit:
[136]1294 $(RM) -f $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_DIRFILES) $(OTHER_CLEAN)
[75]1295pass := clean
1296PASS := CLEAN
1297$(eval $(def_pass))
1298clean: pass_clean
1299
1300## PASS: nothing
1301# This pass just walks the tree.
1302pass_nothing_doit:
[106]1303 $(call MSG_Ltarget,Did nothing in $(CURDIR))
[75]1304pass := nothing
1305PASS := NOTHING
1306$(eval $(def_pass))
1307nothing: pass_nothing
1308
[78]1309
1310
[75]1311#
1312# THE MAIN RULES
1313#
1314all_recursive: $(foreach pass,$(PASSES),pass_$(pass))
1315
[130]1316rebuild: clean
[120]1317 $(MAKE) -f $(firstword $(MAKEFILE_LIST)) all_recursive
[78]1318
1319
[75]1320# misc shortcuts.
1321target: needed libraries binaries others
1322objects: $(_OBJS)
1323programs: $(_EXES)
1324dlls: $(_DLLS)
[83]1325sysmods: $(_SYSMODS)
[75]1326
1327
[72]1328# end-of-file-content
[106]1329__footer_kmk__ := target
[72]1330endif # __footer_kmk__
Note: See TracBrowser for help on using the repository browser.