Index: trunk/kBuild/footer.kmk
===================================================================
--- trunk/kBuild/footer.kmk	(revision 1410)
+++ trunk/kBuild/footer.kmk	(revision 1413)
@@ -156,4 +156,209 @@
 
 
+
+## Inherit one keyword in a non-accumulative manner.
+# @param    $(trg)          Target object.
+# @param    $(prop)     	The property.
+# @param    $(src_key)      Source keyword.
+# @param    $(trg_key)      Target keyword.
+define def_inherit_one_keyword
+ifdef $(trg)_$(prop).$(src_key)
+ ifndef $(trg)_$(prop).$(trg_key)
+  $(trg)_$(prop).$(trg_key) = $($(trg)_$(prop).$(src_key))
+ endif
+endif
+endef
+
+
+# EXPAND_BY = overriding
+
+## Inherit one keyword in a non-accumulative manner.
+# @param    $(trg)          Target object.
+# @param    $(prop)     	The property.
+# @param    $(src_key)      Source keyword.
+# @param    $(trg_key)      Target keyword.
+define def_inherit_one_keyword_overriding_now_l
+ifdef $(trg)_$(prop).$(src_key)
+ ifndef $(trg)_$(prop).$(trg_key)
+  $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key))
+ endif
+endif
+endef
+
+## @copydoc def_inherit_one_overriding_now_l
+define def_inherit_one_keyword_overriding_now_r
+ifdef $(trg)_$(prop).$(src_key)
+ ifndef $(trg)_$(prop).$(trg_key)
+  $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key))
+ endif
+endif
+endef
+
+## Inherit one keyword in a non-accumulative manner, deferred expansion.
+# @param    $(trg)          Target object.
+# @param    $(prop)     	The property.
+# @param    $(src_key)      Source keyword.
+# @param    $(trg_key)      Target keyword.
+# @remark This define relies on double evaluation
+define def_inherit_one_keyword_overriding_deferred
+ifdef $(trg)_$(prop).$(src_key)
+ ifndef $(trg)_$(prop).$(trg_key)
+  $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
+ endif
+endif
+endef
+
+## @copydoc def_inherit_one_overriding_deferred
+define def_inherit_one_keyword_overriding_deferred_l
+ifdef $(trg)_$(prop).$(src_key)
+ ifndef $(trg)_$(prop).$(trg_key)
+  $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
+ endif
+endif
+endef
+
+## @copydoc def_inherit_one_overriding_deferred
+define def_inherit_one_keyword_overriding_deferred_r
+ifdef $(trg)_$(prop).$(src_key)
+ ifndef $(trg)_$(prop).$(trg_key)
+  $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
+ endif
+endif
+endef
+
+
+# EXPAND_BY = prepending
+
+## Inherit one keyword in a prepending manner.
+# @param    $(trg)          Target object.
+# @param    $(prop)     	The property.
+# @param    $(src_key)      Source keyword.
+# @param    $(trg_key)      Target keyword.
+define def_inherit_one_keyword_prepending_now_l
+ifdef $(trg)_$(prop).$(src_key)
+ $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key)) $($(trg)_$(prop).$(trg_key))
+endif
+endef
+
+## @copydoc def_inherit_one_prepending_now_l
+define def_inherit_one_keyword_prepending_now_r
+ifdef $(trg)_$(prop).$(src_key)
+ $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(trg_key)) $($(trg)_$(prop).$(src_key))
+endif
+endef
+
+## Inherit one keyword in a non-accumulative manner, deferred expansion.
+# @param    $(trg)          Target object.
+# @param    $(prop)     	The property.
+# @param    $(src_key)      Source keyword.
+# @param    $(trg_key)      Target keyword.
+# @remark This define relies on double evaluation
+define def_inherit_one_keyword_prepending_deferred
+ifdef $(trg)_$(prop).$(src_key)
+ ifndef $(trg)_$(prop).$(trg_key)
+  $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
+ endif
+endif
+endef
+
+## Inherit one keyword in a prepending manner, deferred expansion.
+# @param    $(trg)          Target object.
+# @param    $(prop)     	The property.
+# @param    $(src_key)      Source keyword.
+# @param    $(trg_key)      Target keyword.
+define def_inherit_one_keyword_prepending_deferred_l
+ifdef $(trg)_$(prop).$(src_key)
+ $(trg)_$(prop).$(trg_key) <= $$($(trg)_$(prop).$(src_key))
+endif
+endef
+
+## @copydoc def_inherit_one_prepending_deferred_l
+define def_inherit_one_keyword_prepending_deferred_r
+ifdef $(trg)_$(prop).$(src_key)
+  $(trg)_$(prop).$(trg_key) += $$($(trg)_$(prop).$(src_key))
+endif
+endef
+
+
+# EXPAND_BY = appending
+
+## Inherit one keyword in an appending manner.
+# @param    $(trg)          Target object.
+# @param    $(prop)     	The property.
+# @param    $(src_key)      Source keyword.
+# @param    $(trg_key)      Target keyword.
+define def_inherit_one_keyword_appending_now_l
+ifdef $(trg)_$(prop).$(src_key)
+ $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(trg_key)) $($(trg)_$(prop).$(src_key))
+endif
+endef
+
+## @copydoc def_inherit_one_appending_now_l
+define def_inherit_one_keyword_appending_now_r
+ifdef $(trg)_$(prop).$(src_key)
+ $(trg)_$(prop).$(trg_key) := $($(trg)_$(prop).$(src_key)) $($(trg)_$(prop).$(trg_key))
+endif
+endef
+
+## Inherit one keyword in a non-accumulative manner, deferred expansion.
+# @param    $(trg)          Target object.
+# @param    $(prop)     	The property.
+# @param    $(src_key)      Source keyword.
+# @param    $(trg_key)      Target keyword.
+# @remark This define relies on double evaluation
+define def_inherit_one_keyword_appending_deferred
+ifdef $(trg)_$(prop).$(src_key)
+ ifndef $(trg)_$(prop).$(trg_key)
+  $(trg)_$(prop).$(trg_key) = $$($(trg)_$(prop).$(src_key))
+ endif
+endif
+endef
+
+## Inherit one keyword in an appending manner, deferred expansion.
+# @param    $(trg)          Target object.
+# @param    $(prop)     	The property.
+# @param    $(src_key)      Source keyword.
+# @param    $(trg_key)      Target keyword.
+define def_inherit_one_keyword_appending_deferred_l
+ifdef $(trg)_$(prop).$(src_key)
+ $(trg)_$(prop).$(trg_key) += $$($(trg)_$(prop).$(src_key))
+endif
+endef
+
+## @copydoc def_inherit_one_appending_deferred_l
+define def_inherit_one_keyword_appending_deferred_r
+ifdef $(trg)_$(prop).$(src_key)
+  $(trg)_$(prop).$(trg_key) <= $$($(trg)_$(prop).$(src_key))
+endif
+endef
+
+
+## Worker fro def_inherit that deals with one keyword that makes
+# use of inheritance.
+# @param    prefix_keyword        key_prefix:keyword. The cool join/split game as usual.
+# @param    trg                   Object to consider for inheriting.
+# @param    properties            List of the properties with straight expansion.
+# @param    properties_now_l      List of the properties with immediate expansion, accumulating on the left side.
+# @param    properties_now_r      List of the properties with immediate expansion, accumulating on the right side.
+# @param    properties_deferred   List of the properties with deferred expansion (e.g. function), non-accumulative .
+# @param    properties_deferred_l List of the properties with deferred expansion (e.g. function), accumulating on the left side.
+# @param    properties_deferred_r List of the properties with deferred expansion (e.g. function), accumulating on the right side.
+define def_inherit_keyword
+prefix   := $(word 1,$(subst :, ,$(prefix_keyword)))
+trg_key  := $(word 2,$(subst :, ,$(prefix_keyword)))
+src_key  := $($(prefix)_$(trg_key)_EXTENDS)
+by       := $($(prefix)_$(trg_key)_EXTENDS_BY)
+
+# Inherit the properties.
+$(foreach prop, $(properties),            $(eval $(def_inherit_one_keyword)))
+$(foreach prop, $(properties_now_l),      $(eval $(def_inherit_one_keyword_$(by)_now_l)))
+$(foreach prop, $(properties_now_r),      $(eval $(def_inherit_one_keyword_$(by)_now_r)))
+$(foreach prop, $(properties_deferred),   $(eval $(def_inherit_one_keyword_$(by)_deferred)))
+$(foreach prop, $(properties_deferred_l), $(eval $(def_inherit_one_keyword_$(by)_deferred_l)))
+$(foreach prop, $(properties_deferred_r), $(eval $(def_inherit_one_keyword_$(by)_deferred_r)))
+
+endef # def_inherit_keyword
+
+
 ## Inherit one template property in a non-accumulative manner.
 # @param    $(prop)         Property name
@@ -164,8 +369,7 @@
  ifndef $(trg)_$(prop)
   $(trg)_$(prop) = $($(src)_$(prop))
-  #$ (warning def_inherit_one: $(trg)_$(prop) = $($(src)_$(prop)) )
  endif
 endif
-endef # def_inherit_one
+endef
 
 
@@ -180,8 +384,7 @@
  ifndef $(trg)_$(prop)
   $(trg)_$(prop) := $($(src)_$(prop))
-  #$ (warning def_inherit_one_overriding_now_l: $(trg)_$(prop) = $($(src)_$(prop)) )
  endif
 endif
-endef # def_inherit_one_overriding_now_l
+endef
 
 ## @copydoc def_inherit_one_overriding_now_l
@@ -190,8 +393,7 @@
  ifndef $(trg)_$(prop)
   $(trg)_$(prop) := $($(src)_$(prop))
-  #$ (warning def_inherit_one_overriding_now_r: $(trg)_$(prop) = $($(src)_$(prop)) )
  endif
 endif
-endef # def_inherit_one_overriding_now_r
+endef
 
 ## Inherit one template property in a non-accumulative manner, deferred expansion.
@@ -204,8 +406,7 @@
  ifndef $(trg)_$(prop)
   $(trg)_$(prop) = $$($(src)_$(prop))
-  #$ (warning def_inherit_one_overriding_deferred: $(trg)_$(prop) = $($(src)_$(prop)) )
  endif
 endif
-endef # def_inherit_one_overriding_deferred
+endef
 
 ## @copydoc def_inherit_one_overriding_deferred
@@ -214,8 +415,7 @@
  ifndef $(trg)_$(prop)
   $(trg)_$(prop) = $$($(src)_$(prop))
-  #$ (warning def_inherit_one_overriding_deferred_l: $(trg)_$(prop) = $($(src)_$(prop)) )
  endif
 endif
-endef # def_inherit_one_overriding_deferred_l
+endef
 
 ## @copydoc def_inherit_one_overriding_deferred
@@ -224,8 +424,7 @@
  ifndef $(trg)_$(prop)
   $(trg)_$(prop) = $$($(src)_$(prop))
-  #$ (warning def_inherit_one_overriding_deferred_r: $(trg)_$(prop) = $($(src)_$(prop)) )
  endif
 endif
-endef # def_inherit_one_overriding_deferred_r
+endef
 
 
@@ -238,16 +437,14 @@
 define def_inherit_one_prepending_now_l
 ifdef $(src)_$(prop)
- $(trg)_$(prop) := $(trg)_$(prop) $($(src)_$(prop))
- #$ (warning def_inherit_one_prepending_now_l: $(trg)_$(prop) = $($(trg)_$(prop)) )
-endif
-endef # def_inherit_one_prepending_now_l
+ $(trg)_$(prop) := $($(src)_$(prop)) $($(trg)_$(prop))
+endif
+endef
 
 ## @copydoc def_inherit_one_prepending_now_l
 define def_inherit_one_prepending_now_r
 ifdef $(src)_$(prop)
- $(trg)_$(prop) := $($(src)_$(prop)) $(trg)_$(prop)
- #$ (warning def_inherit_one_prepending_now_r: $(trg)_$(prop) = $($(trg)_$(prop)) )
-endif
-endef # def_inherit_one_prepending_now_r
+ $(trg)_$(prop) := $($(trg)_$(prop)) $($(src)_$(prop))
+endif
+endef
 
 ## Inherit one template property in a non-accumulative manner, deferred expansion.
@@ -260,8 +457,7 @@
  ifndef $(trg)_$(prop)
   $(trg)_$(prop) = $$($(src)_$(prop))
-  #$ (warning def_inherit_one_prepending_deferred: $(trg)_$(prop) = $($(src)_$(prop)) )
  endif
 endif
-endef # def_inherit_one_prepending_deferred
+endef
 
 ## Inherit one template property in a prepending manner, deferred expansion.
@@ -272,7 +468,6 @@
 ifdef $(src)_$(prop)
  $(trg)_$(prop) <= $$($(src)_$(prop))
- #$ (warning def_inherit_one_prepending_deferred_l: $(trg)_$(prop) = $($(trg)_$(prop)) )
-endif
-endef # def_inherit_one_prepending_deferred_l
+endif
+endef
 
 ## @copydoc def_inherit_one_prepending_deferred_l
@@ -280,12 +475,11 @@
 ifdef $(src)_$(prop)
   $(trg)_$(prop) += $$($(src)_$(prop))
-  #$ (warning def_inherit_one_prepending_deferred_r: $(trg)_$(prop) = $($(trg)_$(prop)) )
-endif
-endef # def_inherit_one_prepending_deferred_r
+endif
+endef
 
 
 # EXPAND_BY = appending
 
-## Inherit one template property in a appending manner.
+## Inherit one template property in an appending manner.
 # @param    $(prop)         Property name
 # @param    $(src)          Source (parent) object.
@@ -293,16 +487,14 @@
 define def_inherit_one_appending_now_l
 ifdef $(src)_$(prop)
- $(trg)_$(prop) := $($(src)_$(prop)) $(trg)_$(prop)
- #$ (warning def_inherit_one_appending_now_l: $(trg)_$(prop) = $($(trg)_$(prop)) )
-endif
-endef # def_inherit_one_appending_now_l
+ $(trg)_$(prop) := $($(trg)_$(prop)) $($(src)_$(prop))
+endif
+endef
 
 ## @copydoc def_inherit_one_appending_now_l
 define def_inherit_one_appending_now_r
 ifdef $(src)_$(prop)
- $(trg)_$(prop) := $(trg)_$(prop) $($(src)_$(prop))
- #$ (warning def_inherit_one_appending_now_r: $(trg)_$(prop) = $($(trg)_$(prop)) )
-endif
-endef # def_inherit_one_appending_now_r
+ $(trg)_$(prop) := $($(src)_$(prop)) $($(trg)_$(prop))
+endif
+endef
 
 ## Inherit one template property in a non-accumulative manner, deferred expansion.
@@ -315,10 +507,9 @@
  ifndef $(trg)_$(prop)
   $(trg)_$(prop) = $$($(src)_$(prop))
-  #$ (warning def_inherit_one_appending_deferred: $(trg)_$(prop) = $($(src)_$(prop)) )
  endif
 endif
-endef # def_inherit_one_appending_deferred
-
-## Inherit one template property in a appending manner, deferred expansion.
+endef
+
+## Inherit one template property in an appending manner, deferred expansion.
 # @param    $(prop)         Property name
 # @param    $(src)          Source (parent) object.
@@ -327,7 +518,6 @@
 ifdef $(src)_$(prop)
  $(trg)_$(prop) += $$($(src)_$(prop))
- #$ (warning def_inherit_one_appending_deferred_l: $(trg)_$(prop) = $($(trg)_$(prop)) )
-endif
-endef # def_inherit_one_appending_deferred_l
+endif
+endef
 
 ## @copydoc def_inherit_one_appending_deferred_l
@@ -335,8 +525,10 @@
 ifdef $(src)_$(prop)
   $(trg)_$(prop) <= $$($(src)_$(prop))
-  #$ (warning def_inherit_one_appending_deferred_r: $(trg)_$(prop) = $($(trg)_$(prop)) )
-endif
-endef # def_inherit_one_appending_deferred_r
-
+endif
+endef
+
+
+## combines the specified properties $(1) with the $(_KEYWORDS) list.
+_INHERIT_JOIN_KEYWORDS = $(1)  $(foreach keyword,$(_KEYWORDS), $(addsuffix .$(keyword), $(1)))
 
 
@@ -377,11 +569,10 @@
 
   # Inherit the properties.
-  #$ (warning def_inherit: trg=$(trg) src=$(src))
-  $(foreach prop, $(properties),            $(eval $(def_inherit_one)))
-  $(foreach prop, $(properties_now_l),      $(eval $(def_inherit_one_$(by)_now_l)))
-  $(foreach prop, $(properties_now_r),      $(eval $(def_inherit_one_$(by)_now_r)))
-  $(foreach prop, $(properties_deferred),   $(eval $(def_inherit_one_$(by)_deferred)))
-  $(foreach prop, $(properties_deferred_l), $(eval $(def_inherit_one_$(by)_deferred_l)))
-  $(foreach prop, $(properties_deferred_r), $(eval $(def_inherit_one_$(by)_deferred_r)))
+  $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties)),            $(eval $(def_inherit_one)))
+  $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_now_l)),      $(eval $(def_inherit_one_$(by)_now_l)))
+  $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_now_r)),      $(eval $(def_inherit_one_$(by)_now_r)))
+  $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_deferred)),   $(eval $(def_inherit_one_$(by)_deferred)))
+  $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_deferred_l)), $(eval $(def_inherit_one_$(by)_deferred_l)))
+  $(foreach prop, $(call _INHERIT_JOIN_KEYWORDS,$(properties_deferred_r)), $(eval $(def_inherit_one_$(by)_deferred_r)))
 
   # Mark the target as done.
@@ -394,28 +585,9 @@
  endif
 endif
+
+# Keyword inheritance.
+$(foreach prefix_keyword, $(join $(_KEYWORDS_PREFIX), $(addprefix :,$(_KEYWORDS_EXTENDS))), $(eval $(value def_inherit_keyword)))
+
 endef # def_inherit
-
-
-##
-# Function for $(call)'ing.
-# @param    1   trg                   Object to consider for inheriting.
-# @param    2   src_prefix            What to prefix the value found in EXTENDS with to get the object.
-# @param    3   properties            List of the properties with straight expansion.
-# @param    4   properties_now_l      List of the properties with immediate expansion, accumulating on the left side.
-# @param    5   properties_now_r      List of the properties with immediate expansion, accumulating on the right side.
-# @param    6   properties_deferred   List of the properties with deferred expansion (e.g. function), non-accumulative .
-# @param    7   properties_deferred_l List of the properties with deferred expansion (e.g. function), accumulating on the left side.
-# @param    8   properties_deferred_r List of the properties with deferred expansion (e.g. function), accumulating on the right side.
-define fn_inherit
-src_prefix := $(2)
-properties := $(3)
-properties_now_l := $(4)
-properties_now_r := $(5)
-properties_deferred := $(6)
-properties_deferred_l := $(7)
-properties_deferred_r := $(8)
-$(foreach trg, $(1),$(eval $(value def_inherit)))
-endef
-
 
 
@@ -493,4 +665,5 @@
 
 # Drop duplicate values.
+# WARNING! These list might not include keywords only involved in inheritance.
 _BLD_TYPES   := $(sort $(_BLD_TYPES))
 _BLD_TARGETS := $(sort $(_BLD_TARGETS))
@@ -498,41 +671,28 @@
 _BLD_CPUS    := $(sort $(_BLD_CPUS))
 
-# Construct all the possible keywords.
-_KEYWORDS := $(_BLD_TYPES) $(_BLD_TARGETS) $(_BLD_ARCHES) $(_BLD_CPUS) \
-	$(foreach bld_trg,$(_BLD_TARGETS),$(addprefix $(bld_trg).,$(_BLD_ARCHES)))
-
-# Look for keywords which extends others and order them.
-_KEYWORDS_ORDERED :=
+## Look for keywords which extends others and order them.
+# @param    keyword
+# @param    prefix
+# @param    valid
 define def_keyword_ordering
+# Check for EXTENDS, fix and validate it if found.
 src := $(strip $($(prefix)_$(keyword)_EXTENDS))
 ifneq ($(src),)
  ifndef $(prefix)_$(keyword)_EXTENDS_STATUS_
-  $(prefix)_$(keyword)_EXTENDS_STATUS_ := 0
-
-  # Validate src.
   ifn1of ($(src), $(valid))
    $(error kBuild: $(keyword) tries to extend unknown keyword '$(src)'! (known = $(valid)))
   endif
 
-  # Recursivly process the parent (src) if it's inherting from somebody too.
-  # If it isn't, then we'll have to add it to the ordered keyword list here.
+  # Recursivly process the parent (src).
   ifneq ($($(prefix)_$(src)_EXTENDS_STATUS_),42)
-   ifneq ($($(prefix)_$(src)_EXTENDS_STATUS_),)
-    $(error kBuild: Keyword inheritance loop! keyword=$(src) $(prefix)_$(src)_EXTENDS_STATUS_=$($(prefix)_$(src)_EXTENDS_STATUS_))
-   endif
-   ifdef $(prefix)_$(src)_EXTENDS
-    # 'foreach' will create 'keyword' in a new variable context hiding
-	# out current variable. 'src' OTOH will be overwritten.
-    $(foreach keyword, $(src), $(eval $(value def_keyword_ordering)))
-    src := $(strip $($(keyword)_EXTENDS))
-   else
-    # Add it to the list and mark it as done.
-    _KEYWORDS_ORDERED += $(src)
-    $(prefix)_$(src)_EXTENDS_STATUS_ := 42
-   endif
+   $(prefix)_$(keyword)_EXTENDS_STATUS_ := 0
+   # 'foreach' will create 'keyword' in a new variable context hiding
+   # out current variable. 'src' OTOH will be overwritten.
+   $(foreach keyword, $(src), $(eval $(value def_keyword_ordering)))
+   src := $(strip $($(prefix)_$(keyword)_EXTENDS))
   endif
 
-  # Check EXTENDS_BY.
-  by = $(strip $($(trg)_EXTENDS_BY))
+  # Check and strip EXTENDS_BY.
+  by = $(strip $($(prefix)_$(keyword)_EXTENDS_BY))
   ifeq ($(by),)
    by = overriding
@@ -541,6 +701,11 @@
   endif
 
+  # Update the attributes with stripped
+  $(prefix)_$(keyword)_EXTENDS_BY := $(by)
+  $(prefix)_$(keyword)_EXTENDS := $(src)
+
   # Add it to the list and mark it as done.
-  _KEYWORDS_ORDERED += $(keyword)
+  _KEYWORDS_EXTENDS += $(keyword)
+  _KEYWORDS_PREFIX  += $(prefix)
   $(prefix)_$(keyword)_EXTENDS_STATUS_ := 42
  else
@@ -550,22 +715,38 @@
   endif
  endif
-endif
-
-endef
+else
+ # Add it to the ordered list and mark it as done.
+ _KEYWORDS_ORDERED += $(keyword)
+ $(prefix)_$(src)_EXTENDS_STATUS_ := 42
+endif
+endef # def_keyword_ordering
+
+# Look for keywords which extends others and their parents, and from this
+# construct two lists.
+_KEYWORDS_ORDERED :=
+_KEYWORDS_EXTENDS :=
+_KEYWORDS_PREFIX  :=
 
 prefix := BLD_TYPE
 valid := $(KBUILD_BLD_TYPES)
-$(foreach keyword, $(_BLD_TYPES) , $(eval $(value def_keyword_ordering)))
+$(foreach keyword, $(_BLD_TYPES)  , $(eval $(value def_keyword_ordering)))
+
+prefix := BLD_TRG
+valid := $(KBUILD_OSES)
+$(foreach keyword, $(_BLD_TARGETS), $(eval $(value def_keyword_ordering)))
 
 prefix := BLD_ARCH
 valid := $(KBUILD_ARCHES)
-$(foreach keyword, $(_BLD_ARCHES), $(eval $(value def_keyword_ordering)))
+$(foreach keyword, $(_BLD_ARCHES) , $(eval $(value def_keyword_ordering)))
 
 prefix := BLD_CPU
 valid := $(KBUILD_CPUS)
-$(foreach keyword, $(_BLD_CPUS)  , $(eval $(value def_keyword_ordering)))
-
-# Update _KEYWORDS to the ordered list making sure parent keywords are included too.
-_KEYWORDS := $(_KEYWORDS_ORDERED) $(filter-out $(_KEYWORDS_ORDERED), $(_KEYWORDS))
+$(foreach keyword, $(_BLD_CPUS)   , $(eval $(value def_keyword_ordering)))
+
+## @todo Inherit bld_trg.bld_arch for too?
+
+# Construct all the possible keywords.
+_KEYWORDS := $(_KEYWORDS_ORDERED) $(_KEYWORDS_EXTENDS) \
+	$(foreach bld_trg,$(_BLD_TARGETS),$(addprefix $(bld_trg).,$(_BLD_ARCHES)))
 
 ifdef KBUILD_PROFILE_SELF
@@ -591,33 +772,30 @@
 properties_deferred_r :=
 
-## combines the specified properties $(1) with the $(_KEYWORDS).
-_COMB_KEY_PROP = $(1)  $(foreach keyword,$(_KEYWORDS), $(addsuffix .$(keyword), $(1)))
-
 # Fetches.
-properties          := $(call _COMB_KEY_PROP,$(PROPS_FETCHES_SINGLE))
-properties_now_l    := $(call _COMB_KEY_PROP,$(PROPS_FETCHES_ACCUMULATE_L))
-properties_now_r    := $(call _COMB_KEY_PROP,$(PROPS_FETCHES_ACCUMULATE_R))
-properties_deferred := $(call _COMB_KEY_PROP,$(PROPS_FETCHES_DEFERRED))
+properties          := $(PROPS_FETCHES_SINGLE)
+properties_now_l    := $(PROPS_FETCHES_ACCUMULATE_L)
+properties_now_r    := $(PROPS_FETCHES_ACCUMULATE_R)
+properties_deferred := $(PROPS_FETCHES_DEFERRED)
 $(foreach trg, $(_ALL_FETCHES),$(eval $(value def_inherit)))
 
 ## Patches. - not implemented yet.
-#properties          := $(call _COMB_KEY_PROP,$(PROPS_PATCHES_SINGLE))
-#properties_now_l    := $(call _COMB_KEY_PROP,$(PROPS_PATCHES_ACCUMULATE_L))
-#properties_now_r    := $(call _COMB_KEY_PROP,$(PROPS_PATCHES_ACCUMULATE_R))
-#properties_deferred := $(call _COMB_KEY_PROP,$(PROPS_PATCHES_DEFERRED))
+#properties          := $(PROPS_PATCHES_SINGLE)
+#properties_now_l    := $(PROPS_PATCHES_ACCUMULATE_L)
+#properties_now_r    := $(PROPS_PATCHES_ACCUMULATE_R)
+#properties_deferred := $(PROPS_PATCHES_DEFERRED)
 #$(foreach trg, $(_ALL_PATCHES),$(eval $(value def_inherit)))
 
 # Programs and build programs.
-properties          := $(call _COMB_KEY_PROP,$(PROPS_PROGRAMS_SINGLE))
-properties_now_l    := $(call _COMB_KEY_PROP,$(PROPS_PROGRAMS_ACCUMULATE_L))
-properties_now_r    := $(call _COMB_KEY_PROP,$(PROPS_PROGRAMS_ACCUMULATE_R))
-properties_deferred := $(call _COMB_KEY_PROP,$(PROPS_PROGRAMS_DEFERRED))
+properties          := $(PROPS_PROGRAMS_SINGLE)
+properties_now_l    := $(PROPS_PROGRAMS_ACCUMULATE_L)
+properties_now_r    := $(PROPS_PROGRAMS_ACCUMULATE_R)
+properties_deferred := $(PROPS_PROGRAMS_DEFERRED)
 $(foreach trg, $(_ALL_BLDPROGS) $(_ALL_PROGRAMS),$(eval $(value def_inherit)))
 
 # Libraries and import libraries.
-properties          := $(call _COMB_KEY_PROP,$(PROPS_LIBRARIES_SINGLE))
-properties_now_l    := $(call _COMB_KEY_PROP,$(PROPS_LIBRARIES_ACCUMULATE_L))
-properties_now_r    := $(call _COMB_KEY_PROP,$(PROPS_LIBRARIES_ACCUMULATE_R))
-properties_deferred := $(call _COMB_KEY_PROP,$(PROPS_LIBRARIES_DEFERRED))
+properties          := $(PROPS_LIBRARIES_SINGLE)
+properties_now_l    := $(PROPS_LIBRARIES_ACCUMULATE_L)
+properties_now_r    := $(PROPS_LIBRARIES_ACCUMULATE_R)
+properties_deferred := $(PROPS_LIBRARIES_DEFERRED)
 if1of ($(BUILD_TARGET), nt os2 win)
  $(foreach trg, $(_ALL_LIBRARIES) $(_ALL_IMPORT_LIBS),$(eval $(value def_inherit)))
@@ -627,8 +805,8 @@
 
 # DLLs.
-properties          := $(call _COMB_KEY_PROP,$(PROPS_DLLS_SINGLE))
-properties_now_l    := $(call _COMB_KEY_PROP,$(PROPS_DLLS_ACCUMULATE_L))
-properties_now_r    := $(call _COMB_KEY_PROP,$(PROPS_DLLS_ACCUMULATE_R))
-properties_deferred := $(call _COMB_KEY_PROP,$(PROPS_DLLS_DEFERRED))
+properties          := $(PROPS_DLLS_SINGLE)
+properties_now_l    := $(PROPS_DLLS_ACCUMULATE_L)
+properties_now_r    := $(PROPS_DLLS_ACCUMULATE_R)
+properties_deferred := $(PROPS_DLLS_DEFERRED)
 if1of ($(BUILD_TARGET), nt os2 win)
  $(foreach trg, $(_ALL_DLLS),$(eval $(value def_inherit)))
@@ -638,15 +816,15 @@
 
 # System modules.
-properties          := $(call _COMB_KEY_PROP,$(PROPS_SYSMODS_SINGLE))
-properties_now_l    := $(call _COMB_KEY_PROP,$(PROPS_SYSMODS_ACCUMULATE_L))
-properties_now_r    := $(call _COMB_KEY_PROP,$(PROPS_SYSMODS_ACCUMULATE_R))
-properties_deferred := $(call _COMB_KEY_PROP,$(PROPS_SYSMODS_DEFERRED))
+properties          := $(PROPS_SYSMODS_SINGLE)
+properties_now_l    := $(PROPS_SYSMODS_ACCUMULATE_L)
+properties_now_r    := $(PROPS_SYSMODS_ACCUMULATE_R)
+properties_deferred := $(PROPS_SYSMODS_DEFERRED)
 $(foreach trg, $(_ALL_SYSMODS),$(eval $(value def_inherit)))
 
 # Installs.
-properties          := $(call _COMB_KEY_PROP,$(PROPS_INSTALLS_SINGLE))
-properties_now_l    := $(call _COMB_KEY_PROP,$(PROPS_INSTALLS_ACCUMULATE_L))
-properties_now_r    := $(call _COMB_KEY_PROP,$(PROPS_INSTALLS_ACCUMULATE_R))
-properties_deferred := $(call _COMB_KEY_PROP,$(PROPS_INSTALLS_DEFERRED))
+properties          := $(PROPS_INSTALLS_SINGLE)
+properties_now_l    := $(PROPS_INSTALLS_ACCUMULATE_L)
+properties_now_r    := $(PROPS_INSTALLS_ACCUMULATE_R)
+properties_deferred := $(PROPS_INSTALLS_DEFERRED)
 $(foreach trg, $(_ALL_INSTALLS),$(eval $(value def_inherit)))
 
@@ -673,7 +851,7 @@
 properties_now_l :=
 properties_now_r :=
-properties_deferred   := $(call _COMB_KEY_PROP,$(PROPS_SINGLE) $(PROPS_DEFERRED))
-properties_deferred_l := $(call _COMB_KEY_PROP,$(PROPS_ACCUMULATE_L))
-properties_deferred_r := $(call _COMB_KEY_PROP,$(PROPS_ACCUMULATE_R))
+properties_deferred   := $(PROPS_SINGLE) $(PROPS_DEFERRED)
+properties_deferred_l := $(PROPS_ACCUMULATE_L)
+properties_deferred_r := $(PROPS_ACCUMULATE_R)
 $(foreach trg, $(addprefix TEMPLATE_,$(_TEMPLATES)),$(eval $(value def_inherit)))
 
@@ -878,5 +1056,5 @@
 ifdef KBUILD_PROFILE_SELF
  _KBUILD_TS_NOW := $(nanots )
- $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done common inheritance)
+ $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - done template/target expansion)
  _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
 endif
