source: trunk/kBuild/footer.kmk@ 206

Last change on this file since 206 was 205, checked in by bird, 21 years ago

.o aliases for compilation from the editor.

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