source: trunk/kBuild/footer.kmk@ 137

Last change on this file since 137 was 136, checked in by bird, 21 years ago

OTHER_CLEAN

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