source: trunk/kBuild/footer.kmk@ 222

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

Needed -> bldprogs.

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