Index: /trunk/kBuild/Examples/Library/Makefile
===================================================================
--- /trunk/kBuild/Examples/Library/Makefile	(revision 77)
+++ /trunk/kBuild/Examples/Library/Makefile	(revision 78)
@@ -6,8 +6,7 @@
 
 
-TEMPLATE			:= mylib								
+TEMPLATE			:= mylib
 LIBRARIES           := libHello
 libHello_SOURCES    := hello.c
-libHello_TEMPLATE   := mylib
 
 DEPTH = ../../..
Index: /trunk/kBuild/Examples/Library/config.kmk
===================================================================
--- /trunk/kBuild/Examples/Library/config.kmk	(revision 77)
+++ /trunk/kBuild/Examples/Library/config.kmk	(revision 78)
@@ -1,3 +1,2 @@
-
 # define template mylib
 TEMPLATE_mylib := Sample template for testing kBuild
Index: /trunk/kBuild/footer.kmk
===================================================================
--- /trunk/kBuild/footer.kmk	(revision 77)
+++ /trunk/kBuild/footer.kmk	(revision 78)
@@ -65,5 +65,11 @@
 # @param    $1      source file
 # @param    $2      normalized main target
-_SOURCE_TOOL = $(firstword $($1_$2_TOOL) $($1_TOOL) $($2_TOOL) $(TOOL))
+# @param    $3      tooltype
+_SOURCE_TOOL = $(strip $(firstword $($1_$2_$(3)TOOL) $($1_$2_TOOL) $($1_$(3)TOOL) $($1_TOOL) $($2_$(3)TOOL) $($2_TOOL) $($(3)TOOL) $(TOOL) ))
+
+## Figure out the tool for a target.
+# @param    $1 		normalized target.
+# @param    $2      tooltype.
+_TARGET_TOOL = $(strip $(firstword $($(1)_$(2)TOOL) $($(1)_TOOL) $($(2)TOOL) $(TOOL) ))
 
 ## Figure out where to put object files.
@@ -118,14 +124,15 @@
 # is inherited from the default properties.
 # @param    $(target)	Target name
+#
 define def_inherit_defaults
 ifdef $(target)_TEMPLATE
 ifndef TEMPLATE_$($(target)_TEMPLATE)_TOOL
-$(foreach prop, TOOL, $(eval $(def_inherit_defaults_one)))
+$(foreach prop,TOOL, $(eval $(def_inherit_defaults_one)))
 endif
 ifndef TEMPLATE_$($(target)_TEMPLATE)_SDKS
-$(foreach prop, SDKS, $(eval $(def_inherit_defaults_one)))
+$(foreach prop,SDKS, $(eval $(def_inherit_defaults_one)))
 endif
 else
-$(foreach prop, TEMPLATE TOOL SDKS, $(eval $(def_inherit_defaults_one)))
+$(foreach prop,TEMPLATE TOOL SDKS,$(eval $(def_inherit_defaults_one)))
 endif
 endef
@@ -133,14 +140,25 @@
 $(foreach target, $(ALL_TARGETS), $(eval $(def_inherit_defaults)))
 
+
+## Inherit one template property in a accumulative manner.
+# @param    $(prop)     Property name
+# @param    $(target)	Target name
+# @todo fix the precedence order for some properties.
+define def_inherit_template_one
+ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
+ifndef $(target)_$(prop)
+$(eval $(target)_$(prop) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
+endif
+endif
+endef
 
 ## Inherit one template property.		
 # @param    $(prop)     Property name
 # @param    $(target)	Target name
-define def_inherit_template_one
-ifndef $(target)_$(prop)
+define def_inherit_template_one_accumulate
 ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
-$(target)_$(prop) := $(TEMPLATE_$($(target)_TEMPLATE)_$(prop))
-endif
-endif
+$(eval $(target)_$(prop) := $($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
+endif
+#$ (warning 1b $(target)_$(prop)=$($(target)_$(prop)) org=$(origin $(target)_$(prop))  TEMPLATE_$($(target)_TEMPLATE)_$(prop)=$(TEMPLATE_$($(target)_TEMPLATE)_$(prop)) org=$(origin TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
 endef
 
@@ -148,6 +166,8 @@
 # @param    $(target)    Target name.
 define def_inherit_template
-$(foreach prop,TOOL SDKS DEFS INCS COPTS CFLAGS CDEFS CINCS CXXOPTS CXXFLAGS CXXDEFS CXXINCS ASOPTS ASFLAGS ASDEFS ASINCS, \
-	$(eval $(def_inherit_template_one)))
+$(foreach prop,TOOL ARTOOL CTOOL CXXTOOL ASTOOL\
+	,$(eval $(def_inherit_template_one)))
+$(foreach prop,SDKS DEFS INCS COPTS CFLAGS CDEFS CINCS CXXOPTS CXXFLAGS CXXDEFS CXXINCS ASOPTS ASFLAGS ASDEFS ASINCS\
+	,$(eval $(def_inherit_template_one_accumulate)))
 endef
 # Inherit template properties
@@ -161,16 +181,26 @@
 _TOOLS := $(TOOL)
 define def_tools_target_source
-#$ (warning dbg: src=$(source))
-$(foreach tool,$($(source)_TOOL) $($(target)_$(source)_TOOL),\
-	$(eval _TOOLS += $(tool)))
+$(foreach tool,\
+	$($(source)_TOOL) $($(target)_$(source)_TOOL)\
+	$($(source)_CTOOL) $($(target)_$(source)_CTOOL)\
+	$($(source)_CXXTOOL) $($(target)_$(source)_CXXTOOL)\
+	$($(source)_ASTOOL) $($(target)_$(source)_ASTOOL)\
+	$($(source)_ARTOOL) $($(target)_$(source)_ARTOOL)\
+	$($(source)_LDTOOL) $($(target)_$(source)_LDTOOL)\
+	,$(eval _TOOLS += $(tool)))
 endef
 define def_tools_target
-#$ (warning dbg: trg=$(target))
-$(foreach tool, $($(target)_TOOL), $(eval _TOOLS += $(tool)))
+$(foreach tool,\
+	$($(target)_TOOL)\
+	$($(target)_CTOOL)\
+	$($(target)_CXXTOOL)\
+	$($(target)_ASTOOL)\
+	$($(target)_ARTOOL)\
+	$($(target)_LDTOOL)\
+	, $(eval _TOOLS += $(tool)))
 $(foreach source, $($(target)_SOURCES), $(eval $(def_tools_target_source)))
 endef
 $(foreach target, $(ALL_TARGETS), $(eval $(def_tools_target)))
 _TOOLS := $(sort $(_TOOLS))
-#$ (warning dbg: _TOOLS=$(_TOOLS))
 
 define def_tools_include
@@ -196,5 +226,4 @@
 $(foreach target, $(ALL_TARGETS), $(eval $(def_sdks_target)))
 _SDKS := $(sort $(_SDKS))
-#$ (warning dbg: _SDKS=$(_SDKS))
 
 define def_sdks_include
@@ -218,51 +247,196 @@
 #$ (warning dbg: def_target_source_c_cpp_asm: source=$(source) target=$(target) type=$(type))
 
-$(eval tool:=$(call _SOURCE_TOOL,$(source),$(target)))
+$(eval tool:=$(call _SOURCE_TOOL,$(source),$(target),$(type)))
 $(eval defs        :=\
+	$(TOOL_$(tool)_DEFS)\
+	$(TOOL_$(tool)_DEFS.$(BUILD_TYPE))\
+	$(TOOL_$(tool)_DEFS.$(BUILD_TARGET))\
+	$(TOOL_$(tool)_DEFS.$(BUILD_TARGET_ARCH))\
+	$(TOOL_$(tool)_DEFS.$(BUILD_TARGET_CPU))\
 	$(TOOL_$(tool)_$(type)DEFS)\
 	$(TOOL_$(tool)_$(type)DEFS.$(BUILD_TYPE))\
+	$(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
+				   $(SDKS.$(BUILD_TYPE)) \
+				   $(SDKS),\
+	$(SDK_$(sdk)_DEFS)\
+	$(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
+	$(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
+	$(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
+	$(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))
+	$(SDK_$(sdk)_$(type)DEFS)\
+	$(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
+	$(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
+	$(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
+	$(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
 	$(DEFS)\
 	$(DEFS.$(BUILD_TYPE))\
+	$(DEFS.$(BUILD_TARGET))\
+	$(DEFS.$(BUILD_TARGET_ARCH))\
+	$(DEFS.$(BUILD_TARGET_CPU))\
+	$($(type)DEFS)\
+	$($(type)DEFS.$(BUILD_TYPE))\
+	$($(type)DEFS.$(BUILD_TARGET))\
+	$($(type)DEFS.$(BUILD_TARGET_ARCH))\
+	$($(type)DEFS.$(BUILD_TARGET_CPU))\
+	$(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
+				   $($(target)_SDKS.$(BUILD_TYPE)) \
+				   $($(target)_SDKS),\
+	$(SDK_$(sdk)_DEFS)\
+	$(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
+	$(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
+	$(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
+	$(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))
+	$(SDK_$(sdk)_$(type)DEFS)\
+	$(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
+	$(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
+	$(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
+	$(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
 	$($(target)_DEFS)\
 	$($(target)_DEFS.$(BUILD_TYPE))\
 	$($(target)_DEFS.$(BUILD_TARGET))\
+	$($(target)_DEFS.$(BUILD_TARGET_ARCH))\
+	$($(target)_DEFS.$(BUILD_TARGET_CPU))\
+	$($(target)_$(type)DEFS)\
+	$($(target)_$(type)DEFS.$(BUILD_TYPE))\
+	$($(target)_$(type)DEFS.$(BUILD_TARGET))\
+	$($(target)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
+	$($(target)_$(type)DEFS.$(BUILD_TARGET_CPU))\
+	$(foreach sdk, $($(source)_SDKS.$(BUILD_TARGET)) \
+				   $($(source)_SDKS.$(BUILD_TYPE)) \
+				   $($(source)_SDKS),\
+	$(SDK_$(sdk)_DEFS)\
+	$(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
+	$(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
+	$(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
+	$(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))
+	$(SDK_$(sdk)_$(type)DEFS)\
+	$(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
+	$(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
+	$(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
+	$(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
 	$($(source)_DEFS)\
 	$($(source)_DEFS.$(BUILD_TYPE))\
 	$($(source)_DEFS.$(BUILD_TARGET))\
+	$($(source)_DEFS.$(BUILD_TARGET_ARCH))\
+	$($(source)_DEFS.$(BUILD_TARGET_CPU))\
 	$($(source)_$(type)DEFS)\
 	$($(source)_$(type)DEFS.$(BUILD_TYPE))\
 	$($(source)_$(type)DEFS.$(BUILD_TARGET))\
-	$($(target)_$(type)DEFS)\
-	$($(target)_$(type)DEFS.$(BUILD_TYPE))\
-	$($(target)_$(type)DEFS.$(BUILD_TARGET))\
+	$($(source)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
+	$($(source)_$(type)DEFS.$(BUILD_TARGET_CPU))\
+	$(foreach sdk, $($(target)_$(source)_SDKS.$(BUILD_TARGET)) \
+				   $($(target)_$(source)_SDKS.$(BUILD_TYPE)) \
+				   $($(target)_$(source)_SDKS),\
+	$(SDK_$(sdk)_DEFS)\
+	$(SDK_$(sdk)_DEFS.$(BUILD_TYPE))\
+	$(SDK_$(sdk)_DEFS.$(BUILD_TARGET))\
+	$(SDK_$(sdk)_DEFS.$(BUILD_TARGET_ARCH))\
+	$(SDK_$(sdk)_DEFS.$(BUILD_TARGET_CPU))
+	$(SDK_$(sdk)_$(type)DEFS)\
+	$(SDK_$(sdk)_$(type)DEFS.$(BUILD_TYPE))\
+	$(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET))\
+	$(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
+	$(SDK_$(sdk)_$(type)DEFS.$(BUILD_TARGET_CPU)))\
 	$($(target)_$(source)_DEFS)\
 	$($(target)_$(source)_DEFS.$(BUILD_TYPE))\
 	$($(target)_$(source)_DEFS.$(BUILD_TARGET))\
+	$($(target)_$(source)_DEFS.$(BUILD_TARGET_ARCH))\
+	$($(target)_$(source)_DEFS.$(BUILD_TARGET_CPU))\
 	$($(target)_$(source)_$(type)DEFS)\
 	$($(target)_$(source)_$(type)DEFS.$(BUILD_TYPE))\
 	$($(target)_$(source)_$(type)DEFS.$(BUILD_TARGET))\
+	$($(target)_$(source)_$(type)DEFS.$(BUILD_TARGET_ARCH))\
+	$($(target)_$(source)_$(type)DEFS.$(BUILD_TARGET_CPU))\
 	)
 $(eval incs        :=\
+	$($(target)_$(source)_$(type)INCS.$(BUILD_TARGET_CPU))\
+	$($(target)_$(source)_$(type)INCS.$(BUILD_TARGET_ARCH))\
 	$($(target)_$(source)_$(type)INCS.$(BUILD_TARGET))\
 	$($(target)_$(source)_$(type)INCS.$(BUILD_TYPE))\
 	$($(target)_$(source)_$(type)INCS)\
+	$($(target)_$(source)_INCS.$(BUILD_TARGET_CPU))\
+	$($(target)_$(source)_INCS.$(BUILD_TARGET_ARCH))\
 	$($(target)_$(source)_INCS.$(BUILD_TARGET))\
 	$($(target)_$(source)_INCS.$(BUILD_TYPE))\
 	$($(target)_$(source)_INCS)\
+	$(foreach sdk, $($(target)_$(source)_SDKS.$(BUILD_TARGET)) \
+				   $($(target)_$(source)_SDKS.$(BUILD_TYPE)) \
+				   $($(target)_$(source)_SDKS),
+	$(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
+	$(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
+	$(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
+	$(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
+	$(SDK_$(sdk)_$(type)INCS)\
+	$(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
+	$(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
+	$(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
+	$(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
+	$(SDK_$(sdk)_INCS))\
+	$($(source)_$(type)INCS.$(BUILD_TARGET_CPU))\
+	$($(source)_$(type)INCS.$(BUILD_TARGET_ARCH))\
 	$($(source)_$(type)INCS.$(BUILD_TARGET))\
 	$($(source)_$(type)INCS.$(BUILD_TYPE))\
 	$($(source)_$(type)INCS)\
+	$($(source)_INCS.$(BUILD_TARGET_CPU))\
+	$($(source)_INCS.$(BUILD_TARGET_ARCH))\
 	$($(source)_INCS.$(BUILD_TARGET))\
 	$($(source)_INCS.$(BUILD_TYPE))\
 	$($(source)_INCS)\
+	$(foreach sdk, $($(source)_SDKS.$(BUILD_TARGET)) \
+				   $($(source)_SDKS.$(BUILD_TYPE)) \
+				   $($(source)_SDKS),\
+	$(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
+	$(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
+	$(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
+	$(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
+	$(SDK_$(sdk)_$(type)INCS)\
+	$(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
+	$(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
+	$(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
+	$(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
+	$(SDK_$(sdk)_INCS))\
+	$($(target)_$(type)INCS.$(BUILD_TARGET_CPU))\
+	$($(target)_$(type)INCS.$(BUILD_TARGET_ARCH))\
 	$($(target)_$(type)INCS.$(BUILD_TARGET))\
 	$($(target)_$(type)INCS.$(BUILD_TYPE))\
 	$($(target)_$(type)INCS)\
+	$($(target)_INCS.$(BUILD_TARGET_CPU))\
+	$($(target)_INCS.$(BUILD_TARGET_ARCH))\
 	$($(target)_INCS.$(BUILD_TARGET))\
 	$($(target)_INCS.$(BUILD_TYPE))\
 	$($(target)_INCS)\
+	$(foreach sdk, $($(target)_SDKS.$(BUILD_TARGET)) \
+				   $($(target)_SDKS.$(BUILD_TYPE)) \
+				   $($(target)_SDKS),\
+	$(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
+	$(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
+	$(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
+	$(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
+	$(SDK_$(sdk)_$(type)INCS)\
+	$(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
+	$(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
+	$(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
+	$(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
+	$(SDK_$(sdk)_INCS))\
+	$(INCS.$(BUILD_TARGET_CPU))\
+	$(INCS.$(BUILD_TARGET_ARCH))\
 	$(INCS.$(BUILD_TARGET))\
 	$(INCS.$(BUILD_TYPE))\
 	$(INCS)\
+	$(foreach sdk, $(SDKS.$(BUILD_TARGET)) \
+				   $(SDKS.$(BUILD_TYPE)) \
+				   $(SDKS),\
+	$(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_CPU))\
+	$(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET_ARCH))\
+	$(SDK_$(sdk)_$(type)INCS.$(BUILD_TARGET))\
+	$(SDK_$(sdk)_$(type)INCS.$(BUILD_TYPE))\
+	$(SDK_$(sdk)_$(type)INCS)\
+	$(SDK_$(sdk)_INCS.$(BUILD_TARGET_CPU))\
+	$(SDK_$(sdk)_INCS.$(BUILD_TARGET_ARCH))\
+	$(SDK_$(sdk)_INCS.$(BUILD_TARGET))\
+	$(SDK_$(sdk)_INCS.$(BUILD_TYPE))\
+	$(SDK_$(sdk)_INCS))\
+	$(TOOL_$(tool)_$(type)INCS.$(BUILD_TARGET_CPU))\
+	$(TOOL_$(tool)_$(type)INCS.$(BUILD_TARGET_ARCH))\
 	$(TOOL_$(tool)_$(type)INCS.$(BUILD_TARGET))\
 	$(TOOL_$(tool)_$(type)INCS.$(BUILD_TYPE))\
@@ -273,16 +447,26 @@
 	$(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TYPE))\
 	$(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TARGET))\
+	$(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
+	$(TOOL_$(tool)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
 	$($(type)FLAGS)\
 	$($(type)FLAGS.$(BUILD_TYPE))\
 	$($(type)FLAGS.$(BUILD_TARGET))\
+	$($(type)FLAGS.$(BUILD_TARGET_ARCH))\
+	$($(type)FLAGS.$(BUILD_TARGET_CPU))\
 	$($(target)_$(type)FLAGS)\
 	$($(target)_$(type)FLAGS.$(BUILD_TYPE))\
 	$($(target)_$(type)FLAGS.$(BUILD_TARGET))\
+	$($(target)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
+	$($(target)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
 	$($(source)_$(type)FLAGS)\
 	$($(source)_$(type)FLAGS.$(BUILD_TYPE))\
 	$($(source)_$(type)FLAGS.$(BUILD_TARGET))\
+	$($(source)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
+	$($(source)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
 	$($(target)_$(source)_$(type)FLAGS)\
 	$($(target)_$(source)_$(type)FLAGS.$(BUILD_TYPE))\
 	$($(target)_$(source)_$(type)FLAGS.$(BUILD_TARGET))\
+	$($(target)_$(source)_$(type)FLAGS.$(BUILD_TARGET_ARCH))\
+	$($(target)_$(source)_$(type)FLAGS.$(BUILD_TARGET_CPU))\
 	)
 $(eval outbase     := $(call _OBJECT_BASE,$(source),$(target)))
@@ -339,5 +523,8 @@
 
 # library
-$(eval tool        := $(firstword $($(target)_TOOL) $(TOOL)))
+$(eval tool        := $(call _TARGET_TOOL,$(target),AR))
+ifeq ($(tool),)
+$$(error kBuild: Library target $(target) doesn't have a tool defined!)
+endif
 $(eval flags       :=\
 	$(TOOL_$(tool)_ARFLAGS)\
@@ -360,5 +547,5 @@
 $(eval objs         = $(_OBJS_$(target)))
 $(eval dirdep      := $(dir $(lib)).dir_created)
-## @todo fix dependencies
+## @todo fix dependencies on makefiles an such
 $(eval deps        := )
 
@@ -386,5 +573,5 @@
 
 # library
-$(eval tool        := $(firstword $($(target)_TOOL) $(TOOL)))
+$(eval tool        := $(call _TARGET_TOOL,$(target),LD))
 $(eval flags       :=\
 	$(TOOL_$(tool)_LDFLAGS)\
@@ -632,10 +819,13 @@
 nothing: pass_nothing
 
-		
-			
+					
+
 #
 # THE MAIN RULES
 #
 all_recursive: $(foreach pass,$(PASSES),pass_$(pass))
+
+rebuild: clean all_recursive
+
 
 # misc shortcuts.
Index: /trunk/kBuild/header.kmk
===================================================================
--- /trunk/kBuild/header.kmk	(revision 77)
+++ /trunk/kBuild/header.kmk	(revision 78)
@@ -129,4 +129,6 @@
 endif
 endif
+BUILD_TARGET_ARCH   := x86
+BUILD_TARGET_CPU    := i586
 
 
@@ -275,13 +277,13 @@
 #
 _CFGDIR     := .
-_CFGFILES   :=
+_CFGFILES   := ./Config.kmk ./config.kmk
 define def_include_config
-$(eval _CFGDIR := $(_CFGDIR)/$(1))
-_CFGFILES   += $(wildcard $(_CFGDIR)/Config.kmk $(_CFGDIR)/config.kmk)
+$(eval _CFGDIR := $(_CFGDIR)/$(dir))
+_CFGFILES   += $(_CFGDIR)/Config.kmk $(_CFGDIR)/config.kmk
 endef
 # walk down the _RELATIVE_ path specified by DEPTH.
-$(foreach d,$(subst /, ,$(DEPTH)), $(eval $(call def_include_config,$(d))) )
+$(foreach dir,$(subst /, ,$(DEPTH)), $(eval $(def_include_config)) )
 # add the default config file.
-_CFGFILE    := $(firstword $(_CFGFILES) $(FILE_KBUILD_CONFIG))
+_CFGFILE    := $(firstword $(wildcard $(_CFGFILES) $(FILE_KBUILD_CONFIG)))
 _CFGFILES   :=
 _CFGDIR     :=
Index: /trunk/kBuild/sdks/NT4DDK.kmk
===================================================================
--- /trunk/kBuild/sdks/NT4DDK.kmk	(revision 78)
+++ /trunk/kBuild/sdks/NT4DDK.kmk	(revision 78)
@@ -0,0 +1,41 @@
+# $Id$
+## @file
+#
+# kBuild SDK - NT4 DDK.
+#
+# Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
+#
+#
+# This file is part of kBuild.
+#
+# kBuild is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# kBuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kBuild; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#
+
+
+SDK_NT4DDK			:= MicroSoft NT 4 DDK
+PATH_SDK_NT4DDK     := $(PATH_DEV)/x86.win32/nt4ddk
+PATH_SDK_NT4DDK_INC := $(PATH_SDK_NT4DDK)/inc
+ifeq ($(BUILD_TARGET_ARCH),x86)
+PATH_SDK_NT4DDK_LIB := $(PATH_SDK_NT4DDK)/lib/i386/free
+SDK_NT4DDK_DEFS		:= _X86_
+else
+$(error NT4DDK only works targetting x86!)
+PATH_SDK_NT4DDK_LIB := $(PATH_SDK_NT4DDK)/lib/???/free
+SDK_NT4DDK_DEFS		:=
+endif
+SDK_NT4DDK_INCS		:= $(PATH_SDK_NT4DDK_INC)
+SDK_NT4DDK_LIBPATHS	:= $(PATH_SDK_NT4DDK_LIB)
+
