Ignore:
Timestamp:
Dec 12, 2005, 4:36:07 AM (20 years ago)
Author:
bird
Message:

Use fixed lot's of those $$$$(PATH_<target>) thingies. Better target install, install pass and install target type. Generic passes. And more.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kBuild/footer.kmk

    r316 r353  
    44# kBuild - File included at top of makefile.
    55#
    6 # Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
     6# Copyright (c) 2004-2005 knut st. osmundsen <bird-srcspam@anduin.net>
    77#
    88#
     
    2121# You should have received a copy of the GNU General Public License
    2222# along with kBuild; if not, write to the Free Software
    23 # Foundation, Inc., 59 Temple Place, Suite typetype0, Boston, MA  0sourcetargettargettarget-targettype07  USA
     23# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2424#
    2525#
     
    3434
    3535# all targets.
    36 ALL_TARGETS := \
     36ALL_TARGETS += \
    3737        $(BLDPROGS)    $(BLDPROGS.$(BUILD_PLATFORM)) \
    3838        $(LIBRARIES)   $(LIBRARIES.$(BUILD_TARGET)) \
     
    4141        $(PROGRAMS)    $(PROGRAMS.$(BUILD_TARGET)) \
    4242        $(SYSMODS)     $(SYSMODS.$(BUILD_TARGET)) \
     43        $(INSTALLS)    $(INSTALLS.$(BUILD_TARGET)) \
    4344        $(OTHERS)      $(OTHERS.$(BUILD_TARGET))
    4445
     
    5051# required dependency file must add those output files to this variable.
    5152_OUT_FILES :=
     53
     54# Files which only requires cleaning up.
     55_CLEAN_FILES :=
    5256
    5357# all of a type
     
    5862_PROGRAMS :=
    5963_SYSMODS  :=
    60 _DIRS     :=
     64_INSTALLS :=
     65_OTHERS   :=
     66_DIRS     := $(PATH_TARGET)/
    6167_IMPORT_LIBS :=
    6268
     
    6470pass_prev :=
    6571
    66 
    67 # all objs of a specific target
    68 define def_objs_var
    69 _OBJS_$target :=
    70 endef
    71 $(foreach target, $(ALL_TARGETS), $(eval _OBJS_$(target) := ))
    7272
    7373#
     
    136136
    137137
     138## Figure out the actual name of an installed file.
     139# @param        $1              The file to install.
     140# @param        $2              The target name.
     141# @param        $3              The _INST value (can be empty).
     142# @param        $4              The default directory to use when $3 is empty.
     143_INSTALL_FILE = $(patsubst %/,%/$(notdir $(1)),$(if $(3),$(PATH_INS)/$(3),$(4)/))
     144
     145
    138146#
    139147# Check syntax which leads to weird syntax errors.
     
    165173define def_templates_include
    166174ifndef TEMPLATE_$(template)
    167 include $(firstword $(wildcard $(PATH_KBUILD)/templates/$(template).kmk))
     175include $(firstword $(foreach path, $(TEMPLATE_PATHS) $(PATH_KBUILD)/templates/, $(wildcard $(path)/$(template).kmk)))
    168176endif
    169177endef
     
    213221
    214222
    215 ## Inherit one template property in a accumulative manner.
     223## Inherit one template property in a non-accumulative manner.
    216224# @param    $(prop)     Property name
    217225# @param    $(target)   Target name
     
    220228ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
    221229ifndef $(target)_$(prop)
    222 #$$ (warning dbgtarget: $(target)_$(prop):='$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
    223 $$(target)_$$(prop) := $$(TEMPLATE_$$($$(target)_TEMPLATE)_$$(prop))
     230$(target)_$(prop) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
     231#$ (warning dbgtarget: $(target)_$(prop):='$(value $(target)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
    224232endif
    225233endif
    226234ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)
    227235ifndef $(target)_$(prop).$(BUILD_TARGET)
    228 #$$ (warning dbgsource: $(target)_$(prop).$(BUILD_TARGET)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
    229 $$(target)_$$(prop).$$(BUILD_TARGET) := $$(TEMPLATE_$$($$(target)_TEMPLATE)_$$(prop).$$(BUILD_TARGET))
     236#$ (warning dbgsource: $(target)_$(prop).$(BUILD_TARGET)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
     237$(target)_$(prop).$(BUILD_TARGET) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
     238endif
     239endif
     240endef
     241
     242## Inherit one template property in a non-accumulative manner, deferred expansion.
     243# @param    1: $(prop)     Property name
     244# @param    2: $(target)        Target name
     245# @todo fix the precedence order for some properties.
     246# @remark this define relies on double evaluation
     247define def_inherit_template_one_deferred
     248ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
     249ifndef $(target)_$(prop)
     250$(target)_$(prop) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
     251#$ (warning dbgtarget: $(target)_$(prop):='$(value $(target)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
     252endif
     253endif
     254ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)
     255ifndef $(target)_$(prop).$(BUILD_TARGET)
     256#$ (warning dbgsource: $(target)_$(prop).$(BUILD_TARGET)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
     257$(target)_$(prop).$(BUILD_TARGET) = $$(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
    230258endif
    231259endif
     
    237265define def_inherit_template_one_accumulate
    238266ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
    239 #$$ (warning dbgtype: TEMPLATE_$($(target)_TEMPLATE)_$(prop) $(target)_$(prop)=$($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
    240 $$(eval $(target)_$(prop) := $($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
    241 #$$ (warning dbgtype: $(target)_$(prop)=$($(target)_$(prop)))
     267#$ (warning dbgtype: TEMPLATE_$($(target)_TEMPLATE)_$(prop) $(target)_$(prop)=$($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
     268$(target)_$(prop) := $($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
     269#$ (warning dbgtype: $(target)_$(prop)=$($(target)_$(prop)))
    242270endif
    243271ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)
    244 #$$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
    245 $$(eval $(target)_$(prop).$(BUILD_TYPE) := $($(target)_$(prop).$(BUILD_TYPE)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)))
     272#$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
     273$(target)_$(prop).$(BUILD_TYPE) := $($(target)_$(prop).$(BUILD_TYPE)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
    246274endif
    247275ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)
    248 #$$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
    249 $$(eval $(target)_$(prop).$(BUILD_TARGET) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)))
     276#$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
     277$(target)_$(prop).$(BUILD_TARGET) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
    250278endif
    251279ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU)
    252 #$$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU))
    253 $$(eval $(target)_$(prop).$(BUILD_TARGET_CPU) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU)))
     280#$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU))
     281$(target)_$(prop).$(BUILD_TARGET_CPU) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU))
    254282endif
    255283ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH)
    256 #$$ (warning dbg6: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH))
    257 $$(eval $(target)_$(prop).$(BUILD_TARGET_ARCH) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH)))
    258 endif
    259 endef
    260 
     284#$ (warning dbg6: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH))
     285$(target)_$(prop).$(BUILD_TARGET_ARCH) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH))
     286endif
     287endef
    261288
    262289## Inherit template properties for on target.
    263290# @param    $(target)    Target name.
    264291define def_inherit_template
    265 $$(foreach prop, TOOL ARTOOL CTOOL CXXTOOL ASTOOL LDTOOL INST NOINST\
    266         ,$$(eval $$(def_inherit_template_one)))
    267 $$(foreach prop,SDKS DEFS INCS COPTS CFLAGS CDEFS CINCS CXXOPTS CXXFLAGS CXXDEFS CXXINCS ASOPTS ASFLAGS ASDEFS ASINCS LDFLAGS LIBS LIBPATH \
    268                 BLD_TYPE BLD_TRG BLD_TRG_ARCH BLD_TRG_CPU SYSSUFF EXESUFF DLLSUFF LIBSUFF ARLIBSUFF \
    269         ,$$(eval $$(def_inherit_template_one_accumulate)))
    270 endef
     292$(foreach prop,$(PROPS_SINGLE),$(eval $(value def_inherit_template_one)))
     293$(foreach prop,$(PROPS_DEFERRED),$(eval $(def_inherit_template_one_deferred))) # exploits the 2 evaluation, so no value!
     294$(foreach prop,$(PROPS_ACCUMULATE),$(eval $(value def_inherit_template_one_accumulate)))
     295endef
     296
    271297# Inherit template properties
    272 $(foreach target, $(ALL_TARGETS),$(eval $(def_inherit_template)))
     298$(foreach target, $(ALL_TARGETS),$(eval $(value def_inherit_template)))
    273299
    274300
     
    278304_TOOLS := $(TOOL)
    279305define def_tools_target_source
    280 $(foreach tool,\
    281         $($(source)_TOOL.$(BUILD_TARGET)) $($(target)_$(source)_TOOL.$(BUILD_TARGET))\
    282         $($(source)_TOOL) $($(target)_$(source)_TOOL)\
    283         $($(source)_CTOOL.$(BUILD_TARGET)) $($(target)_$(source)_CTOOL.$(BUILD_TARGET))\
    284         $($(source)_CTOOL) $($(target)_$(source)_CTOOL)\
    285         $($(source)_CXXTOOL.$(BUILD_TARGET)) $($(target)_$(source)_CXXTOOL.$(BUILD_TARGET))\
    286         $($(source)_CXXTOOL) $($(target)_$(source)_CXXTOOL)\
    287         $($(source)_ASTOOL.$(BUILD_TARGET)) $($(target)_$(source)_ASTOOL.$(BUILD_TARGET))\
    288         $($(source)_ASTOOL) $($(target)_$(source)_ASTOOL)\
    289         $($(source)_ARTOOL.$(BUILD_TARGET)) $($(target)_$(source)_ARTOOL.$(BUILD_TARGET))\
    290         $($(source)_ARTOOL) $($(target)_$(source)_ARTOOL)\
    291         $($(source)_LDTOOL.$(BUILD_TARGET)) $($(target)_$(source)_LDTOOL.$(BUILD_TARGET))\
    292         $($(source)_LDTOOL) $($(target)_$(source)_LDTOOL)\
    293         ,$(eval _TOOLS += $(tool)))
    294 endef
     306$(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
     307        $($(source)_$(prop).$(BUILD_TARGET)) \
     308        $($(target)_$(source)_$(prop).$(BUILD_TARGET)) \
     309        $($(source)_$(prop)) \
     310        $($(target)_$(source)_$(prop))))
     311endef
     312
    295313define def_tools_target
    296 $(foreach tool,\
    297         $($(target)_TOOL.$(BUILD_TARGET))\
    298         $($(target)_TOOL)\
    299         $($(target)_CTOOL.$(BUILD_TARGET))\
    300         $($(target)_CTOOL)\
    301         $($(target)_CXXTOOL.$(BUILD_TARGET))\
    302         $($(target)_CXXTOOL)\
    303         $($(target)_ASTOOL.$(BUILD_TARGET))\
    304         $($(target)_ASTOOL)\
    305         $($(target)_ARTOOL.$(BUILD_TARGET))\
    306         $($(target)_ARTOOL)\
    307         $($(target)_LDTOOL.$(BUILD_TARGET))\
    308         $($(target)_LDTOOL)\
    309         ,$(eval _TOOLS += $(tool)))
    310 $(foreach source, $($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TYPE)) \
    311         , $(eval $(def_tools_target_source)))
    312 endef
    313 $(foreach target, $(ALL_TARGETS), $(eval $(def_tools_target)))
     314$(eval _TOOLS += $(foreach prop, $(PROPS_TOOLS), \
     315        $($(target)_$(prop).$(BUILD_TARGET)) \
     316        $($(target)_$(prop))))
     317$(foreach source, \
     318        $($(target)_SOURCES.$(BUILD_TARGET)) \
     319        $($(target)_SOURCES.$(BUILD_TYPE)) \
     320        $($(target)_SOURCES) \
     321        , $(eval $(value def_tools_target_source)))
     322endef
     323
     324$(foreach target, $(ALL_TARGETS), $(eval $(value def_tools_target)))
    314325_TOOLS := $(sort $(_TOOLS))
    315326
    316327define def_tools_include
    317328ifndef TOOL_$(tool)
    318 include $(firstword $(wildcard $(PATH_KBUILD)/tools/$(tool).kmk))
    319 endif
    320 endef
    321 $(foreach tool, $(_TOOLS), $(eval $(def_tools_include)))
     329TOOL_$(tool)_KMK_FILE := $(firstword $(foreach path, $(TOOL_PATHS) $(PATH_KBUILD)/tools, $(wildcard $(path)/$(tool).kmk)))
     330ifeq ($(TOOL_$(tool)_KMK_FILE),)
     331$(error kBuild: Cannot find include file for the tool '$(tool)'! Searched: $(TOOL_PATHS) $(PATH_KBUILD)/tools)
     332endif
     333include $(TOOL_$(tool)_KMK_FILE)
     334endif
     335endef
     336$(foreach tool, $(_TOOLS), $(eval $(value def_tools_include)))
    322337
    323338
     
    342357define def_sdks_include_one
    343358ifndef SDK_$(sdk)
    344 include $(firstword $(wildcard $(PATH_KBUILD)/sdks/$(sdk).kmk))
    345 endif
    346 endef
    347 $(foreach sdk, $(_SDKS), $(eval $(def_sdks_include_one)))
     359SDK_$(sdk)_KMK_FILE := $(firstword $(foreach path, $(SDK_PATHS) $(PATH_KBUILD)/sdks, $(wildcard $(path)/$(sdk).kmk)))
     360ifeq ($(SDK_$(sdk)_KMK_FILE),)
     361$(error kBuild: Cannot find include file for the SDK '$(sdk)'! Searched: $(SDK_PATHS) $(PATH_KBUILD)/sdks)
     362endif
     363include $(SDK_$(sdk)_KMK_FILE)
     364endif
     365endef
     366$(foreach sdk, $(_SDKS), $(eval $(value def_sdks_include_one)))
    348367
    349368#
    350369# Object processing.
    351370#
     371
     372## Generates the '::' rule for building all objects of a source file.
     373# @param    $(obj)    The object file.
     374define def_target_obj_rule
     375$(basename $(notdir $(obj))).o::
     376        + $$(MAKE) -B -f $$(MAKEFILE) $(obj)
     377$(basename $$(notdir $$(obj))).obj::
     378        + $$(MAKE) -B -f $$(MAKEFILE) $(obj)
     379endef
    352380
    353381
     
    366394#$ (warning dbg: def_target_source_c_cpp_asm: source='$(source)' target='$(target)' type='$(type)')
    367395
    368 $(eval tool:=$(call _SOURCE_TOOL,$(source),$(target),$(type)))
    369 $(eval outbase     := $(call _OBJECT_BASE,$(source),$(target)))
    370 $(eval PATH_$(target)_$(source) := $(patsubst %/,%,$(dir $(outbase))))
    371 $(eval dirdep      := $(dir $(outbase)).dir_created)
    372 $(eval defs        :=\
     396tool := $(call _SOURCE_TOOL,$(source),$(target),$(type))
     397outbase     := $(call _OBJECT_BASE,$(source),$(target))
     398PATH_$(target)_$(source) := $(patsubst %/,%,$(dir $(outbase)))
     399dirdep      := $(call DIRDEP,$(dir $(outbase)))
     400defs        :=\
    373401        $(TOOL_$(tool)_DEFS)\
    374402        $(TOOL_$(tool)_DEFS.$(bld_type))\
     
    381409                                   $(SDKS.$(bld_type)) \
    382410                                   $(SDKS),\
    383         $(SDK_$(sdk)_DEFS)\
    384         $(SDK_$(sdk)_DEFS.$(bld_type))\
    385         $(SDK_$(sdk)_DEFS.$(bld_trg))\
    386         $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
    387         $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
    388         $(SDK_$(sdk)_$(type)DEFS)\
    389         $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
    390         $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
    391         $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
    392         $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
     411                $(SDK_$(sdk)_DEFS)\
     412                $(SDK_$(sdk)_DEFS.$(bld_type))\
     413                $(SDK_$(sdk)_DEFS.$(bld_trg))\
     414                $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
     415                $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
     416                $(SDK_$(sdk)_$(type)DEFS)\
     417                $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
     418                $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
     419                $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
     420                $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
    393421        $(DEFS)\
    394422        $(DEFS.$(bld_type))\
     
    404432                                   $($(target)_SDKS.$(bld_type)) \
    405433                                   $($(target)_SDKS),\
    406         $(SDK_$(sdk)_DEFS)\
    407         $(SDK_$(sdk)_DEFS.$(bld_type))\
    408         $(SDK_$(sdk)_DEFS.$(bld_trg))\
    409         $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
    410         $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
    411         $(SDK_$(sdk)_$(type)DEFS)\
    412         $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
    413         $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
    414         $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
    415         $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
     434                $(SDK_$(sdk)_DEFS)\
     435                $(SDK_$(sdk)_DEFS.$(bld_type))\
     436                $(SDK_$(sdk)_DEFS.$(bld_trg))\
     437                $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
     438                $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
     439                $(SDK_$(sdk)_$(type)DEFS)\
     440                $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
     441                $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
     442                $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
     443                $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
    416444        $($(target)_DEFS)\
    417445        $($(target)_DEFS.$(bld_type))\
     
    427455                                   $($(source)_SDKS.$(bld_type)) \
    428456                                   $($(source)_SDKS),\
    429         $(SDK_$(sdk)_DEFS)\
    430         $(SDK_$(sdk)_DEFS.$(bld_type))\
    431         $(SDK_$(sdk)_DEFS.$(bld_trg))\
    432         $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
    433         $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
    434         $(SDK_$(sdk)_$(type)DEFS)\
    435         $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
    436         $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
    437         $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
    438         $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
     457                $(SDK_$(sdk)_DEFS)\
     458                $(SDK_$(sdk)_DEFS.$(bld_type))\
     459                $(SDK_$(sdk)_DEFS.$(bld_trg))\
     460                $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
     461                $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
     462                $(SDK_$(sdk)_$(type)DEFS)\
     463                $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
     464                $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
     465                $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
     466                $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
    439467        $($(source)_DEFS)\
    440468        $($(source)_DEFS.$(bld_type))\
     
    450478                                   $($(target)_$(source)_SDKS.$(bld_type)) \
    451479                                   $($(target)_$(source)_SDKS),\
    452         $(SDK_$(sdk)_DEFS)\
    453         $(SDK_$(sdk)_DEFS.$(bld_type))\
    454         $(SDK_$(sdk)_DEFS.$(bld_trg))\
    455         $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
    456         $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
    457         $(SDK_$(sdk)_$(type)DEFS)\
    458         $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
    459         $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
    460         $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
    461         $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
     480                $(SDK_$(sdk)_DEFS)\
     481                $(SDK_$(sdk)_DEFS.$(bld_type))\
     482                $(SDK_$(sdk)_DEFS.$(bld_trg))\
     483                $(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
     484                $(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
     485                $(SDK_$(sdk)_$(type)DEFS)\
     486                $(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
     487                $(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
     488                $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
     489                $(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
    462490        $($(target)_$(source)_DEFS)\
    463491        $($(target)_$(source)_DEFS.$(bld_type))\
     
    469497        $($(target)_$(source)_$(type)DEFS.$(bld_trg))\
    470498        $($(target)_$(source)_$(type)DEFS.$(bld_trg_arch))\
    471         $($(target)_$(source)_$(type)DEFS.$(bld_trg_cpu))\
    472         )
    473 $(eval incs        :=\
     499        $($(target)_$(source)_$(type)DEFS.$(bld_trg_cpu))
     500incs        :=\
    474501        $($(target)_$(source)_$(type)INCS.$(bld_trg_cpu))\
    475502        $($(target)_$(source)_$(type)INCS.$(bld_trg_arch))\
     
    485512                                   $($(target)_$(source)_SDKS.$(bld_type)) \
    486513                                   $($(target)_$(source)_SDKS),\
    487         $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
    488         $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
    489         $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
    490         $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
    491         $(SDK_$(sdk)_$(type)INCS)\
    492         $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
    493         $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
    494         $(SDK_$(sdk)_INCS.$(bld_trg))\
    495         $(SDK_$(sdk)_INCS.$(bld_type))\
    496         $(SDK_$(sdk)_INCS))\
     514                $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
     515                $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
     516                $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
     517                $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
     518                $(SDK_$(sdk)_$(type)INCS)\
     519                $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
     520                $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
     521                $(SDK_$(sdk)_INCS.$(bld_trg))\
     522                $(SDK_$(sdk)_INCS.$(bld_type))\
     523                $(SDK_$(sdk)_INCS))\
    497524        $($(source)_$(type)INCS.$(bld_trg_cpu))\
    498525        $($(source)_$(type)INCS.$(bld_trg_arch))\
     
    508535                                   $($(source)_SDKS.$(bld_type)) \
    509536                                   $($(source)_SDKS),\
    510         $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
    511         $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
    512         $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
    513         $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
    514         $(SDK_$(sdk)_$(type)INCS)\
    515         $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
    516         $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
    517         $(SDK_$(sdk)_INCS.$(bld_trg))\
    518         $(SDK_$(sdk)_INCS.$(bld_type))\
    519         $(SDK_$(sdk)_INCS))\
     537                $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
     538                $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
     539                $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
     540                $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
     541                $(SDK_$(sdk)_$(type)INCS)\
     542                $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
     543                $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
     544                $(SDK_$(sdk)_INCS.$(bld_trg))\
     545                $(SDK_$(sdk)_INCS.$(bld_type))\
     546                $(SDK_$(sdk)_INCS))\
    520547        $($(target)_$(type)INCS.$(bld_trg_cpu))\
    521548        $($(target)_$(type)INCS.$(bld_trg_arch))\
     
    531558                                   $($(target)_SDKS.$(bld_type)) \
    532559                                   $($(target)_SDKS),\
    533         $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
    534         $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
    535         $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
    536         $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
    537         $(SDK_$(sdk)_$(type)INCS)\
    538         $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
    539         $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
    540         $(SDK_$(sdk)_INCS.$(bld_trg))\
    541         $(SDK_$(sdk)_INCS.$(bld_type))\
    542         $(SDK_$(sdk)_INCS))\
     560                $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
     561                $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
     562                $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
     563                $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
     564                $(SDK_$(sdk)_$(type)INCS)\
     565                $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
     566                $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
     567                $(SDK_$(sdk)_INCS.$(bld_trg))\
     568                $(SDK_$(sdk)_INCS.$(bld_type))\
     569                $(SDK_$(sdk)_INCS))\
    543570        $(INCS.$(bld_trg_cpu))\
    544571        $(INCS.$(bld_trg_arch))\
     
    549576                                   $(SDKS.$(bld_type)) \
    550577                                   $(SDKS),\
    551         $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
    552         $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
    553         $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
    554         $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
    555         $(SDK_$(sdk)_$(type)INCS)\
    556         $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
    557         $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
    558         $(SDK_$(sdk)_INCS.$(bld_trg))\
    559         $(SDK_$(sdk)_INCS.$(bld_type))\
    560         $(SDK_$(sdk)_INCS))\
     578                $(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
     579                $(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
     580                $(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
     581                $(SDK_$(sdk)_$(type)INCS.$(bld_type))\
     582                $(SDK_$(sdk)_$(type)INCS)\
     583                $(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
     584                $(SDK_$(sdk)_INCS.$(bld_trg_arch))\
     585                $(SDK_$(sdk)_INCS.$(bld_trg))\
     586                $(SDK_$(sdk)_INCS.$(bld_type))\
     587                $(SDK_$(sdk)_INCS))\
    561588        $(TOOL_$(tool)_$(type)INCS.$(bld_trg_cpu))\
    562589        $(TOOL_$(tool)_$(type)INCS.$(bld_trg_arch))\
    563590        $(TOOL_$(tool)_$(type)INCS.$(bld_trg))\
    564591        $(TOOL_$(tool)_$(type)INCS.$(bld_type))\
    565         $(TOOL_$(tool)_$(type)INCS)\
    566         )
    567 $(eval flags        :=\
     592        $(TOOL_$(tool)_$(type)INCS)
     593flags        :=\
    568594        $(TOOL_$(tool)_$(type)FLAGS)\
    569595        $(TOOL_$(tool)_$(type)FLAGS.$(bld_type))\
     
    590616        $($(target)_$(source)_$(type)FLAGS.$(bld_trg))\
    591617        $($(target)_$(source)_$(type)FLAGS.$(bld_trg_arch))\
    592         $($(target)_$(source)_$(type)FLAGS.$(bld_trg_cpu))\
    593         )
    594 $(eval objsuff     := $(firstword \
     618        $($(target)_$(source)_$(type)FLAGS.$(bld_trg_cpu))
     619objsuff     := $(firstword \
    595620        $($(target)_$(source)_OBJSUFF.$(bld_trg))\
    596621        $($(target)_$(source)_OBJSUFF)\
     
    601626        $(TOOL_$(tool)_$(type)OBJSUFF.$(bld_trg))\
    602627        $(TOOL_$(tool)_$(type)OBJSUFF)\
    603         $(SUFF_OBJ)\
    604         ))
    605 $(eval obj         := $(outbase)$(objsuff))
    606 $(eval dep         := $(outbase)$(SUFF_DEP))
    607 $(eval deps        := \
     628        $(SUFF_OBJ))
     629obj         := $(outbase)$(objsuff)
     630dep         := $(outbase)$(SUFF_DEP)
     631deps        := \
    608632        $($(target)_$(source)_DEPS)\
    609     $($(target)_$(source)_DEPS.$(bld_type))\
    610     $($(target)_$(source)_DEPS.$(bld_trg))\
    611     $($(target)_$(source)_DEPS.$(bld_trg_arch))\
    612     $($(target)_$(source)_DEPS.$(bld_trg_cpu))\
     633        $($(target)_$(source)_DEPS.$(bld_type))\
     634        $($(target)_$(source)_DEPS.$(bld_trg))\
     635        $($(target)_$(source)_DEPS.$(bld_trg_arch))\
     636        $($(target)_$(source)_DEPS.$(bld_trg_cpu))\
    613637        $($(source)_DEPS)\
    614638        $($(source)_DEPS.$(bld_type))\
    615639        $($(source)_DEPS.$(bld_trg))\
     640        $($(source)_DEPS.$(bld_trg_arch))\
     641        $($(source)_DEPS.$(bld_trg_cpu))\
    616642        $($(target)_DEPS)\
     643        $($(target)_DEPS.$(bld_type))\
    617644        $($(target)_DEPS.$(bld_trg_arch))\
    618         $($(target)_DEPS.$(bld_trg_cpu)))
     645        $($(target)_DEPS.$(bld_trg_cpu))
    619646
    620647
    621648#$ (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))
    622649ifndef TOOL_$(tool)_COMPILE_$(type)
    623 $$(warning kBuild: TOOL_$(tool)_COMPILE_$(type) is not defined. source=$(source) target=$(target) )
    624 $$(warning kBuild: tools: \
     650$(warning kBuild: tools: \
    625651        1 $($(target)_$(source)_$(type)TOOL.$(bld_trg)) \
    626652        2 $($(target)_$(source)_$(type)TOOL) \
     
    639665        15 $(TOOL.$(bld_trg)) \
    640666        16 $(TOOL) )
    641 endif
     667$(error kBuild: TOOL_$(tool)_COMPILE_$(type) is not defined. source=$(source) target=$(target) )
     668endif
     669
     670# generate the rules
    642671$(eval $(TOOL_$(tool)_COMPILE_$(type)))
    643672
    644 $$(basename $$(notdir $$(obj))).o::
    645         + $$(MAKE) -B -f $$(MAKEFILE) $(obj)
    646 $$(basename $$(notdir $$(obj))).obj::
    647         + $$(MAKE) -B -f $$(MAKEFILE) $(obj)
    648 
    649 $(eval _OBJS_$(target) += $(obj))
    650 $(eval _DEPFILES       += $(dep))
     673$(eval $(def_target_obj_rule))
     674
     675$(target)_OBJS_ += $(obj)
     676_DEPFILES       += $(dep)
    651677
    652678endef
     
    657683#$ (warning def_target_sources)
    658684# C sources
    659 $(foreach type,C,$(foreach source, $(filter %.c, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type)))\
    660         ,$(eval $(def_target_source_c_cpp_asm)) ))
     685type := C
     686$(foreach source, $(filter %.c, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\
     687        ,$(eval $(value def_target_source_c_cpp_asm)) )
    661688
    662689# C++ sources
    663 $(foreach type,CXX,$(foreach source, $(filter %.cpp %.cxx %.xx, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type)))\
    664         ,$(eval $(def_target_source_c_cpp_asm)) ))
     690type := CXX
     691$(foreach source, $(filter %.cpp %.cxx %.xx, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\
     692        ,$(eval $(value def_target_source_c_cpp_asm)) )
    665693
    666694# ASM sources
    667 $(foreach type,AS,$(foreach source, $(filter %.asm %.s %.S, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type)))\
    668         ,$(eval $(def_target_source_c_cpp_asm)) ))
    669 endef
    670 
    671 
    672 #
    673 # BLDPROGS
    674 #
    675 
    676 ## Build program (one).
    677 # @param    $(target)   Normalized target (program) name.
    678 define def_bldprog
     695type := AS
     696$(foreach source, $(filter %.asm %.s %.S, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)))\
     697        ,$(eval $(value def_target_source_c_cpp_asm)) )
     698
     699endef
     700
     701## Generate the link & lib install rule
     702# @param    $(target)   Normalized target name.
     703# @param    $(out)      The build target.
     704# @param    $(INSTARGET_$(target))  The installation targets.
     705define def_link_install_rule
     706$(INSTARGET_$(target)) : $(out) | $(call DIRDEP,$(dir $(INSTARGET_$(target))))
     707        $(RM) -f $$@
     708        $(CP) $(out) $$@
     709endef
     710
     711
     712
     713## Generic macro for generating the install rule(s) for a target
     714# and update the globals with default out.
     715#
     716# @param        $(target)   Normalized target name.
     717# @param        $(out)      The output file.
     718# @param        $(definst)  The default _INST value.
     719# @param        $(typevar)  The name of the variable with all the root targets of its type.
     720# @obsolete
     721define def_target_install_pluss
     722ifndef $(target)_NOINST
     723INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
     724        $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
     725
     726$(eval $(def_link_install_rule))
     727
     728_INSTALLS  += $(INSTARGET_$(target))
     729
     730ifdef KBUILD_DO_AUTO_INSTALL
     731$(typevar)  += $(INSTARGET_$(target))
     732else
     733$(typevar)  += $(out)
     734endif
     735else # _NOINST
     736$(typevar)  += $(out)
     737endif
     738
     739_OUT_FILES += $(out)
     740_CLEAN_FILES += $($(target)_CLEAN)
     741_OBJS += $($(target)_OBJS_)
     742
     743endef
     744
     745
     746
     747#
     748# LIBRARIES
     749#
     750
     751## Library (one).
     752# @param    $(target)   Normalized library (target) name.
     753define def_lib
     754# library basics
     755## @todo prefix
     756bld_type    := $(firstword $($(target)_BLD_TYPE)     $(BUILD_TYPE))
     757bld_trg     := $(firstword $($(target)_BLD_TRG)      $(BUILD_TARGET))
     758bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
     759bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU)  $(BUILD_TARGET_CPU))
     760tool        := $(call _TARGET_TOOL,$(target),AR)
     761ifeq ($(tool),)
     762$(error kBuild: Library target $(target) does not have a tool defined!)
     763endif
     764outbase     := $(call _TARGET_BASE,$(target),$(target))
     765PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
     766suff        := $(firstword\
     767        $($(target)_LIBSUFF.$(bld_trg))\
     768        $($(target)_LIBSUFF)\
     769        $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg))\
     770        $(TOOL_$(tool)_ARLIBSUFF)\
     771        $(SUFF_LIB))
     772out         := $(outbase)$(suff)
     773TARGET_$(target) := $(out)
     774$(target)_OBJS_ := $(filter %.o %.obj, \
     775        $($(target)_SOURCES) \
     776        $($(target)_SOURCES.$(bld_trg)) \
     777        $($(target)_SOURCES.$(bld_trg_arch)) \
     778        $($(target)_SOURCES.$(bld_trg_cpu)) \
     779        $($(target)_SOURCES.$(bld_type)))
     780
     781
     782# source -> object
     783$(eval $(value def_target_sources))
     784
     785# library linking
     786tool        := $(call _TARGET_TOOL,$(target),AR)
     787outbase     := $(call _TARGET_BASE,$(target),$(target))
     788flags       :=\
     789        $(TOOL_$(tool)_ARFLAGS)\
     790        $(TOOL_$(tool)_ARFLAGS.$(bld_type))\
     791        $(ARFLAGS)\
     792        $(ARFLAGS.$(bld_type))\
     793        $($(target)_ARFLAGS)\
     794        $($(target)_ARFLAGS.$(bld_type))
     795othersrc    := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,\
     796        $($(target)_SOURCES) \
     797        $($(target)_SOURCES.$(bld_trg)) \
     798        $($(target)_SOURCES.$(bld_trg_arch)) \
     799        $($(target)_SOURCES.$(bld_trg_cpu)) \
     800        $($(target)_SOURCES.$(bld_type)))
     801objs         = $($(target)_OBJS_)
     802dirdep      := $(call DIRDEP,$(dir $(out)))
     803## @todo fix dependencies on makefiles an such
     804deps        := $($(target)_DEPS)
     805
     806lib     := $(out)
     807libsuff := $(suff)
     808$(eval $(TOOL_$(tool)_LINK_LIBRARY))
     809
     810# installing and globals
     811definst := $(PATH_LIB)
     812typevar :=_LIBS
     813$(eval $(value def_target_install_pluss))
     814endef
     815
     816# Process libraries
     817$(foreach target, $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)), $(eval $(value def_lib)))
     818
     819
     820#
     821# Link operations.
     822#
     823
     824##
     825# Link prolog
     826#
     827# @param    $(target)   Normalized target name.
     828# @param    $(EXT)      EXE,DLL,SYS.
     829# @param    $(definst)  The default _INST value.
     830# @param    $(typevar)  The name of the variable with all the root targets of its type.
     831define def_link_prolog
    679832# basics
    680 $(eval bld_type    := $(firstword $($(target)_BLD_TYPE)     $(BUILD_TYPE)))
    681 $(eval bld_trg     := $(firstword $($(target)_BLD_TRG)      $(BUILD_PLATFORM)))
    682 $(eval bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_PLATFORM_ARCH)))
    683 $(eval bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU)  $(BUILD_PLATFORM_CPU)))
    684 $(eval tool        := $(call _TARGET_TOOL,$(target),LD))
    685 $(eval outbase     := $(call _TARGET_BASE,$(target),$(target)))
    686 $(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
    687 $(eval exesuff     := $(firstword $($(target)_EXESUFF) $($(target)_EXESUFF) $(TOOL_$(tool)_LDEXESUFF) $(HOSTSUFF_EXE)))
    688 $(eval exe         := $(outbase)$(exesuff))
    689 $(eval TARGET_$(target) := $(exe))
     833bld_type    := $(firstword $($(target)_BLD_TYPE)     $(BUILD_TYPE))
     834bld_trg     := $(firstword $($(target)_BLD_TRG)      $(BUILD_$(bld_trg_base_var)))
     835bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_$(bld_trg_base_var)_ARCH))
     836bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU)  $(BUILD_$(bld_trg_base_var)_CPU))
     837
     838tool        := $(call _TARGET_TOOL,$(target),LD)
     839outbase     := $(call _TARGET_BASE,$(target),$(target))
     840suff        := $(firstword \
     841        $($(target)_$(EXT)SUFF) \
     842        $($(target)_$(EXT)SUFF) \
     843        $(TOOL_$(tool)_LD$(EXT)SUFF) \
     844        $($(EXTPRE)SUFF_$(EXT)))
     845out         := $(outbase)$(suff)
     846PATH_$(target)   := $(patsubst %/,%,$(dir $(outbase)))
     847TARGET_$(target) := $(out)
     848$(target)_OBJS_  := $(filter %.o %.obj, \
     849        $($(target)_SOURCES) \
     850        $($(target)_SOURCES.$(bld_trg)) \
     851        $($(target)_SOURCES.$(bld_trg_arch)) \
     852        $($(target)_SOURCES.$(bld_trg_cpu)) \
     853        $($(target)_SOURCES.$(bld_type)))
    690854
    691855# source -> object
    692 $(eval $(def_target_sources))
     856$(eval $(value def_target_sources))
    693857
    694858# more library stuff.
    695 $(eval tool        := $(call _TARGET_TOOL,$(target),LD))
    696 $(eval outbase     := $(call _TARGET_BASE,$(target),$(target)))
    697 $(eval objs         = $(_OBJS_$(target)) $(filter %.o %.obj, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type))))
    698 $(eval flags       :=\
     859tool        := $(call _TARGET_TOOL,$(target),LD)
     860outbase     := $(call _TARGET_BASE,$(target),$(target))
     861flags       :=\
    699862        $(TOOL_$(tool)_LDFLAGS)\
    700863        $(TOOL_$(tool)_LDFLAGS.$(bld_type))\
     
    711874        $($(target)_LDFLAGS.$(bld_trg))\
    712875        $($(target)_LDFLAGS.$(bld_trg_arch))\
    713         $($(target)_LDFLAGS.$(bld_trg_cpu))\
    714 )
    715 $(eval libs        :=\
     876        $($(target)_LDFLAGS.$(bld_trg_cpu))
     877othersrc    := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,\
     878        $($(target)_SOURCES)\
     879        $($(target)_SOURCES.$(bld_trg)) \
     880        $($(target)_SOURCES.$(bld_trg_arch)) \
     881        $($(target)_SOURCES.$(bld_trg_cpu)) \
     882        $($(target)_SOURCES.$(bld_type)))
     883objs         = $($(target)_OBJS_)
     884libs        :=\
    716885        $($(target)_LIBS.$(bld_trg_cpu))\
    717886        $($(target)_LIBS.$(bld_trg_arch))\
     
    722891                                   $($(target)_SDKS.$(bld_type)) \
    723892                                   $($(target)_SDKS),\
    724         $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
    725         $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
    726         $(SDK_$(sdk)_LIBS.$(bld_trg))\
    727         $(SDK_$(sdk)_LIBS.$(bld_type))\
    728         $(SDK_$(sdk)_LIBS))\
     893                $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
     894                $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
     895                $(SDK_$(sdk)_LIBS.$(bld_trg))\
     896                $(SDK_$(sdk)_LIBS.$(bld_type))\
     897                $(SDK_$(sdk)_LIBS))\
    729898        $(LIBS.$(bld_trg_cpu))\
    730899        $(LIBS.$(bld_trg_arch))\
     
    735904                                   $(SDKS.$(bld_type)) \
    736905                                   $(SDKS),\
    737         $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
    738         $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
    739         $(SDK_$(sdk)_LIBS.$(bld_trg))\
    740         $(SDK_$(sdk)_LIBS.$(bld_type))\
    741         $(SDK_$(sdk)_LIBS))\
     906                $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
     907                $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
     908                $(SDK_$(sdk)_LIBS.$(bld_trg))\
     909                $(SDK_$(sdk)_LIBS.$(bld_type))\
     910                $(SDK_$(sdk)_LIBS))\
    742911        $(TOOL_$(tool)_LIBS.$(bld_trg_cpu))\
    743912        $(TOOL_$(tool)_LIBS.$(bld_trg_arch))\
    744913        $(TOOL_$(tool)_LIBS.$(bld_trg))\
    745914        $(TOOL_$(tool)_LIBS.$(bld_type))\
    746         $(TOOL_$(tool)_LIBS)\
    747 )
    748 $(eval libpath    :=\
     915        $(TOOL_$(tool)_LIBS)
     916libpath    :=\
    749917        $($(target)_LIBPATH.$(bld_trg_cpu))\
    750918        $($(target)_LIBPATH.$(bld_trg_arch))\
     
    755923                                   $($(target)_SDKS.$(bld_type)) \
    756924                                   $($(target)_SDKS),\
    757         $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
    758         $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
    759         $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
    760         $(SDK_$(sdk)_LIBPATH.$(bld_type))\
    761         $(SDK_$(sdk)_LIBPATH))\
     925                $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
     926                $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
     927                $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
     928                $(SDK_$(sdk)_LIBPATH.$(bld_type))\
     929                $(SDK_$(sdk)_LIBPATH))\
    762930        $(LIBPATH.$(bld_trg_cpu))\
    763931        $(LIBPATH.$(bld_trg_arch))\
     
    768936                                   $(SDKS.$(bld_type)) \
    769937                                   $(SDKS),\
    770         $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
    771         $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
    772         $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
    773         $(SDK_$(sdk)_LIBPATH.$(bld_type))\
    774         $(SDK_$(sdk)_LIBPATH))\
     938                $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
     939                $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
     940                $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
     941                $(SDK_$(sdk)_LIBPATH.$(bld_type))\
     942                $(SDK_$(sdk)_LIBPATH))\
    775943        $(TOOL_$(tool)_LIBPATH.$(bld_trg_cpu))\
    776944        $(TOOL_$(tool)_LIBPATH.$(bld_trg_arch))\
    777945        $(TOOL_$(tool)_LIBPATH.$(bld_trg))\
    778946        $(TOOL_$(tool)_LIBPATH.$(bld_type))\
    779         $(TOOL_$(tool)_LIBPATH)\
    780 )
    781 $(eval dirdep      := $(dir $(exe)).dir_created)
     947        $(TOOL_$(tool)_LIBPATH)
     948dirdep      := $(call DIRDEP,$(dir $(out)))
    782949## @todo fix dependencies
    783 $(eval deps        := $($(target)_DEPS))
    784 #
    785 $(eval custom_pre    := $(strip $(firstword
     950deps        := $($(target)_DEPS)
     951
     952## @todo this stuff can't be working.
     953custom_pre  := $(strip $(firstword \
    786954        $($(target)_CUSTOM_PRE.$(bld_trg).$(bld_type))\
    787955        $($(target)_CUSTOM_PRE.$(bld_trg))\
     
    792960        $(CUSTOM_PRE.$(bld_type))\
    793961        $(CUSTOM_PRE)\
    794 )))
    795 $(eval custom_post    := $(strip $(firstword
     962))
     963custom_post    := $(strip $(firstword \
    796964        $($(target)_CUSTOM_POST.$(bld_trg).$(bld_type))\
    797965        $($(target)_CUSTOM_POST.$(bld_trg))\
     
    802970        $(CUSTOM_POST.$(bld_type))\
    803971        $(CUSTOM_POST)\
    804 )))
    805 $(eval othersrc    := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,$($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type))))
    806 
     972))
     973
     974# installation targets
     975ifndef $(target)_NOINST
     976INSTARGET_$(target) := $(patsubst %/,%/$(notdir $(out)), \
     977        $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(definst)/))
     978ifdef KBUILD_DO_AUTO_INSTALL
     979$(typevar)  += $(INSTARGET_$(target))
     980else
     981$(typevar)  += $(out)
     982endif
     983# generate the install rule
     984$(eval $(def_link_install_rule))
     985
     986else # NOINST
     987INSTARGET_$(target) :=
     988$(typevar)  += $(out)
     989endif # NOINST
     990
     991endef
     992
     993
     994##
     995# Typical link epilog.
     996#
     997# @param        $(target)   Normalized target name.
     998# @param        $(out)      The output file.
     999define def_link_epilog
     1000
     1001_INSTALLS    += $(INSTARGET_$(target))
     1002_OBJS        += $($(target)_OBJS_)
     1003_OUT_FILES   += $(out)
     1004_CLEAN_FILES += $($(target)_CLEAN)
     1005
     1006endef
     1007
     1008
     1009#
     1010# BLDPROGS
     1011#
     1012
     1013## Build program (one).
     1014# @param    $(target)   Normalized target (program) name.
     1015define def_bldprog
     1016
     1017# set NOINST if not forced installation.
     1018ifndef $(target)_INST
     1019$(target)_NOINST := 1
     1020endif
     1021
     1022# prolog
     1023$(eval $(value def_link_prolog))
     1024
     1025# body
    8071026ifndef TOOL_$(tool)_LINK_PROGRAM
    808 $$(warning kBuild: TOOL_$(tool)_LINK_PROGRAM is not defined. target=$(target) )
    809 $$(warning kBuild: tools: \
     1027$(warning kBuild: tools: \
    8101028        1 $($(target)_$(source)TOOL.$(bld_trg)) \
    8111029        2 $($(target)_$(source)TOOL) \
     
    8141032        5 $(TOOL.$(bld_trg)) \
    8151033        6 $(TOOL) )
    816 endif
    817 
     1034$(error kBuild: TOOL_$(tool)_LINK_PROGRAM is not defined. target=$(target) )
     1035endif
    8181036$(eval $(TOOL_$(tool)_LINK_PROGRAM))
    8191037
    820 # installing
    821 ifdef $(target)_INST
    822 #ifndef KBUILD_NEW_STUFF
    823 $(eval pubexe := $(PATH_BIN)/$(notdir $(exe)))
    824 $(pubexe) : $(exe) $(dir $(pubexe)).dir_created
    825         $(RM) -f $(pubexe)
    826         $(CP) $(exe) $(pubexe)
    827 #else
    828 #$ (eval pubexe := $(patsubst %/,%/$(notdir $(exe)), \
    829 #       $ (if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(PATH_BIN)/)))
    830 #$ (pubexe) : $(exe) $(addsuffix .dir_created, $(dir $(pubexe)))
    831 #       $ (RM) -f $$@
    832 #       $ (CP) $(exe) $$@
    833 #endif
    834 
    835 _BLDPROGS  += $(pubexe)
    836 _OUT_FILES += $(exe) $(pubexe)
    837 _DIRS      += $(dir $(pubexe))
    838 else
    839 _BLDPROGS  += $(exe)
    840 _OUT_FILES += $(exe)
    841 endif
    842 _OBJS += $(_OBJS_$(target))
     1038# epilog
     1039$(eval $(value def_link_epilog))
     1040
    8431041endef
    8441042
    8451043# Process build programs.
    846 $(foreach target, $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)), $(eval $(def_bldprog)))
    847 
    848 
    849 
    850 #
    851 # LIBRARIES
    852 #
    853 
    854 ## Library (one).
    855 # @param    $(target)   Normalized library (target) name.
    856 define def_lib
    857 # library basics
    858 ## @todo prefix
    859 $(eval bld_type    := $(firstword $($(target)_BLD_TYPE)     $(BUILD_TYPE)))
    860 $(eval bld_trg     := $(firstword $($(target)_BLD_TRG)      $(BUILD_TARGET)))
    861 $(eval bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH)))
    862 $(eval bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU)  $(BUILD_TARGET_CPU)))
    863 $(eval tool        := $(call _TARGET_TOOL,$(target),AR))
    864 ifeq ($(tool),)
    865 $$(error kBuild: Library target $(target) doesn't have a tool defined!)
    866 endif
    867 $(eval outbase     := $(call _TARGET_BASE,$(target),$(target)))
    868 $(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
    869 $(eval libsuff     := $(firstword\
    870         $($(target)_LIBSUFF.$(bld_trg))\
    871         $($(target)_LIBSUFF)\
    872         $(TOOL_$(tool)_ARLIBSUFF.$(bld_trg))\
    873         $(TOOL_$(tool)_ARLIBSUFF)\
    874         $(SUFF_LIB)\
    875 ))
    876 $(eval lib         := $(outbase)$(libsuff))
    877 $(eval TARGET_$(target) := $(lib))
    878 
    879 # source -> object
    880 $(eval $(def_target_sources))
    881 
    882 # library linking
    883 $(eval tool        := $(call _TARGET_TOOL,$(target),AR))
    884 $(eval outbase     := $(call _TARGET_BASE,$(target),$(target)))
    885 $(eval flags       :=\
    886         $(TOOL_$(tool)_ARFLAGS)\
    887         $(TOOL_$(tool)_ARFLAGS.$(bld_type))\
    888         $(ARFLAGS)\
    889         $(ARFLAGS.$(bld_type))\
    890         $($(target)_ARFLAGS)\
    891         $($(target)_ARFLAGS.$(bld_type))\
    892         )
    893 $(eval objs         = $(_OBJS_$(target)) $(filter %.o %.obj, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type))))
    894 $(eval othersrc    := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,$($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type))))
    895 $(eval dirdep      := $(dir $(lib)).dir_created)
    896 ## @todo fix dependencies on makefiles an such
    897 $(eval deps        := $($(target)_DEPS))
    898 
    899 $(eval $(TOOL_$(tool)_LINK_LIBRARY))
    900 
    901 # installing
    902 ifndef $(target)_NOINST
    903 # ifndef KBUILD_NEW_STUFF
    904 $(eval publib := $(PATH_LIB)/$(notdir $(lib)))
    905 $(publib) : $(lib) $(dir $(publib)).dir_created
    906         $(RM) -f $(publib)
    907         $(CP) $(lib) $(publib)
    908 #else
    909 #$ ( eval publib := $(patsubst %/,%/$(notdir $(lib)), \
    910 #       $ ( if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(PATH_LIB)/)))
    911 #$ ( publib) : $(lib) $(addsuffix .dir_created, $(dir $(publib)))
    912 #       $ ( RM) -f $$@
    913 #       $ ( CP) $(lib) $$@
    914 #endif
    915 
    916 _LIBS      += $(publib)
    917 _OUT_FILES += $(lib) $(publib)
    918 _DIRS      += $(dir $(publib))
    919 else
    920 _LIBS += $(lib)
    921 _OUT_FILES += $(lib)
    922 endif
    923 _OBJS += $(_OBJS_$(target))
    924 endef
    925 
    926 # Process libraries
    927 $(foreach target, $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)), $(eval $(def_lib)))
     1044EXT     := EXE
     1045EXTPRE  := HOST
     1046definst := $(PATH_BIN)
     1047typevar := _BLDPROGS
     1048bld_trg_base_var := PLATFORM
     1049$(foreach target, $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)), $(eval $(value def_bldprog)))
    9281050
    9291051
     
    9361058# @param    $(target)   Normalized target (program) name.
    9371059define def_dll
    938 # dllmod basics
    939 $(eval bld_type    := $(firstword $($(target)_BLD_TYPE)     $(BUILD_TYPE)))
    940 $(eval bld_trg     := $(firstword $($(target)_BLD_TRG)      $(BUILD_TARGET)))
    941 $(eval bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH)))
    942 $(eval bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU)  $(BUILD_TARGET_CPU)))
    943 $(eval tool        := $(call _TARGET_TOOL,$(target),LD))
    944 $(eval outbase     := $(call _TARGET_BASE,$(target),$(target)))
    945 $(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
    946 $(eval dllsuff     := $(firstword $($(target)_DLLSUFF) $($(target)_DLLSUFF) $(TOOL_$(tool)_LDDLLSUFF) $(SUFF_DLL)))
    947 $(eval dll         := $(outbase)$(dllsuff))
    948 $(eval TARGET_$(target) := $(dll))
    949 
    950 # source -> object
    951 $(eval $(def_target_sources))
    952 
    953 # dllmod linking.
    954 $(eval tool        := $(call _TARGET_TOOL,$(target),LD))
    955 $(eval outbase     := $(call _TARGET_BASE,$(target),$(target)))
    956 $(eval objs         = $(_OBJS_$(target)) $(filter %.o %.obj, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type))))
    957 
    958 $(eval flags       :=\
    959         $(TOOL_$(tool)_LDFLAGS)\
    960         $(TOOL_$(tool)_LDFLAGS.$(bld_type))\
    961         $(TOOL_$(tool)_LDFLAGS.$(bld_trg))\
    962         $(TOOL_$(tool)_LDFLAGS.$(bld_trg_arch))\
    963         $(TOOL_$(tool)_LDFLAGS.$(bld_trg_cpu))\
    964         $(LDFLAGS)\
    965         $(LDFLAGS.$(bld_type))\
    966         $(LDFLAGS.$(bld_trg))\
    967         $(LDFLAGS.$(bld_trg_arch))\
    968         $(LDFLAGS.$(bld_trg_cpu))\
    969         $($(target)_LDFLAGS)\
    970         $($(target)_LDFLAGS.$(bld_type))\
    971         $($(target)_LDFLAGS.$(bld_trg))\
    972         $($(target)_LDFLAGS.$(bld_trg_arch))\
    973         $($(target)_LDFLAGS.$(bld_trg_cpu))\
    974 )
    975 $(eval libs        :=\
    976         $($(target)_LIBS.$(bld_trg_cpu))\
    977         $($(target)_LIBS.$(bld_trg_arch))\
    978         $($(target)_LIBS.$(bld_trg))\
    979         $($(target)_LIBS.$(bld_type))\
    980         $($(target)_LIBS)\
    981         $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
    982                                    $($(target)_SDKS.$(bld_type)) \
    983                                    $($(target)_SDKS),\
    984         $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
    985         $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
    986         $(SDK_$(sdk)_LIBS.$(bld_trg))\
    987         $(SDK_$(sdk)_LIBS.$(bld_type))\
    988         $(SDK_$(sdk)_LIBS))\
    989         $(LIBS.$(bld_trg_cpu))\
    990         $(LIBS.$(bld_trg_arch))\
    991         $(LIBS.$(bld_trg))\
    992         $(LIBS.$(bld_type))\
    993         $(LIBS)\
    994         $(foreach sdk, $(SDKS.$(bld_trg)) \
    995                                    $(SDKS.$(bld_type)) \
    996                                    $(SDKS),\
    997         $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
    998         $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
    999         $(SDK_$(sdk)_LIBS.$(bld_trg))\
    1000         $(SDK_$(sdk)_LIBS.$(bld_type))\
    1001         $(SDK_$(sdk)_LIBS))\
    1002         $(TOOL_$(tool)_LIBS.$(bld_trg_cpu))\
    1003         $(TOOL_$(tool)_LIBS.$(bld_trg_arch))\
    1004         $(TOOL_$(tool)_LIBS.$(bld_trg))\
    1005         $(TOOL_$(tool)_LIBS.$(bld_type))\
    1006         $(TOOL_$(tool)_LIBS)\
    1007 )
    1008 $(eval libpath    :=\
    1009         $($(target)_LIBPATH.$(bld_trg_cpu))\
    1010         $($(target)_LIBPATH.$(bld_trg_arch))\
    1011         $($(target)_LIBPATH.$(bld_trg))\
    1012         $($(target)_LIBPATH.$(bld_type))\
    1013         $($(target)_LIBPATH)\
    1014         $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
    1015                                    $($(target)_SDKS.$(bld_type)) \
    1016                                    $($(target)_SDKS),\
    1017         $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
    1018         $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
    1019         $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
    1020         $(SDK_$(sdk)_LIBPATH.$(bld_type))\
    1021         $(SDK_$(sdk)_LIBPATH))\
    1022         $(LIBPATH.$(bld_trg_cpu))\
    1023         $(LIBPATH.$(bld_trg_arch))\
    1024         $(LIBPATH.$(bld_trg))\
    1025         $(LIBPATH.$(bld_type))\
    1026         $(LIBPATH)\
    1027         $(foreach sdk, $(SDKS.$(bld_trg)) \
    1028                                    $(SDKS.$(bld_type)) \
    1029                                    $(SDKS),\
    1030         $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
    1031         $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
    1032         $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
    1033         $(SDK_$(sdk)_LIBPATH.$(bld_type))\
    1034         $(SDK_$(sdk)_LIBPATH))\
    1035         $(TOOL_$(tool)_LIBPATH.$(bld_trg_cpu))\
    1036         $(TOOL_$(tool)_LIBPATH.$(bld_trg_arch))\
    1037         $(TOOL_$(tool)_LIBPATH.$(bld_trg))\
    1038         $(TOOL_$(tool)_LIBPATH.$(bld_type))\
    1039         $(TOOL_$(tool)_LIBPATH)\
    1040 )
    1041 $(eval dirdep      := $(dir $(dll)).dir_created)
    1042 ## @todo fix dependencies
    1043 $(eval deps        := $($(target)_DEPS))
    1044 #
    1045 $(eval custom_pre    := $(strip $(firstword
    1046         $($(target)_CUSTOM_PRE.$(bld_trg).$(bld_type))\
    1047         $($(target)_CUSTOM_PRE.$(bld_trg))\
    1048         $($(target)_CUSTOM_PRE.$(bld_type))\
    1049         $($(target)_CUSTOM_PRE)\
    1050         $(CUSTOM_PRE.$(bld_trg).$(bld_type))\
    1051         $(CUSTOM_PRE.$(bld_trg))\
    1052         $(CUSTOM_PRE.$(bld_type))\
    1053         $(CUSTOM_PRE)\
    1054 )))
    1055 $(eval custom_post    := $(strip $(firstword
    1056         $($(target)_CUSTOM_POST.$(bld_trg).$(bld_type))\
    1057         $($(target)_CUSTOM_POST.$(bld_trg))\
    1058         $($(target)_CUSTOM_POST.$(bld_type))\
    1059         $($(target)_CUSTOM_POST)\
    1060         $(CUSTOM_POST.$(bld_trg).$(bld_type))\
    1061         $(CUSTOM_POST.$(bld_trg))\
    1062         $(CUSTOM_POST.$(bld_type))\
    1063         $(CUSTOM_POST)\
    1064 )))
    1065 $(eval othersrc    := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,$($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type))))
    1066 
     1060
     1061# prolog
     1062$(eval $(value def_link_prolog))
     1063
     1064# body
    10671065ifndef TOOL_$(tool)_LINK_DLL
    1068 $$(warning kBuild: TOOL_$(tool)_LINK_DLL is not defined. target=$(target) )
    1069 $$(warning kBuild: tools: \
     1066$(warning kBuild: tools: \
    10701067        1 $($(target)_$(source)TOOL.$(bld_trg)) \
    10711068        2 $($(target)_$(source)TOOL) \
     
    10761073        7 $(TOOL.$(bld_trg)) \
    10771074        8 $(TOOL) )
    1078 endif
    1079 
     1075$(error kBuild: TOOL_$(tool)_LINK_DLL is not defined. target=$(target) )
     1076endif
    10801077$(eval $(TOOL_$(tool)_LINK_DLL))
    10811078
    1082 
    1083 # installing
    1084 ifndef $(target)_NOINST
    1085 #ifndef KBUILD_NEW_STUFF
    1086 $(eval pubdll := $(PATH_BIN)/$(notdir $(dll)))
    1087 $(pubdll) : $(dll) $(dir $(pubdll)).dir_created
    1088         $(RM) -f $(pubdll)
    1089         $(CP) $(dll) $(pubdll)
    1090 #else
    1091 #$ (eval pubdll := $(patsubst %/,%/$(notdir $(dll)), \
    1092 #       $ (if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(PATH_DLL)/)))
    1093 #$ (pubdll) : $(dll) $(addsuffix .dir_created, $(dir $(publib)))
    1094 #       $(RM) -f $$@
    1095 #       $(CP) $(dll) $$@
    1096 #endif
    1097 
    1098 $(eval TARGET_PUB_$(target) := $(pubdll))
    1099 _DLLS      += $(pubdll)
    1100 _OUT_FILES += $(dll) $(pubdll)
    1101 _DIRS      += $(dir $(pubdll))
    1102 else
    1103 _DLLS      += $(dll)
    1104 _OUT_FILES += $(dll)
    1105 endif
    1106 _OBJS += $(_OBJS_$(target))
     1079# epilog
     1080$(eval $(value def_link_epilog))
     1081
    11071082endef
    11081083
    11091084# Process dlls
    1110 $(foreach target, $(DLLS) $(DLLS.$(BUILD_TARGET)), $(eval $(def_dll)))
     1085EXT     := DLL
     1086EXTPRE  :=
     1087definst := $(PATH_DLL)
     1088typevar := _DLLS
     1089bld_trg_base_var := TARGET
     1090$(foreach target, $(DLLS) $(DLLS.$(BUILD_TARGET)), $(eval $(value def_dll)))
    11111091
    11121092
     
    11181098#   - On other platforms they are fake DLLs.
    11191099ifeq ($(subst win32,os2,$(BUILD_TARGET)),os2)
    1120 $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval $(def_lib)))
     1100$(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval $(value def_lib)))
    11211101else
    1122 $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval $(def_dll)))
    1123 endif
    1124 $(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval _IMPORT_LIBS += $(firstword $(TARGET_PUB_$(target)) $(TARGET_$(target)))))
    1125 
     1102$(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval $(value def_dll)))
     1103endif
     1104$(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), \
     1105        $(eval _IMPORT_LIBS += $(if $(INSTARGET_$(target)),$(INSTARGET_$(target)), $(TARGET_$(target)))))
    11261106
    11271107
     
    11331113# @param    $(target)   Normalized target (program) name.
    11341114define def_program
    1135 # basics
    1136 $(eval bld_type    := $(firstword $($(target)_BLD_TYPE)     $(BUILD_TYPE)))
    1137 $(eval bld_trg     := $(firstword $($(target)_BLD_TRG)      $(BUILD_TARGET)))
    1138 $(eval bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH)))
    1139 $(eval bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU)  $(BUILD_TARGET_CPU)))
    1140 $(eval tool        := $(call _TARGET_TOOL,$(target),LD))
    1141 $(eval outbase     := $(call _TARGET_BASE,$(target),$(target)))
    1142 $(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
    1143 $(eval exesuff     := $(firstword $($(target)_EXESUFF) $($(target)_EXESUFF) $(TOOL_$(tool)_LDEXESUFF) $(SUFF_EXE)))
    1144 $(eval exe         := $(outbase)$(exesuff))
    1145 $(eval TARGET_$(target) := $(exe))
    1146 
    1147 # source -> object
    1148 $(eval $(def_target_sources))
    1149 
    1150 # more library stuff.
    1151 $(eval tool        := $(call _TARGET_TOOL,$(target),LD))
    1152 $(eval outbase     := $(call _TARGET_BASE,$(target),$(target)))
    1153 $(eval objs         = $(_OBJS_$(target)) $(filter %.o %.obj, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type))))
    1154 
    1155 $(eval flags       :=\
    1156         $(TOOL_$(tool)_LDFLAGS)\
    1157         $(TOOL_$(tool)_LDFLAGS.$(bld_type))\
    1158         $(TOOL_$(tool)_LDFLAGS.$(bld_trg))\
    1159         $(TOOL_$(tool)_LDFLAGS.$(bld_trg_arch))\
    1160         $(TOOL_$(tool)_LDFLAGS.$(bld_trg_cpu))\
    1161         $(LDFLAGS)\
    1162         $(LDFLAGS.$(bld_type))\
    1163         $(LDFLAGS.$(bld_trg))\
    1164         $(LDFLAGS.$(bld_trg_arch))\
    1165         $(LDFLAGS.$(bld_trg_cpu))\
    1166         $($(target)_LDFLAGS)\
    1167         $($(target)_LDFLAGS.$(bld_type))\
    1168         $($(target)_LDFLAGS.$(bld_trg))\
    1169         $($(target)_LDFLAGS.$(bld_trg_arch))\
    1170         $($(target)_LDFLAGS.$(bld_trg_cpu))\
    1171 )
    1172 $(eval libs        :=\
    1173         $($(target)_LIBS.$(bld_trg_cpu))\
    1174         $($(target)_LIBS.$(bld_trg_arch))\
    1175         $($(target)_LIBS.$(bld_trg))\
    1176         $($(target)_LIBS.$(bld_type))\
    1177         $($(target)_LIBS)\
    1178         $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
    1179                                    $($(target)_SDKS.$(bld_type)) \
    1180                                    $($(target)_SDKS),\
    1181         $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
    1182         $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
    1183         $(SDK_$(sdk)_LIBS.$(bld_trg))\
    1184         $(SDK_$(sdk)_LIBS.$(bld_type))\
    1185         $(SDK_$(sdk)_LIBS))\
    1186         $(LIBS.$(bld_trg_cpu))\
    1187         $(LIBS.$(bld_trg_arch))\
    1188         $(LIBS.$(bld_trg))\
    1189         $(LIBS.$(bld_type))\
    1190         $(LIBS)\
    1191         $(foreach sdk, $(SDKS.$(bld_trg)) \
    1192                                    $(SDKS.$(bld_type)) \
    1193                                    $(SDKS),\
    1194         $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
    1195         $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
    1196         $(SDK_$(sdk)_LIBS.$(bld_trg))\
    1197         $(SDK_$(sdk)_LIBS.$(bld_type))\
    1198         $(SDK_$(sdk)_LIBS))\
    1199         $(TOOL_$(tool)_LIBS.$(bld_trg_cpu))\
    1200         $(TOOL_$(tool)_LIBS.$(bld_trg_arch))\
    1201         $(TOOL_$(tool)_LIBS.$(bld_trg))\
    1202         $(TOOL_$(tool)_LIBS.$(bld_type))\
    1203         $(TOOL_$(tool)_LIBS)\
    1204 )
    1205 $(eval libpath    :=\
    1206         $($(target)_LIBPATH.$(bld_trg_cpu))\
    1207         $($(target)_LIBPATH.$(bld_trg_arch))\
    1208         $($(target)_LIBPATH.$(bld_trg))\
    1209         $($(target)_LIBPATH.$(bld_type))\
    1210         $($(target)_LIBPATH)\
    1211         $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
    1212                                    $($(target)_SDKS.$(bld_type)) \
    1213                                    $($(target)_SDKS),\
    1214         $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
    1215         $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
    1216         $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
    1217         $(SDK_$(sdk)_LIBPATH.$(bld_type))\
    1218         $(SDK_$(sdk)_LIBPATH))\
    1219         $(LIBPATH.$(bld_trg_cpu))\
    1220         $(LIBPATH.$(bld_trg_arch))\
    1221         $(LIBPATH.$(bld_trg))\
    1222         $(LIBPATH.$(bld_type))\
    1223         $(LIBPATH)\
    1224         $(foreach sdk, $(SDKS.$(bld_trg)) \
    1225                                    $(SDKS.$(bld_type)) \
    1226                                    $(SDKS),\
    1227         $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
    1228         $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
    1229         $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
    1230         $(SDK_$(sdk)_LIBPATH.$(bld_type))\
    1231         $(SDK_$(sdk)_LIBPATH))\
    1232         $(TOOL_$(tool)_LIBPATH.$(bld_trg_cpu))\
    1233         $(TOOL_$(tool)_LIBPATH.$(bld_trg_arch))\
    1234         $(TOOL_$(tool)_LIBPATH.$(bld_trg))\
    1235         $(TOOL_$(tool)_LIBPATH.$(bld_type))\
    1236         $(TOOL_$(tool)_LIBPATH)\
    1237 )
    1238 $(eval dirdep      := $(dir $(exe)).dir_created)
    1239 ## @todo fix dependencies
    1240 $(eval deps        := $($(target)_DEPS))
    1241 #
    1242 $(eval custom_pre    := $(strip $(firstword
    1243         $($(target)_CUSTOM_PRE.$(bld_trg).$(bld_type))\
    1244         $($(target)_CUSTOM_PRE.$(bld_trg))\
    1245         $($(target)_CUSTOM_PRE.$(bld_type))\
    1246         $($(target)_CUSTOM_PRE)\
    1247         $(CUSTOM_PRE.$(bld_trg).$(bld_type))\
    1248         $(CUSTOM_PRE.$(bld_trg))\
    1249         $(CUSTOM_PRE.$(bld_type))\
    1250         $(CUSTOM_PRE)\
    1251 )))
    1252 $(eval custom_post    := $(strip $(firstword
    1253         $($(target)_CUSTOM_POST.$(bld_trg).$(bld_type))\
    1254         $($(target)_CUSTOM_POST.$(bld_trg))\
    1255         $($(target)_CUSTOM_POST.$(bld_type))\
    1256         $($(target)_CUSTOM_POST)\
    1257         $(CUSTOM_POST.$(bld_trg).$(bld_type))\
    1258         $(CUSTOM_POST.$(bld_trg))\
    1259         $(CUSTOM_POST.$(bld_type))\
    1260         $(CUSTOM_POST)\
    1261 )))
    1262 $(eval othersrc    := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,$($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type))))
    1263 
    1264 $(eval $(TOOL_$(tool)_LINK_PROGRAM))
    1265 
    1266 # installing
    1267 ifndef $(target)_NOINST
    1268 #ifndef KBUILD_NEW_STUFF
    1269 $(eval pubexe := $(PATH_BIN)/$(notdir $(exe)))
    1270 $(pubexe) : $(exe) $(dir $(pubexe)).dir_created
    1271         $(RM) -f $(pubexe)
    1272         $(CP) $(exe) $(pubexe)
    1273 #else
    1274 #$ (eval pubexe := $(patsubst %/,%/$(notdir $(exe)), \
    1275 #       $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(PATH_BIN)/)))
    1276 #$ (pubexe) : $(exe) $(addsuffix .dir_created, $(dir $(pubexe)))
    1277 #       $(RM) -f $$@
    1278 #       $(CP) $(exe) $$@
    1279 #endif
    1280 
    1281 _PROGRAMS  += $(pubexe)
    1282 _OUT_FILES += $(exe) $(pubexe)
    1283 _DIRS      += $(dir $(pubexe))
    1284 else
    1285 _PROGRAMS  += $(exe)
    1286 _OUT_FILES += $(exe)
    1287 endif
    1288 _OBJS += $(_OBJS_$(target))
    1289 endef
    1290 
    1291 # Process libraries
    1292 $(foreach target, $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)), $(eval $(def_program)))
    1293 
    1294 
    1295 
    1296 #
    1297 # SYSMODS
    1298 #
    1299 
    1300 ## System module (one).
    1301 # @param    $(target)   Normalized target (program) name.
    1302 define def_sysmod
    1303 # sysmod basics
    1304 $(eval bld_type    := $(firstword $($(target)_BLD_TYPE)     $(BUILD_TYPE)))
    1305 $(eval bld_trg     := $(firstword $($(target)_BLD_TRG)      $(BUILD_TARGET)))
    1306 $(eval bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH)))
    1307 $(eval bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU)  $(BUILD_TARGET_CPU)))
    1308 $(eval tool        := $(call _TARGET_TOOL,$(target),LD))
    1309 $(eval outbase     := $(call _TARGET_BASE,$(target),$(target)))
    1310 $(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
    1311 $(eval syssuff     := $(firstword $($(target)_SYSSUFF) $($(target)_SYSSUFF) $(TOOL_$(tool)_LDSYSSUFF) $(SUFF_SYS)))
    1312 $(eval sys         := $(outbase)$(syssuff))
    1313 $(eval TARGET_$(target) := $(sys))
    1314 
    1315 # source -> object
    1316 $(eval $(def_target_sources))
    1317 
    1318 # sysmod linking
    1319 $(eval tool        := $(call _TARGET_TOOL,$(target),LD))
    1320 $(eval outbase     := $(call _TARGET_BASE,$(target),$(target)))
    1321 $(eval objs         = $(_OBJS_$(target)) $(filter %.o %.obj, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type))))
    1322 
    1323 $(eval flags       :=\
    1324         $(TOOL_$(tool)_LDFLAGS)\
    1325         $(TOOL_$(tool)_LDFLAGS.$(bld_type))\
    1326         $(TOOL_$(tool)_LDFLAGS.$(bld_trg))\
    1327         $(TOOL_$(tool)_LDFLAGS.$(bld_trg_arch))\
    1328         $(TOOL_$(tool)_LDFLAGS.$(bld_trg_cpu))\
    1329         $(LDFLAGS)\
    1330         $(LDFLAGS.$(bld_type))\
    1331         $(LDFLAGS.$(bld_trg))\
    1332         $(LDFLAGS.$(bld_trg_arch))\
    1333         $(LDFLAGS.$(bld_trg_cpu))\
    1334         $($(target)_LDFLAGS)\
    1335         $($(target)_LDFLAGS.$(bld_type))\
    1336         $($(target)_LDFLAGS.$(bld_trg))\
    1337         $($(target)_LDFLAGS.$(bld_trg_arch))\
    1338         $($(target)_LDFLAGS.$(bld_trg_cpu))\
    1339 )
    1340 $(eval libs        :=\
    1341         $($(target)_LIBS.$(bld_trg_cpu))\
    1342         $($(target)_LIBS.$(bld_trg_arch))\
    1343         $($(target)_LIBS.$(bld_trg))\
    1344         $($(target)_LIBS.$(bld_type))\
    1345         $($(target)_LIBS)\
    1346         $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
    1347                                    $($(target)_SDKS.$(bld_type)) \
    1348                                    $($(target)_SDKS),\
    1349         $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
    1350         $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
    1351         $(SDK_$(sdk)_LIBS.$(bld_trg))\
    1352         $(SDK_$(sdk)_LIBS.$(bld_type))\
    1353         $(SDK_$(sdk)_LIBS))\
    1354         $(LIBS.$(bld_trg_cpu))\
    1355         $(LIBS.$(bld_trg_arch))\
    1356         $(LIBS.$(bld_trg))\
    1357         $(LIBS.$(bld_type))\
    1358         $(LIBS)\
    1359         $(foreach sdk, $(SDKS.$(bld_trg)) \
    1360                                    $(SDKS.$(bld_type)) \
    1361                                    $(SDKS),\
    1362         $(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
    1363         $(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
    1364         $(SDK_$(sdk)_LIBS.$(bld_trg))\
    1365         $(SDK_$(sdk)_LIBS.$(bld_type))\
    1366         $(SDK_$(sdk)_LIBS))\
    1367         $(TOOL_$(tool)_LIBS.$(bld_trg_cpu))\
    1368         $(TOOL_$(tool)_LIBS.$(bld_trg_arch))\
    1369         $(TOOL_$(tool)_LIBS.$(bld_trg))\
    1370         $(TOOL_$(tool)_LIBS.$(bld_type))\
    1371         $(TOOL_$(tool)_LIBS)\
    1372 )
    1373 $(eval libpath    :=\
    1374         $($(target)_LIBPATH.$(bld_trg_cpu))\
    1375         $($(target)_LIBPATH.$(bld_trg_arch))\
    1376         $($(target)_LIBPATH.$(bld_trg))\
    1377         $($(target)_LIBPATH.$(bld_type))\
    1378         $($(target)_LIBPATH)\
    1379         $(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
    1380                                    $($(target)_SDKS.$(bld_type)) \
    1381                                    $($(target)_SDKS),\
    1382         $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
    1383         $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
    1384         $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
    1385         $(SDK_$(sdk)_LIBPATH.$(bld_type))\
    1386         $(SDK_$(sdk)_LIBPATH))\
    1387         $(LIBPATH.$(bld_trg_cpu))\
    1388         $(LIBPATH.$(bld_trg_arch))\
    1389         $(LIBPATH.$(bld_trg))\
    1390         $(LIBPATH.$(bld_type))\
    1391         $(LIBPATH)\
    1392         $(foreach sdk, $(SDKS.$(bld_trg)) \
    1393                                    $(SDKS.$(bld_type)) \
    1394                                    $(SDKS),\
    1395         $(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
    1396         $(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
    1397         $(SDK_$(sdk)_LIBPATH.$(bld_trg))\
    1398         $(SDK_$(sdk)_LIBPATH.$(bld_type))\
    1399         $(SDK_$(sdk)_LIBPATH))\
    1400         $(TOOL_$(tool)_LIBPATH.$(bld_trg_cpu))\
    1401         $(TOOL_$(tool)_LIBPATH.$(bld_trg_arch))\
    1402         $(TOOL_$(tool)_LIBPATH.$(bld_trg))\
    1403         $(TOOL_$(tool)_LIBPATH.$(bld_type))\
    1404         $(TOOL_$(tool)_LIBPATH)\
    1405 )
    1406 $(eval dirdep      := $(dir $(sys)).dir_created)
    1407 ## @todo fix dependencies
    1408 $(eval deps        := $($(target)_DEPS))
    1409 #
    1410 $(eval custom_pre    := $(strip $(firstword
    1411         $($(target)_CUSTOM_PRE.$(bld_trg).$(bld_type))\
    1412         $($(target)_CUSTOM_PRE.$(bld_trg))\
    1413         $($(target)_CUSTOM_PRE.$(bld_type))\
    1414         $($(target)_CUSTOM_PRE)\
    1415         $(CUSTOM_PRE.$(bld_trg).$(bld_type))\
    1416         $(CUSTOM_PRE.$(bld_trg))\
    1417         $(CUSTOM_PRE.$(bld_type))\
    1418         $(CUSTOM_PRE)\
    1419 )))
    1420 $(eval custom_post    := $(strip $(firstword
    1421         $($(target)_CUSTOM_POST.$(bld_trg).$(bld_type))\
    1422         $($(target)_CUSTOM_POST.$(bld_trg))\
    1423         $($(target)_CUSTOM_POST.$(bld_type))\
    1424         $($(target)_CUSTOM_POST)\
    1425         $(CUSTOM_POST.$(bld_trg).$(bld_type))\
    1426         $(CUSTOM_POST.$(bld_trg))\
    1427         $(CUSTOM_POST.$(bld_type))\
    1428         $(CUSTOM_POST)\
    1429 )))
    1430 $(eval othersrc    := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm %.o %.obj,$($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type))))
    1431 
    1432 ifndef TOOL_$(tool)_LINK_SYSMOD
    1433 $$(warning kBuild: TOOL_$(tool)_LINK_SYSMOD is not defined. target=$(target) )
    1434 $$(warning kBuild: tools: \
     1115
     1116# prolog
     1117$(eval $(value def_link_prolog))
     1118
     1119# body
     1120ifndef TOOL_$(tool)_LINK_PROGRAM
     1121$(warning kBuild: tools: \
    14351122        1 $($(target)_$(source)TOOL.$(bld_trg)) \
    14361123        2 $($(target)_$(source)TOOL) \
     
    14411128        7 $(TOOL.$(bld_trg)) \
    14421129        8 $(TOOL) )
    1443 endif
    1444 
     1130$(error kBuild: TOOL_$(tool)_LINK_PROGRAM is not defined. target=$(target) )
     1131endif
     1132$(eval $(TOOL_$(tool)_LINK_PROGRAM))
     1133
     1134# epilog
     1135$(eval $(value def_link_epilog))
     1136
     1137endef
     1138
     1139# Process programs
     1140EXT     := EXE
     1141EXTPRE  :=
     1142definst := $(PATH_BIN)
     1143typevar := _PROGRAMS
     1144bld_trg_base_var := TARGET
     1145$(foreach target, $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)), $(eval $(value def_program)))
     1146
     1147
     1148
     1149#
     1150# SYSMODS
     1151#
     1152
     1153## System module (one).
     1154# @param    $(target)   Normalized target (program) name.
     1155define def_sysmod
     1156
     1157# prolog
     1158$(eval $(value def_link_prolog))
     1159
     1160# body
     1161ifndef TOOL_$(tool)_LINK_SYSMOD
     1162$(warning kBuild: tools: \
     1163        1 $($(target)_$(source)TOOL.$(bld_trg)) \
     1164        2 $($(target)_$(source)TOOL) \
     1165        3 $($(target)_TOOL.$(bld_trg)) \
     1166        4 $($(target)_TOOL) \
     1167        5 $($(source)TOOL) \
     1168        6 $($(source)TOOL.$(bld_trg)) \
     1169        7 $(TOOL.$(bld_trg)) \
     1170        8 $(TOOL) )
     1171$(error kBuild: TOOL_$(tool)_LINK_SYSMOD is not defined. target=$(target) )
     1172endif
    14451173$(eval $(TOOL_$(tool)_LINK_SYSMOD))
    14461174
    1447 # installing
    1448 ifndef $(target)_NOINST
    1449 #ifndef KBUILD_NEW_STUFF
    1450 $(eval pubsys := $(PATH_BIN)/$(notdir $(sys)))
    1451 $(pubsys): $(sys) $(dir $(pubsys)).dir_created
    1452         $(RM) -f $(pubsys)
    1453         $(CP) $(sys) $(pubsys)
    1454 #else
    1455 #$ (eval pubsys := $(patsubst %/,%/$(notdir $(sys)), \
    1456 #       $(if $($(target)_INST), $(addprefix $(PATH_INS)/,$($(target)_INST)), $(PATH_SYS)/)))
    1457 #$ (pubsys) : $(sys) $(addsuffix .dir_created, $(dir $(pubsys)))
    1458 #       $(RM) -f $$@
    1459 #       $(CP) $(sys) $$@
    1460 #endif
    1461 
    1462 $(eval _SYSMODS += $(pubsys))
    1463 $(eval _OUT_FILES += $(sys) $(pubsys))
    1464 _DIRS      += $(dir $(pubsys))
     1175# epilog
     1176$(eval $(value def_link_epilog))
     1177
     1178endef
     1179
     1180# Process sysmods
     1181EXT     := SYS
     1182EXTPRE  :=
     1183definst := $(PATH_SYS)
     1184typevar := _SYSMODS
     1185bld_trg_base_var := TARGET
     1186$(foreach target, $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)), $(eval $(value def_sysmod)))
     1187
     1188
     1189#
     1190# OTHERS
     1191#
     1192_OTHERS = $(OTHERS) $(OTHERS.$(BUILD_TARGET))
     1193
     1194
     1195#
     1196# INSTALLS
     1197#
     1198
     1199## generate the install rule
     1200define def_install_src_rule
     1201# the install rule
     1202$(insdst) : $(srcsrc) | $(call DIRDEP,$(dir $(insdst)))
     1203        $$(RM) -f $$@
     1204        $(inscmd)
     1205endef
     1206
     1207## install one file
     1208define def_install_src
     1209
     1210# deal with '=>' in the source file name.
     1211srcdst := $(subst =>, ,$(src))
     1212srcsrc := $(firstword $(srcdst))
     1213srcdst := $(word $(words $(srcdst)),$(srcdst))
     1214
     1215# _INSTFUN
     1216ifdef $(srcsrc)_INSTFUN
     1217instfun := $(srcsrc)_INSTFUN
    14651218else
    1466 $(eval _SYSMODS += $(sys))
    1467 $(eval _OUT_FILES += $(sys))
    1468 endif
    1469 _OBJS += $(_OBJS_$(target))
    1470 endef
    1471 
    1472 # Process sysmods
    1473 $(foreach target, $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)), $(eval $(def_sysmod)))
    1474 
    1475 
    1476 
    1477 #
    1478 # OTHERS
    1479 #
    1480 _OTHERS = $(OTHERS) $(OTHERS.$(BUILD_TARGET))
    1481 
     1219ifdef $(target)_INSTFUN
     1220instfun := $(target)_INSTFUN
     1221else
     1222instfun := _INSTALL_FILE
     1223endif
     1224endif
     1225
     1226# _INST
     1227ifdef $(srcsrc)_INST
     1228inst = $(srcsrc)_INST
     1229else
     1230ifdef $(target)_INST
     1231inst = $(target)_INST
     1232else
     1233inst =
     1234endif
     1235endif
     1236
     1237# calc target
     1238insdst := $(call $(instfun),$(srcdst),$(target),$($(inst)),$(PATH_INS))
     1239#$(warning instfun=$(instfun) srcdst=$(srcdst) target=$(target) srcdst=$(srcsrc) inst=$(inst) => insdst=$(insdst))
     1240
     1241# create the command
     1242ifdef $(srcsrc)_INSTALLER
     1243inscmd := $(call $(srcsrc)_INSTALLER,$(srcsrc),$(insdst),$(target))
     1244else
     1245ifdef $(target)_INSTALLER
     1246inscmd := $(call $(target)_INSTALLER,$(srcsrc),$(insdst),$(target))
     1247else
     1248inscmd := $$(CP) $(srcsrc) $(insdst)
     1249endif
     1250endif
     1251
     1252# generate the rule (need double evaluation here)
     1253$(eval $(def_install_src_rule))
     1254
     1255INSTARGET_$(target) += $(insdst)
     1256endef
     1257
     1258
     1259## generate the symlink rule
     1260define def_install_symlink_rule
     1261# the install rule
     1262$(insdst) : | $(call DIRDEP,$(dir $(insdst)))
     1263        $$(RM) -f $$@
     1264        $$(LN_SYMLINK) $(srcsrc) $(insdst)
     1265endef
     1266
     1267## create one symlink
     1268define def_install_symlink
     1269
     1270# deal with '=>' in the source file name.
     1271srcdst := $(subst =>, ,$(src))
     1272srcsrc := $(firstword $(srcdst))
     1273srcdst := $(word $(words $(srcdst)),$(srcdst))
     1274
     1275# _INSTFUN
     1276ifdef $(srcsrc)_INSTFUN
     1277instfun := $(srcsrc)_INSTFUN
     1278else
     1279ifdef $(target)_INSTFUN
     1280instfun := $(target)_INSTFUN
     1281else
     1282instfun := _INSTALL_FILE
     1283endif
     1284endif
     1285
     1286# _INST
     1287ifdef $(srcsrc)_INST
     1288inst = $(srcsrc)_INST
     1289else
     1290ifdef $(target)_INST
     1291inst = $(target)_INST
     1292else
     1293inst =
     1294endif
     1295endif
     1296
     1297# calc target
     1298insdst := $(call $(instfun),$(srcdst),$(target),$(inst),$(PATH_INS))
     1299#$(warning srcsrc=$(srcsrc) srcdst=$(srcdst) insdst=$(insdst))
     1300
     1301# generate the rule (need double evaluation here)
     1302$(eval $(def_install_symlink_rule))
     1303
     1304INSTARGET_$(target) += $(insdst)
     1305endef
     1306
     1307## process one install target.
     1308define def_install
     1309bld_type  := $(firstword $($(target)_BLD_TYPE)     $(BUILD_TYPE))
     1310bld_trg   := $(firstword $($(target)_BLD_TRG)      $(BUILD_TARGET))
     1311bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH))
     1312bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU)  $(BUILD_TARGET_CPU))
     1313
     1314INSTARGET_$(target) :=
     1315$(foreach src,$($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_trg_arch)) $($(target)_SOURCES.$(bld_trg_cpu)) $($(target)_SOURCES.$(bld_type)), \
     1316        $(eval $(value def_install_src)))
     1317
     1318$(foreach src,$($(target)_SYMLINKS) $($(target)_SYMLINKS.$(bld_trg)) $($(target)_SYMLINKS.$(bld_trg_arch)) $($(target)_SYMLINKS.$(bld_trg_cpu)) $($(target)_SYMLINKS.$(bld_type)), \
     1319        $(eval $(value def_install_symlink)))
     1320
     1321_INSTALLS  += $(INSTARGET_$(target))
     1322endef
     1323
     1324## process all install targets
     1325$(foreach target, $(INSTALLS) $(INSTALLS.$(BUILD_TARGET)), \
     1326        $(eval $(value def_install)))
    14821327
    14831328
     
    14881333
    14891334#
    1490 # Directories.
    1491 #
    1492 _DIRFILES := $(sort $(addsuffix /.dir_created,$(_DIRS)) $(addsuffix .dir_created,$(sort $(dir $(_OUT_FILES) $(_OBJS)))))
    1493 
    1494 define def_createdir
    1495 $(dirfile):
    1496         $(call MSG_L1,Creating directory $$(@D))
    1497         $(MKDIR) -p $$(@D)
    1498         @echo dir_created > $$@
    1499 endef
    1500 
    1501 $(foreach dirfile,$(_DIRFILES),$(eval $(def_createdir)))
    1502 
    1503 
    1504 #
    1505 # Include dependency files.
    1506 #
    1507 $(foreach dep,$(wildcard $(_DEPFILES)),$(eval include $(dep)))
     1335# PACKING
     1336#
     1337packing::
     1338
     1339
     1340#
     1341# DIRECTORIES
     1342#
     1343_DIR_ALL := $(sort $(addsuffix /,$(patsubst %/,%,$(_DIRS))) $(dir $(_OUT_FILES) $(_OBJS) $(_INSTALLS)))
     1344
     1345define def_mkdir_rule
     1346$(directory):
     1347        $(call MSG_L1,Creating directory $$@)
     1348        $(MKDIR) -p $$@
     1349endef
     1350
     1351$(foreach directory,$(_DIR_ALL),$(eval $(def_mkdir_rule)))
     1352
     1353
     1354#
     1355# NOTHING
     1356#
     1357do-nothing:
     1358        $(call MSG_L1,Did nothing in $(CURDIR))
     1359
     1360
     1361#
     1362# CLEAN UP
     1363#
     1364do-clean:
     1365        $(RM) -f $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_CLEAN_FILES) $(OTHER_CLEAN)
    15081366
    15091367
     
    15111369# PASSES (including directory and makefile walking)
    15121370#
    1513 # Do all the default passes if it's unspecified.
    1514 
    1515 #PASSES ?= bldprogs libraries binaries others publish
    1516 PASSES ?= bldprogs libraries dlls binaries others
    1517 
    1518 ## @todo figure out a generic way of configuring how pass works!
    1519 
    1520 ## Proritized list of the default makefile when walking subdirectories.
    1521 # The user can overload this list.
    1522 DEFAULT_MAKEFILE ?= Makefile.kmk makefile.kmk Makefile makefile
    15231371
    15241372## Subdir
     
    15421390endef
    15431391
    1544 
    15451392## Execute a pass.
    15461393# @param        $(pass)         Lowercase pass name.
    15471394# @param        $(PASS)         Uppercase pass name.
     1395define def_pass_old
     1396$(eval SUBDIRS_$(PASS)          ?= $(SUBDIRS)          $(SUBDIRS.$(BUILD_TARGET)))
     1397$(eval SUBDIRS_AFTER_$(PASS)    ?= $(SUBDIRS_AFTER)    $(SUBDIRS_AFTER.$(BUILD_TARGET)))
     1398$(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)))
     1399$(eval MAKEFILES_AFTER_$(PASS)  ?= $(MAKEFILES_AFTER)  $(MAKEFILES_AFTER.$(BUILD_TARGET)))
     1400
     1401$(eval tag:=_before)
     1402$(eval dep:=)
     1403$(foreach subdir,$(SUBDIRS_$(PASS))            $(SUBDIRS_$(PASS).$(BUILD_TARGET))         ,$(eval $(def_pass_subdir)))
     1404$(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)),$(eval $(def_pass_makefile)))
     1405
     1406$(eval tag:=_after)
     1407$(eval dep:=pass_$(pass)_doit)
     1408$(foreach subdir,$(SUBDIRS_AFTER_$(PASS))      $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET))   ,$(eval $(def_pass_subdir)))
     1409$(foreach makefile,$(MAKEFILES_AFTER_$(PASS))  $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_makefile)))
     1410
     1411.NOTPARALLEL: pass_$(pass)_before pass_$(pass)_after
     1412.PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_doit pass_$(pass)_after
     1413pass_$(pass)_doit:      $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$(var))
     1414pass_$(pass)_this:      pass_$(pass)_before
     1415        + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
     1416pass_$(pass)_after::    pass_$(pass)_this
     1417pass_$(pass):           pass_$(pass)_after
     1418
     1419endef
     1420
    15481421define def_pass
    15491422$(eval SUBDIRS_$(PASS)          ?= $(SUBDIRS)          $(SUBDIRS.$(BUILD_TARGET)))
     
    15621435$(foreach makefile,$(MAKEFILES_AFTER_$(PASS))  $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_makefile)))
    15631436
    1564 .NOTPARALLEL: pass_$(pass)_before pass_$(pass)_after
    1565 .PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_doit pass_$(pass)_after
     1437ifdef KBUILD_SAFE_PARALLELL
     1438.NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this
     1439.PHONY:       pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_this pass_$(pass)_doit
     1440pass_$(pass)_doit:          $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$(var))
    15661441pass_$(pass)_this:      pass_$(pass)_before
    15671442        + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
    15681443pass_$(pass)_after::    pass_$(pass)_this
    15691444pass_$(pass):           pass_$(pass)_after
    1570 
    1571 endef
    1572 
    1573 
    1574 ## PASS: bldprogs
    1575 # This pass builds targets which are required for building the rest.
    1576 pass_bldprogs_doit: $(_BLDPROGS)
    1577 pass := bldprogs
    1578 PASS := BLDPROGS
    1579 $(eval $(def_pass))
    1580 
    1581 ## PASS: libraries
    1582 # This pass builds library targets.
    1583 pass_libraries_doit: $(_LIBS) $(_IMPORT_LIBS) $(_OTHER_LIBRARIES)
    1584 pass := libraries
    1585 PASS := LIBRARIES
    1586 $(eval $(def_pass))
    1587 
    1588 ## PASS: binaries
    1589 # This pass builds dll targets.
    1590 pass_dlls_doit: $(_DLLS) $(_OTHER_DLLS)
    1591 pass := dlls
    1592 PASS := DLLS
    1593 $(eval $(def_pass))
    1594 
    1595 ## PASS: binaries
    1596 # This pass builds binary targets, i.e. programs, system modules and stuff.
    1597 pass_binaries_doit: $(_PROGRAMS) $(_SYSMODS) $(_OTHER_BINARIES)
    1598 pass := binaries
    1599 PASS := BINARIES
    1600 $(eval $(def_pass))
    1601 
    1602 ## PASS: others
    1603 # This pass builds other targets.
    1604 pass_others_doit: $(_OTHERS)
    1605 pass := others
    1606 PASS := OTHERS
    1607 $(eval $(def_pass))
    1608 
    1609 ## PASS: publish
    1610 # This pass installs the built entities to a sandbox area.
    1611 pass_publish_doit: publish
    1612 publish::
    1613 pass := publish
    1614 PASS := PUBLISH
    1615 # $(sort).. not nice.
    1616 SUBDIRS_PUBLISH         ?= $(sort $(SUBDIRS)          $(SUBDIRS.$(BUILD_TARGET))          $(SUBDIRS_LIBRARIES)          $(SUBDIRS_LIBRARIES.$(BUILD_TARGET))          $(SUBDIRS_BINARIES)          $(SUBDIRS_BINARIES.$(BUILD_TARGET))          $(SUBDIRS_OTHERS)          $(SUBDIRS_OTHERS.$(BUILD_TARGET)))
    1617 SUBDIRS_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)))
    1618 MAKEFILES_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)))
    1619 MAKEFILES_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)))
    1620 $(eval $(def_pass))
    1621 
    1622 ## PASS: packing
    1623 # This pass processes custom packing rules.
    1624 pass_packing_doit: packing
    1625 packing::
    1626 pass := packing
    1627 PASS := PACKING
    1628 $(eval $(def_pass))
    1629 
    1630 ## PASS: clean
    1631 # This pass removes all generated files.
    1632 pass_clean_doit:
    1633         $(RM) -f $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_DIRFILES) $(OTHER_CLEAN)
    1634 pass := clean
    1635 PASS := CLEAN
    1636 $(eval $(def_pass))
    1637 clean: pass_clean
    1638 
    1639 ## PASS: nothing
    1640 # This pass just walks the tree.
    1641 pass_nothing_doit:
    1642         $(call MSG_L1,Did nothing in $(CURDIR))
    1643 pass := nothing
    1644 PASS := NOTHING
    1645 $(eval $(def_pass))
    1646 nothing: pass_nothing
    1647 
     1445else
     1446.NOTPARALLEL: pass_$(pass) pass_$(pass)_before pass_$(pass)_after
     1447.PHONY:       pass_$(pass) pass_$(pass)_before pass_$(pass)_after pass_$(pass)_doit
     1448pass_$(pass)_doit: pass_$(pass)_before \
     1449                $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var)))
     1450pass_$(pass): \
     1451                pass_$(pass)_before \
     1452                pass_$(pass)_doit \
     1453                pass_$(pass)_after
     1454endif
     1455
     1456#$ (warning pass=$(pass) PASS=$(PASS): $(PASS_$(PASS)_trgs) $(PASS_$(PASS)_trgs) $(foreach var,$(PASS_$(PASS)_vars),$($(var))))
     1457endef
     1458
     1459# Generate the defined passes.
     1460$(foreach PASS, $(PASSES), \
     1461        $(eval pass := $(PASS_$(PASS)_pass)) \
     1462        $(eval $(def_pass)))
    16481463
    16491464## Pass order
     
    16511466# @param        $(prev_pass)    The previous pass name.
    16521467define def_pass_order
     1468ifdef KBUILD_SAFE_PARALLELL
     1469.NOTPARALLEL: pass_$(pass)_order
     1470.PHONY: pass_$(pass)_order
    16531471pass_$(pass)_order: $(pass_prev)
    1654         $(call MSG_L1,Pass $(pass))
     1472        $(call MSG_L1,Pass - $(if $(PASS_$(PASS)),$(PASS_$(PASS)),$(pass)))
    16551473        + $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)
    1656 .NOTPARALLEL: pass_$(pass)_order
     1474else
     1475.NOTPARALLEL: pass_$(pass)_order pass_$(pass)_banner
     1476.PHONY: pass_$(pass)_order pass_$(pass)_banner
     1477pass_$(pass)_banner:
     1478        $(call MSG_L1,Pass - $(if $(PASS_$(PASS)),$(PASS_$(PASS)),$(pass)))
     1479pass_$(pass)_order: \
     1480                $(pass_prev) \
     1481                pass_$(pass)_banner \
     1482                pass_$(pass)
     1483endif
    16571484$(eval pass_prev := pass_$(pass)_order)
    16581485endef
     
    16611488# Use dependencies to ensure correct pass order.
    16621489pass_prev :=
    1663 $(foreach pass,$(PASSES),$(eval $(def_pass_order)))
     1490$(foreach PASS,$(DEFAULT_PASSES),\
     1491        $(eval pass := $(PASS_$(PASS)_pass)) \
     1492        $(eval $(def_pass_order)))
    16641493
    16651494
     
    16721501        + $(MAKE) -f $(firstword $(MAKEFILE_LIST)) all_recursive
    16731502
     1503uninstall:
     1504        $(RM) -f $(_INSTALLS)
    16741505
    16751506# misc shortcuts.
    1676 target:    bldprogs libraries binaries others
     1507targets:   bldprogs libraries dlls programs sysmods others install
    16771508objects:   $(_OBJS)
    16781509bldprogs:  $(_BLDPROGS)
     
    16811512programs:  $(_PROGRAMS)
    16821513sysmods:   $(_SYSMODS)
     1514others:    $(_OTHERS)
     1515install:   $(_INSTALLS)
     1516
     1517
     1518#
     1519# kBuild debugging stuff.
     1520#
     1521_SPACE := $(subst ., ,.)
     1522_TAB := $(subst .,      ,.)
     1523define _NEWLINE
     1524
     1525
     1526endef
     1527NLTAB = $(_NEWLINE)$(TAB)
     1528show_targets:
     1529        @$(foreach target, $(ALL_TARGETS),\
     1530        @$(ECHO) "target: $(target)" $(NLTAB)\
     1531        @$(ECHO) "  PATH_$(target)=$(PATH_$(target))" $(NLTAB)\
     1532        @$(ECHO) "  TARGET_$(target)=$(TARGET_$(target))" $(NLTAB)\
     1533        @$(ECHO) "  INSTARGET_$(target)=$(INSTARGET_$(target))" $(NLTAB)\
     1534$(foreach prop,$(PROPS_SINGLE) $(PROPS_ACCUMULATE) OBJS_, \
     1535        $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))) \
     1536        $(if $($(target)_$(prop).$(_tmp)),\
     1537                @$(ECHO) "  $(target)_$(prop).$(_tmp)=$($(target)_$(prop).$(_tmp))" $(NLTAB)) \
     1538        $(if $($(target)_$(prop)), $(NLTAB)@$(ECHO) "  $(target)_$(prop)=$($(target)_$(prop))" $(NLTAB)) \
     1539)\
     1540$(foreach prop,$(PROPS_DEFERRED), \
     1541        $(eval _tmp:=$(firstword $($(target)_BLD_TRG) $(BUILD_TARGET))) \
     1542        $(if $(value $(target)_$(prop).$(_tmp)),\
     1543                @$(ECHO) '  $(target)_$(prop).$(_tmp)=$(value $(TARGET)_$(prop).$(_tmp))' $(NLTAB)) \
     1544        $(if $(value $(target)_$(prop)), $(NLTAB)@$(ECHO) '  $(target)_$(prop)=$(value $(target)_$(prop))' $(NLTAB)) \
     1545))
     1546
     1547
     1548
     1549#
     1550# Include dependency files.
     1551#
     1552$(foreach dep,$(wildcard $(_DEPFILES)),$(eval include $(dep)))
    16831553
    16841554
Note: See TracChangeset for help on using the changeset viewer.