Index: trunk/kBuild/gnumake-append.sh
===================================================================
--- trunk/kBuild/gnumake-append.sh	(revision 977)
+++ 	(revision )
@@ -1,76 +1,0 @@
-#/bin/sh
-
-# $Id: $
-## @file
-#
-# kmk_append fake script for bootstrapping.
-#
-# Copyright (c) 2007 knut st. osmundsen <bird-src-spam@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
-#
-#
-
-
-set -e
-
-#
-# Parse args.
-#
-NEWLINE=0
-echo "$1"
-while test "$1" = "-n"  -o  "$1" = "-v"  -o  "$1" = "-nv"  -o "$1" = "-vn";
-do
-    case "$1" in
-        -n)
-            NEWLINE=1
-            ;;
-        *)
-            echo "gnumake-append.sh: Unsupported argument: $1"
-            exit 1;
-    esac
-    shift
-done
-
-FILE="$1"
-if test -z "$FILE"; then
-    echo "gnumake-append.sh: No arguments given."
-    echo "syntax: gnumake-append.sh [-n] <file> [string [more strings]]"
-    exit 1
-fi
-shift
-
-
-#
-# Do work
-#
-if test "$#" -eq "0"; then
-    echo "" >> "$FILE"
-else
-    if test "$NEWLINE" = "0"; then
-        echo "$*" >> "$FILE"
-    else
-        while test "$#" -ne "0";
-	do
-            echo "$1" >> "$FILE"
-            shift
-        done
-    fi
-fi
-exit 0;
-
Index: trunk/kBuild/gnumake-footer.kmk
===================================================================
--- trunk/kBuild/gnumake-footer.kmk	(revision 977)
+++ 	(revision )
@@ -1,454 +1,0 @@
-# $Id$
-## @file
-#
-# kBuild - Additional footer for use when bootstrapping kBuild using Vanilla GNU Make.
-#
-# Copyright (c) 2004-2007 knut st. osmundsen <bird-kBuild-spam@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
-#
-#
-
-## Converts an relative path to an absolute path using the given CWD.
-# @returns absolute path.
-# @param    $1      The path to fixup.
-# @param    $2      The CWD to use.
-abspathex = $(foreach _fix_path,$1\
-,$(if $(subst :$(call no-root-slash,$(call no-drive,$(_fix_path))):,,:$(_fix_path):),$(_fix_path),$(abspath $2/$(_fix_path))))
-
-## Figure out the tool for a source
-# @param    target       source file
-# @param    source       normalized main target
-# @param    type         tooltype
-# @param    bld_trg      build target.
-# @param    bld_trg_arch build target architecture.
-# @remark 	Obsoleted by kBuild helpers in kmk. Only required for gmake compatbility.
-_SOURCE_TOOL = $(strip $(firstword \
-	$($(target)_$(source)_$(type)TOOL.$(bld_trg).$(bld_trg_arch)) \
-	$($(target)_$(source)_$(type)TOOL.$(bld_trg)) \
-	$($(target)_$(source)_$(type)TOOL) \
-	$($(target)_$(source)_TOOL.$(bld_trg).$(bld_trg_arch)) \
-	$($(target)_$(source)_TOOL.$(bld_trg)) \
-	$($(target)_$(source)_TOOL) \
-	$($(source)_$(type)TOOL.$(bld_trg).$(bld_trg_arch)) \
-	$($(source)_$(type)TOOL.$(bld_trg)) \
-	$($(source)_$(type)TOOL) \
-	$($(source)_TOOL.$(bld_trg).$(bld_trg_arch)) \
-	$($(source)_TOOL.$(bld_trg)) \
-	$($(source)_TOOL) \
-	$($(target)_$(type)TOOL.$(bld_trg).$(bld_trg_arch)) \
-	$($(target)_$(type)TOOL.$(bld_trg)) \
-	$($(target)_$(type)TOOL) \
-	$($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
-	$($(target)_TOOL.$(bld_trg)) \
-	$($(target)_TOOL) \
-	$($(type)TOOL.$(bld_trg).$(bld_trg_arch)) \
-	$($(type)TOOL.$(bld_trg)) \
-	$($(type)TOOL) \
-	$(TOOL.$(bld_trg).$(bld_trg_arch)) \
-	$(TOOL.$(bld_trg)) \
-	$(TOOL) ))
-
-## Figure out where to put object files.
-# @param    $1      source file
-# @param    $2      normalized main target
-# @remark There are two major hacks here:
-#           1. Source files in the output directory are translated into a gen/ subdir.
-#         	2. Catch anyone specifying $(PATH_SUB_CURRENT)/sourcefile.c.
-# @remark 	obsoleted by kBuild helpers in kmk. Only required for gmake compatbility.
-_OBJECT_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(basename \
-	$(patsubst $(PATH_ROOT)/%,%,$(patsubst $(PATH_SUB_CURRENT)/%,%,$(patsubst $(PATH_TARGET)/$(2)/%,gen/%,$(1)))))))
-
-
-## Generic macro for processing C, C++ and Assembly sources.
-# @param    $(target)     Normalized target name.
-# @param    $(source)     Source file name.
-# @param    $(type)       Source type. {C,CXX,AS}
-# @param    bld_type      Build type.
-# @param    bld_trg       Build target.
-# @param    bld_trg_arch  Build target arch.
-# @param    bld_trg_cpu   Build target cpu.
-# @remark 	obsoleted by kBuild helpers in kmk. Only required for limited gmake compatbility.
-#
-define def_target_source_c_cpp_asm_rc_old
-#$ (warning dbg: def_target_source_c_cpp_asm_rc_old: source='$(source)' target='$(target)' type='$(type)')
-
-tool := $(call _SOURCE_TOOL,$(source),$(target),$(type))
-outbase     := $(call _OBJECT_BASE,$(source),$(target))
-PATH_$(target)_$(source) := $(patsubst %/,%,$(dir $(outbase)))
-dirdep      := $(call DIRDEP,$(dir $(outbase)))
-defs        :=\
-	$(TOOL_$(tool)_DEFS)\
-	$(TOOL_$(tool)_DEFS.$(bld_type))\
-	$(TOOL_$(tool)_DEFS.$(bld_trg))\
-	$(TOOL_$(tool)_DEFS.$(bld_trg_arch))\
-	$(TOOL_$(tool)_DEFS.$(bld_trg).$(bld_trg_arch))\
-	$(TOOL_$(tool)_DEFS.$(bld_trg_cpu))\
-	$(TOOL_$(tool)_$(type)DEFS)\
-	$(TOOL_$(tool)_$(type)DEFS.$(bld_type))\
-	$(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
-	               $(SDKS.$(bld_trg_arch)) \
-	               $(SDKS.$(bld_trg)) \
-	               $(SDKS.$(bld_type)) \
-	               $(SDKS),\
-		$(SDK_$(sdk)_DEFS)\
-		$(SDK_$(sdk)_DEFS.$(bld_type))\
-		$(SDK_$(sdk)_DEFS.$(bld_trg))\
-		$(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
-		$(SDK_$(sdk)_DEFS.$(bld_trg).$(bld_trg_arch))\
-		$(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
-		$(SDK_$(sdk)_$(type)DEFS)\
-		$(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
-		$(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
-		$(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
-		$(SDK_$(sdk)_$(type)DEFS.$(bld_trg).$(bld_trg_arch))\
-		$(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
-	$(DEFS)\
-	$(DEFS.$(bld_type))\
-	$(DEFS.$(bld_trg))\
-	$(DEFS.$(bld_trg_arch))\
-	$(DEFS.$(bld_trg).$(bld_trg_arch))\
-	$(DEFS.$(bld_trg_cpu))\
-	$($(type)DEFS)\
-	$($(type)DEFS.$(bld_type))\
-	$($(type)DEFS.$(bld_trg))\
-	$($(type)DEFS.$(bld_trg_arch))\
-	$($(type)DEFS.$(bld_trg).$(bld_trg_arch))\
-	$($(type)DEFS.$(bld_trg_cpu))\
-	$(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
-	               $($(target)_SDKS.$(bld_trg_arch)) \
-	               $($(target)_SDKS.$(bld_trg)) \
-	               $($(target)_SDKS.$(bld_type)) \
-	               $($(target)_SDKS),\
-		$(SDK_$(sdk)_DEFS)\
-		$(SDK_$(sdk)_DEFS.$(bld_type))\
-		$(SDK_$(sdk)_DEFS.$(bld_trg))\
-		$(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
-		$(SDK_$(sdk)_DEFS.$(bld_trg).$(bld_trg_arch))\
-		$(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
-		$(SDK_$(sdk)_$(type)DEFS)\
-		$(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
-		$(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
-		$(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
-		$(SDK_$(sdk)_$(type)DEFS.$(bld_trg).$(bld_trg_arch))\
-		$(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
-	$($(target)_DEFS)\
-	$($(target)_DEFS.$(bld_type))\
-	$($(target)_DEFS.$(bld_trg))\
-	$($(target)_DEFS.$(bld_trg_arch))\
-	$($(target)_DEFS.$(bld_trg).$(bld_trg_arch))\
-	$($(target)_DEFS.$(bld_trg_cpu))\
-	$($(target)_$(type)DEFS)\
-	$($(target)_$(type)DEFS.$(bld_type))\
-	$($(target)_$(type)DEFS.$(bld_trg))\
-	$($(target)_$(type)DEFS.$(bld_trg_arch))\
-	$($(target)_$(type)DEFS.$(bld_trg).$(bld_trg_arch))\
-	$($(target)_$(type)DEFS.$(bld_trg_cpu))\
-	$(foreach sdk, $($(source)_SDKS.$(bld_trg).$(bld_trg_arch)) \
-	               $($(source)_SDKS.$(bld_trg_arch)) \
-	               $($(source)_SDKS.$(bld_trg)) \
-	               $($(source)_SDKS.$(bld_type)) \
-	               $($(source)_SDKS),\
-		$(SDK_$(sdk)_DEFS)\
-		$(SDK_$(sdk)_DEFS.$(bld_type))\
-		$(SDK_$(sdk)_DEFS.$(bld_trg))\
-		$(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
-		$(SDK_$(sdk)_DEFS.$(bld_trg).$(bld_trg_arch))\
-		$(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
-		$(SDK_$(sdk)_$(type)DEFS)\
-		$(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
-		$(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
-		$(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
-		$(SDK_$(sdk)_$(type)DEFS.$(bld_trg).$(bld_trg_arch))\
-		$(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
-	$($(source)_DEFS)\
-	$($(source)_DEFS.$(bld_type))\
-	$($(source)_DEFS.$(bld_trg))\
-	$($(source)_DEFS.$(bld_trg_arch))\
-	$($(source)_DEFS.$(bld_trg).$(bld_trg_arch))\
-	$($(source)_DEFS.$(bld_trg_cpu))\
-	$($(source)_$(type)DEFS)\
-	$($(source)_$(type)DEFS.$(bld_type))\
-	$($(source)_$(type)DEFS.$(bld_trg))\
-	$($(source)_$(type)DEFS.$(bld_trg_arch))\
-	$($(source)_$(type)DEFS.$(bld_trg).$(bld_trg_arch))\
-	$($(source)_$(type)DEFS.$(bld_trg_cpu))\
-	$(foreach sdk, $($(target)_$(source)_SDKS.$(bld_trg).$(bld_trg_arch)) \
-	               $($(target)_$(source)_SDKS.$(bld_trg_arch)) \
-	               $($(target)_$(source)_SDKS.$(bld_trg)) \
-	               $($(target)_$(source)_SDKS.$(bld_type)) \
-	               $($(target)_$(source)_SDKS),\
-		$(SDK_$(sdk)_DEFS)\
-		$(SDK_$(sdk)_DEFS.$(bld_type))\
-		$(SDK_$(sdk)_DEFS.$(bld_trg))\
-		$(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
-		$(SDK_$(sdk)_DEFS.$(bld_trg).$(bld_trg_arch))\
-		$(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
-		$(SDK_$(sdk)_$(type)DEFS)\
-		$(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
-		$(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
-		$(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
-		$(SDK_$(sdk)_$(type)DEFS.$(bld_trg).$(bld_trg_arch))\
-		$(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
-	$($(target)_$(source)_DEFS)\
-	$($(target)_$(source)_DEFS.$(bld_type))\
-	$($(target)_$(source)_DEFS.$(bld_trg))\
-	$($(target)_$(source)_DEFS.$(bld_trg_arch))\
-	$($(target)_$(source)_DEFS.$(bld_trg).$(bld_trg_arch))\
-	$($(target)_$(source)_DEFS.$(bld_trg_cpu))\
-	$($(target)_$(source)_$(type)DEFS)\
-	$($(target)_$(source)_$(type)DEFS.$(bld_type))\
-	$($(target)_$(source)_$(type)DEFS.$(bld_trg))\
-	$($(target)_$(source)_$(type)DEFS.$(bld_trg_arch))\
-	$($(target)_$(source)_$(type)DEFS.$(bld_trg).$(bld_trg_arch))\
-	$($(target)_$(source)_$(type)DEFS.$(bld_trg_cpu))
-incs        :=\
-	$($(target)_$(source)_$(type)INCS.$(bld_trg_cpu))\
-	$($(target)_$(source)_$(type)INCS.$(bld_trg).$(bld_trg_arch))\
-	$($(target)_$(source)_$(type)INCS.$(bld_trg_arch))\
-	$($(target)_$(source)_$(type)INCS.$(bld_trg))\
-	$($(target)_$(source)_$(type)INCS.$(bld_type))\
-	$($(target)_$(source)_$(type)INCS)\
-	$($(target)_$(source)_INCS.$(bld_trg_cpu))\
-	$($(target)_$(source)_INCS.$(bld_trg).$(bld_trg_arch))\
-	$($(target)_$(source)_INCS.$(bld_trg_arch))\
-	$($(target)_$(source)_INCS.$(bld_trg))\
-	$($(target)_$(source)_INCS.$(bld_type))\
-	$($(target)_$(source)_INCS)\
-	$(foreach sdk, $($(target)_$(source)_SDKS.$(bld_trg).$(bld_trg_arch)) \
-	               $($(target)_$(source)_SDKS.$(bld_trg_arch)) \
-	               $($(target)_$(source)_SDKS.$(bld_trg)) \
-	               $($(target)_$(source)_SDKS.$(bld_type)) \
-	               $($(target)_$(source)_SDKS),\
-		$(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
-		$(SDK_$(sdk)_$(type)INCS.$(bld_trg).$(bld_trg_arch))\
-		$(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
-		$(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
-		$(SDK_$(sdk)_$(type)INCS.$(bld_type))\
-		$(SDK_$(sdk)_$(type)INCS)\
-		$(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
-		$(SDK_$(sdk)_INCS.$(bld_trg).$(bld_trg_arch))\
-		$(SDK_$(sdk)_INCS.$(bld_trg_arch))\
-		$(SDK_$(sdk)_INCS.$(bld_trg))\
-		$(SDK_$(sdk)_INCS.$(bld_type))\
-		$(SDK_$(sdk)_INCS))\
-	$($(source)_$(type)INCS.$(bld_trg_cpu))\
-	$($(source)_$(type)INCS.$(bld_trg).$(bld_trg_arch))\
-	$($(source)_$(type)INCS.$(bld_trg_arch))\
-	$($(source)_$(type)INCS.$(bld_trg))\
-	$($(source)_$(type)INCS.$(bld_type))\
-	$($(source)_$(type)INCS)\
-	$($(source)_INCS.$(bld_trg_cpu))\
-	$($(source)_INCS.$(bld_trg).$(bld_trg_arch))\
-	$($(source)_INCS.$(bld_trg_arch))\
-	$($(source)_INCS.$(bld_trg))\
-	$($(source)_INCS.$(bld_type))\
-	$($(source)_INCS)\
-	$(foreach sdk, $($(source)_SDKS.$(bld_trg).$(bld_trg_arch)) \
-		       $($(source)_SDKS.$(bld_trg_arch)) \
-		       $($(source)_SDKS.$(bld_trg)) \
-		       $($(source)_SDKS.$(bld_type)) \
-		       $($(source)_SDKS),\
-		$(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
-		$(SDK_$(sdk)_$(type)INCS.$(bld_trg).$(bld_trg_arch))\
-		$(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
-		$(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
-		$(SDK_$(sdk)_$(type)INCS.$(bld_type))\
-		$(SDK_$(sdk)_$(type)INCS)\
-		$(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
-		$(SDK_$(sdk)_INCS.$(bld_trg).$(bld_trg_arch))\
-		$(SDK_$(sdk)_INCS.$(bld_trg_arch))\
-		$(SDK_$(sdk)_INCS.$(bld_trg))\
-		$(SDK_$(sdk)_INCS.$(bld_type))\
-		$(SDK_$(sdk)_INCS))\
-	$($(target)_$(type)INCS.$(bld_trg_cpu))\
-	$($(target)_$(type)INCS.$(bld_trg).$(bld_trg_arch))\
-	$($(target)_$(type)INCS.$(bld_trg_arch))\
-	$($(target)_$(type)INCS.$(bld_trg))\
-	$($(target)_$(type)INCS.$(bld_type))\
-	$($(target)_$(type)INCS)\
-	$($(target)_INCS.$(bld_trg_cpu))\
-	$($(target)_INCS.$(bld_trg).$(bld_trg_arch))\
-	$($(target)_INCS.$(bld_trg_arch))\
-	$($(target)_INCS.$(bld_trg))\
-	$($(target)_INCS.$(bld_type))\
-	$($(target)_INCS)\
-	$(foreach sdk, $($(target)_SDKS.$(bld_trg).$(bld_trg_arch)) \
-		       $($(target)_SDKS.$(bld_trg_arch)) \
-		       $($(target)_SDKS.$(bld_trg)) \
-		       $($(target)_SDKS.$(bld_type)) \
-		       $($(target)_SDKS),\
-		$(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
-		$(SDK_$(sdk)_$(type)INCS.$(bld_trg).$(bld_trg_arch))\
-		$(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
-		$(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
-		$(SDK_$(sdk)_$(type)INCS.$(bld_type))\
-		$(SDK_$(sdk)_$(type)INCS)\
-		$(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
-		$(SDK_$(sdk)_INCS.$(bld_trg).$(bld_trg_arch))\
-		$(SDK_$(sdk)_INCS.$(bld_trg_arch))\
-		$(SDK_$(sdk)_INCS.$(bld_trg))\
-		$(SDK_$(sdk)_INCS.$(bld_type))\
-		$(SDK_$(sdk)_INCS))\
-	$(INCS.$(bld_trg_cpu))\
-	$(INCS.$(bld_trg).$(bld_trg_arch))\
-	$(INCS.$(bld_trg_arch))\
-	$(INCS.$(bld_trg))\
-	$(INCS.$(bld_type))\
-	$(INCS)\
-	$(foreach sdk, $(SDKS.$(bld_trg).$(bld_trg_arch)) \
-	               $(SDKS.$(bld_trg_arch)) \
-	               $(SDKS.$(bld_trg)) \
-	               $(SDKS.$(bld_type)) \
-	               $(SDKS),\
-		$(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
-		$(SDK_$(sdk)_$(type)INCS.$(bld_trg).$(bld_trg_arch))\
-		$(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
-		$(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
-		$(SDK_$(sdk)_$(type)INCS.$(bld_type))\
-		$(SDK_$(sdk)_$(type)INCS)\
-		$(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
-		$(SDK_$(sdk)_INCS.$(bld_trg).$(bld_trg_arch))\
-		$(SDK_$(sdk)_INCS.$(bld_trg_arch))\
-		$(SDK_$(sdk)_INCS.$(bld_trg))\
-		$(SDK_$(sdk)_INCS.$(bld_type))\
-		$(SDK_$(sdk)_INCS))\
-	$(TOOL_$(tool)_$(type)INCS.$(bld_trg_cpu))\
-	$(TOOL_$(tool)_$(type)INCS.$(bld_trg).$(bld_trg_arch))\
-	$(TOOL_$(tool)_$(type)INCS.$(bld_trg_arch))\
-	$(TOOL_$(tool)_$(type)INCS.$(bld_trg))\
-	$(TOOL_$(tool)_$(type)INCS.$(bld_type))\
-	$(TOOL_$(tool)_$(type)INCS)
-flags        :=\
-	$(TOOL_$(tool)_$(type)FLAGS)\
-	$(TOOL_$(tool)_$(type)FLAGS.$(bld_type))\
-	$(TOOL_$(tool)_$(type)FLAGS.$(bld_trg))\
-	$(TOOL_$(tool)_$(type)FLAGS.$(bld_trg_arch))\
-	$(TOOL_$(tool)_$(type)FLAGS.$(bld_trg).$(bld_trg_arch))\
-	$(TOOL_$(tool)_$(type)FLAGS.$(bld_trg_cpu))\
-	$($(type)FLAGS)\
-	$($(type)FLAGS.$(bld_type))\
-	$($(type)FLAGS.$(bld_trg))\
-	$($(type)FLAGS.$(bld_trg_arch))\
-	$($(type)FLAGS.$(bld_trg).$(bld_trg_arch))\
-	$($(type)FLAGS.$(bld_trg_cpu))\
-	$($(target)_$(type)FLAGS)\
-	$($(target)_$(type)FLAGS.$(bld_type))\
-	$($(target)_$(type)FLAGS.$(bld_trg))\
-	$($(target)_$(type)FLAGS.$(bld_trg_arch))\
-	$($(target)_$(type)FLAGS.$(bld_trg).$(bld_trg_arch))\
-	$($(target)_$(type)FLAGS.$(bld_trg_cpu))\
-	$($(source)_$(type)FLAGS)\
-	$($(source)_$(type)FLAGS.$(bld_type))\
-	$($(source)_$(type)FLAGS.$(bld_trg))\
-	$($(source)_$(type)FLAGS.$(bld_trg_arch))\
-	$($(source)_$(type)FLAGS.$(bld_trg).$(bld_trg_arch))\
-	$($(source)_$(type)FLAGS.$(bld_trg_cpu))\
-	$($(target)_$(source)_$(type)FLAGS)\
-	$($(target)_$(source)_$(type)FLAGS.$(bld_type))\
-	$($(target)_$(source)_$(type)FLAGS.$(bld_trg))\
-	$($(target)_$(source)_$(type)FLAGS.$(bld_trg_arch))\
-	$($(target)_$(source)_$(type)FLAGS.$(bld_trg).$(bld_trg_arch))\
-	$($(target)_$(source)_$(type)FLAGS.$(bld_trg_cpu))
-# this isn't 100% in sync with kBuild, but it doesn't matter as it's only for gmake now.
-objsuff     := $(firstword \
-	$($(target)_$(source)_OBJSUFF.$(bld_trg).$(bld_trg_arch))\
-	$($(target)_$(source)_OBJSUFF.$(bld_trg))\
-	$($(target)_$(source)_OBJSUFF)\
-	$($(source)_OBJSUFF.$(bld_trg).$(bld_trg_arch))\
-	$($(source)_OBJSUFF.$(bld_trg))\
-	$($(source)_OBJSUFF)\
-	$($(target)_OBJSUFF.$(bld_trg).$(bld_trg_arch))\
-	$($(target)_OBJSUFF.$(bld_trg))\
-	$($(target)_OBJSUFF)\
-	$(TOOL_$(tool)_$(type)OBJSUFF.$(bld_trg).$(bld_trg_arch))\
-	$(TOOL_$(tool)_$(type)OBJSUFF.$(bld_trg))\
-	$(TOOL_$(tool)_$(type)OBJSUFF)\
-	$(SUFF_OBJ))
-obj         := $(outbase)$(objsuff)
-deps        := \
-	$($(target)_$(source)_DEPS)\
-	$($(target)_$(source)_DEPS.$(bld_type))\
-	$($(target)_$(source)_DEPS.$(bld_trg))\
-	$($(target)_$(source)_DEPS.$(bld_trg_arch))\
-	$($(target)_$(source)_DEPS.$(bld_trg).$(bld_trg_arch))\
-	$($(target)_$(source)_DEPS.$(bld_trg_cpu))\
-	$($(source)_DEPS)\
-	$($(source)_DEPS.$(bld_type))\
-	$($(source)_DEPS.$(bld_trg))\
-	$($(source)_DEPS.$(bld_trg_arch))\
-	$($(source)_DEPS.$(bld_trg).$(bld_trg_arch))\
-	$($(source)_DEPS.$(bld_trg_cpu))\
-	$($(target)_DEPS)\
-	$($(target)_DEPS.$(bld_type))\
-	$($(target)_DEPS.$(bld_trg))\
-	$($(target)_DEPS.$(bld_trg_arch))\
-	$($(target)_DEPS.$(bld_trg).$(bld_trg_arch))\
-	$($(target)_DEPS.$(bld_trg_cpu))
-
-# dependencies
-dep         := $(obj)$(SUFF_DEP)
-ifndef NO_COMPILE_CMDS_DEPS
-_DEPFILES_INCLUDED += $(dep)
-$(if $(wildcard $(dep)),$(eval include $(dep)))
-endif
-
-#$ (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))
-ifndef TOOL_$(tool)_COMPILE_$(type)_CMDS
-$(warning kBuild: tools: \
-	1 $($(target)_$(source)_$(type)TOOL.$(bld_trg).$(bld_trg_arch)) \
-	2 $($(target)_$(source)_$(type)TOOL.$(bld_trg)) \
-	3 $($(target)_$(source)_$(type)TOOL) \
-	4 $($(target)_$(source)_TOOL.$(bld_trg).$(bld_trg_arch)) \
-	5 $($(target)_$(source)_TOOL.$(bld_trg)) \
-	6 $($(target)_$(source)_TOOL) \
-	7 $($(target)_$(type)TOOL.$(bld_trg).$(bld_trg_arch)) \
-	8 $($(target)_$(type)TOOL.$(bld_trg)) \
-	9 $($(target)_$(type)TOOL) \
-	10 $($(target)_TOOL.$(bld_trg).$(bld_trg_arch)) \
-	11 $($(target)_TOOL.$(bld_trg)) \
-	12 $($(target)_TOOL) \
-	13 $($(source)_$(type)TOOL.$(bld_trg).$(bld_trg_arch)) \
-	14 $($(source)_$(type)TOOL.$(bld_trg)) \
-	15 $($(source)_$(type)TOOL) \
-	16 $($(source)_TOOL.$(bld_trg).$(bld_trg_arch)) \
-	17 $($(source)_TOOL.$(bld_trg)) \
-	18 $($(source)_TOOL) \
-	19 $($(type)TOOL.$(bld_trg).$(bld_trg_arch)) \
-	20 $($(type)TOOL.$(bld_trg)) \
-	21 $($(type)TOOL) \
-	22 $(TOOL.$(bld_trg).$(bld_trg_arch)) \
-	23 $(TOOL.$(bld_trg)) \
-	24 $(TOOL) )
-$(error kBuild: TOOL_$(tool)_COMPILE_$(type)_CMDS is not defined. source=$(source) target=$(target) )
-endif
-
-# call the tool
-$(target)_$(source)_CMDS_   := $(TOOL_$(tool)_COMPILE_$(type)_CMDS)
-$(target)_$(source)_OUTPUT_ := $(TOOL_$(tool)_COMPILE_$(type)_OUTPUT)
-$(target)_$(source)_DEPEND_ := $(TOOL_$(tool)_COMPILE_$(type)_DEPEND) $(deps) $(source)
-$(target)_$(source)_DEPORD_ := $(TOOL_$(tool)_COMPILE_$(type)_DEPORD) $(dirdep)
-
-# generate the compile rule.
-$(eval $(def_target_source_rule))
-
-_OUT_FILES      += $($(target)_$(source)_OUTPUT_)
-$(target)_OBJS_ += $(obj)
-
-endef
-
Index: trunk/kBuild/gnumake-header.kmk
===================================================================
--- trunk/kBuild/gnumake-header.kmk	(revision 977)
+++ 	(revision )
@@ -1,196 +1,0 @@
-# $Id$
-## @file
-#
-# kBuild - Additional header for use when bootstrapping kBuild using Vanilla GNU Make.
-#
-# Copyright (c) 2004-2007 knut st. osmundsen <bird-kBuild-spam@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
-#
-#
-
-#
-# Disable some features to make it work.
-#
-NO_COMPILE_CMDS_DEPS := 1
-NO_LINK_CMDS_DEPS := 1
-sinclude $(PATH_KBUILD)/StampOutPredefines.kmk
-$(warning kBuild: Using vanilla GNU make isn't safe for anything but kBuild bootstrapping!)
-
-##
-# Pushes an item onto a 'stack' variable.
-# @param    $1   The stack variable name
-# @param    $2   What to push.
-stack-push = $(eval $1 +=$2)
-
-##
-# Removes the top element from a 'stack' variable.
-# @returns  The popped element
-# @param    $1   The stack variable name
-stack-pop  = $(call stack-top,$1)$(call stack-popv,$1)
-
-##
-# Removes the top element from a 'stack' variable.
-# This does *NOT* return the top element, use
-# @param    $1   The stack variable name
-# @remark This ain't very fast (that's why it's implemented in functions.c in kmk).
-stack-popv = $(eval $1:=$(wordlist 1,$(words $(wordlist 2,9999,$($1))),$($1)))
-
-##
-# Retrieves the top element from the 'stack' variable.
-# @param    $1   The stack variable name
-stack-top  = $(lastword $($1))
-
-## Converts an relative path to an absolute path using the given CWD.
-# @returns absolute path.
-# @param    $1      The path to fixup.
-# @param    $2      The CWD to use.
-abspathex = $(foreach _fix_path,$1\
-,$(if $(subst :$(call no-root-slash,$(call no-drive,$(_fix_path))):,,:$(_fix_path):),$(_fix_path),$(abspath $2/$(_fix_path))))
-
-
-##
-# Use the APPEND shell script in case we're boot strapping.
-APPEND_EXT := $(PATH_KBUILD)/gnumake-append.sh
-APPEND = $(APPEND_EXT)
-
-#
-# Fix some default variables.
-#
-ifeq ($(MAKEFLAGS),$(MAKEFLAGS:R=x))
-# add the -R makeflag to avoid doing this for submakes
-MAKEFLAGS := R$(MAKEFLAGS)
-
-define def_undefine_default
-ifeq ($(origin $1), default)
-$1:=
-endif
-endef
-
-_DEFAULT_VARIABLES := .LIBPATTERNS .VARIABLES AR ARFLAGS AS CC CHECKOUT,v CO COFLAGS COMPILE.C COMPILE.F COMPILE.S COMPILE.c COMPILE.cc COMPILE.cpp COMPILE.def COMPILE.f COMPILE.mod COMPILE.p COMPILE.r COMPILE.s CPP CTANGLE CWEAVE CXX F77 F77FLAGS FC GET LD LEX LEX.l LINK.C LINK.F LINK.S LINK.c LINK.cc LINK.cpp LINK.f LINK.o LINK.p LINK.r LINK.s LINT LINT.c M2C MAKEINFO OUTPUT_OPTION PC PREPROCESS.F PREPROCESS.S PREPROCESS.r RM TANGLE TEX TEXI2DVI WEAVE YACC YACC.y
-$(foreach i, $(_DEFAULT_VARIABLES), $(eval $(call def_undefine_default,$(i))))
-_DEFAULT_VARIABLES :=
-def_undefine_default :=
-endif
-
-#
-# Zap suffixes.
-#
-.SUFFIXES:
-SUFFIXES :=
-
-#
-# Zap implicit rules
-#
-ifeq ($(MAKEFLAGS),$(MAKEFLAGS:r=x))
-MAKEFLAGS := r$(MAKEFLAGS)
-# add the -r makeflag to avoid doing this for submakes
-
-%.C:
-%.F:
-%.S:
-%.a:
-%.c:
-%.c: %.l
-%.c: %.w
-%.c: %.w %.ch
-%.c: %.y
-%.cc:
-%.ch:
-%.cpp:
-%.def:
-%.dll:
-%.dvi:
-%.dvi: %.tex
-%.dvi: %.texi
-%.dvi: %.texinfo
-%.dvi: %.txinfo
-%.el:
-%.elc:
-%.exe:
-%.f:
-%.f: %.F
-%.f: %.r
-%.h:
-%.info:
-%.info: %.texi
-%.info: %.texinfo
-%.info: %.txinfo
-%.l:
-%.lib:
-%.ln:
-%.ln: %.c
-%.ln: %.l
-%.ln: %.y
-%.mod:
-%.o:
-%.o: %.C
-%.o: %.F
-%.o: %.S
-%.o: %.c
-%.o: %.cc
-%.o: %.cpp
-%.o: %.f
-%.o: %.mod
-%.o: %.p
-%.o: %.r
-%.o: %.s
-%.obj:
-%.out:
-%.out: %
-%.p:
-%.p: %.web
-%.r:
-%.r: %.l
-%.s:
-%.s: %.S
-%.sh:
-%.sym:
-%.sym: %.def
-%.tex:
-%.tex: %.w
-%.tex: %.w %.ch
-%.tex: %.web
-%.texi:
-%.texinfo:
-%.txinfo:
-%.w:
-%.web:
-%.y:
-%: %.C
-%: %.F
-%: %.S
-%: %.c
-%: %.cc
-%: %.cpp
-%: %.f
-%: %.mod
-%: %.o
-%: %.p
-%: %.r
-%: %.s
-%: %.sh
-%:: %,v
-%:: RCS/%
-%:: RCS/%,v
-%:: SCCS/s.%
-%:: s.%
-(%): %
-endif
-
-
Index: trunk/kBuild/header.kmk
===================================================================
--- trunk/kBuild/header.kmk	(revision 977)
+++ trunk/kBuild/header.kmk	(revision 978)
@@ -2,5 +2,5 @@
 ## @file
 #
-# kBuild - File included at top of makefile.
+# kBuild - File included at top of a makefile.
 #
 # Copyright (c) 2004-2007 knut st. osmundsen <bird-kBuild-spam@anduin.net>
@@ -28,28 +28,42 @@
 # start-of-file-content
 
-#
-# default rule
+
+#
+# Check make version before we do anything else.
+#
+ifndef KMK_VERSION
+ $(error kBuild: The kmk default variable KMK_VERSION isn't defined! Make sure you are using 'kmk' and not 'make', 'gmake', 'kmk_gmake', 'dmake' or any other make program.)
+endif
+ifneq ($(KBUILD_VERSION_MAJOR).$(KBUILD_VERSION_MINOR),0.1)
+ ifneq ($(KBUILD_VERSION_MAJOR),0)
+  $(warning kBuild: kmk major version mismatch, expected '0' found '$(KBUILD_VERSION_MAJOR)'!)
+ else
+  $(warning kBuild: kmk minor version mismatch, expected '1' found '$(KBUILD_VERSION_MINOR)'!)
+ endif
+endif
+
+#
+# The revision in which this file was last modified.
+# This can be useful when using development versions of kBuild.
+#
+KMK_REVISION := $(patsubst %:,,  $Rev$  )
+
+
+#
+# Define the default goal.
 #
 all: all_recursive
 
 #
-# The FORCE rule.
+# The phony FORCE target.
 #
 FORCE:
 
-#
-# Try avoid inference rules.
-#
-.SUFFIXES:
-SUFFIXES :=
-
-#
-# Enable delete (targets) on error.
+
+#
+# Enable delete on error and second expansion of prerequisites.
 #
 .DELETE_ON_ERROR:
 
-#
-# Enable second expansion of prerequisites.
-#
 .SECONDEXPANSION:
 
@@ -58,9 +72,4 @@
 # General purpose macros.
 #
-
-## get last word in a list.
-# @returns  last word in $1.
-# @param    $1	Word list.
-lastword = $(word $(words $(1)), $(1))
 
 ##
@@ -115,82 +124,118 @@
 
 #
+# The OSes and Architectures that kBuild recognizes.
+#
+# When kBuild is ported to a new OS or architecture a unique keyword needs
+# to be assigned to it and added here. This strictness is required because
+# this keyword namespace is shared between OSes, architectures, cpus and
+# build types.
+#
+KBUILD_OSES   = darwin freebsd l4 linux netbsd nt openbsd os2 solaris win
+KBUILD_ARCHES = x86 amd64 sparc32 sparc64 mips32 mips64 ppc32 ppc64
+
+
+#
 # Set default build type.
 #
 ifndef BUILD_TYPE
- ifdef BUILD_MODE
- # BUILD_MODE is legacy from the OS/2 build system. :)
-BUILD_TYPE          := $(tolower $(BUILD_MODE))
- else
-BUILD_TYPE          := release
- endif
-endif
-
-
-#
-# Assert build platform.
-#
-ifndef BUILD_PLATFORM
- $(error kBuild: BUILD_PLATFORM is undefined!)
-else
- BUILD_PLATFORM     := $(strip $(BUILD_PLATFORM))
- ifneq ($(words $(BUILD_PLATFORM))$(filter-out darwin freebsd l4 linux nt os2 solaris win win32 win64,$(BUILD_PLATFORM)),1)
-  # OS/2 (have uppercase legacy)
-  ifeq ($(BUILD_PLATFORM),OS2)
-   $(error kBuild: BUILD_PLATFORM must be all lowercase!)
-  endif
-  $(error kBuild: BUILD_PLATFORM value '$(BUILD_PLATFORM)' was not recognized!)
- endif
-endif
-
-# Fill in defaults if needed.
-ifndef BUILD_PLATFORM_ARCH
- ifeq ($(filter-out win64,$(BUILD_PLATFORM)),)
-  BUILD_PLATFORM_ARCH := amd64
- else
-  BUILD_PLATFORM_ARCH := x86
- endif
-endif
-ifndef BUILD_PLATFORM_CPU
- ifeq ($(filter-out amd64,$(BUILD_PLATFORM_ARCH)),)
-  BUILD_PLATFORM_CPU:= k8
- else
-  BUILD_PLATFORM_CPU:= i586
- endif
-endif
-
-
-#
-# Assert target platform.
+ BUILD_TYPE := release
+else
+ ifneq ($(filter $(BUILD_TYPE),$(KBUILD_OSES) $(KBUILD_ARCHES)),)
+  $(error kBuild: The BUILD_TYPE value '$(BUILD_TYPE)' is an OS or architecture!)
+ endif
+ ifneq (.$(words $(BUILD_TYPE)).$(BUILD_TYPE).,.1.$(strip $(BUILD_TYPE)).)
+  $(error kBuild: The BUILD_TYPE value '$(BUILD_TYPE)' contains spaces/tabs!)
+ endif
+endif
+
+
+#
+# Assert valid build platform variables.
+#
+# All these are set by kmk so they shouldn't be any trouble
+# unless the user starts messing about with environment variables.
+#
+ifneq (.$(words $(BUILD_PLATFORM)).$(BUILD_PLATFORM).,.1.$(strip $(BUILD_PLATFORM)).)
+ $(error kBuild: The BUILD_PLATFORM value '$(BUILD_PLATFORM)' contains spaces/tabs!)
+endif
+ifneq ($(words $(filter $(BUILD_PLATFORM),$(KBUILD_OSES))),1)
+ $(error kBuild: BUILD_PLATFORM value '$(BUILD_PLATFORM)' is not recognized (valid: $(KBUILD_OSES)))
+endif
+
+ifneq (.$(BUILD_PLATFORM_ARCH).,.$(strip $(BUILD_PLATFORM_ARCH)).)
+ $(error kBuild: The BUILD_PLATFORM_ARCH value '$(BUILD_PLATFORM_ARCH)' contains spaces/tabs!)
+endif
+ifneq ($(words $(filter $(BUILD_PLATFORM_ARCH),$(KBUILD_ARCHES))),1)
+ $(error kBuild: BUILD_PLATFORM_ARCH value '$(BUILD_PLATFORM_ARCH)' is not recognized (valid: $(KBUILD_ARCHES)))
+endif
+
+ifeq ($(strip $(BUILD_PLATFORM_CPU)),)
+ $(error kBuild: The BUILD_PLATFORM_CPU value is missing (should be set by kmk)!)
+endif
+ifneq (.$(words $(BUILD_PLATFORM_CPU)).$(BUILD_PLATFORM_CPU).,.1.$(strip $(BUILD_PLATFORM_CPU)).)
+ $(error kBuild: The BUILD_PLATFORM_CPU value '$(BUILD_PLATFORM_CPU)' contains spaces/tabs!)
+endif
+ifneq ($(filter $(BUILD_PLATFORM_CPU), $(KBUILD_OSES) $(BUILD_ARCHES)),)
+ $(error kBuild: The BUILD_PLATFORM_CPU value '$(BUILD_PLATFORM_CPU)' was found in the OS or architecture keywords!)
+endif
+ifeq ($(BUILD_PLATFORM_CPU),$(BUILD_TYPE))
+ $(error kBuild: The BUILD_PLATFORM_CPU value '$(BUILD_PLATFORM_CPU)' is the same as the BUILD_TYPE!)
+endif
+
+
+#
+# Assert or set default target platform.
+# When not defined use the corresponding BUILD_PLATFORM value.
 #
 ifndef BUILD_TARGET
-# not defined, set to the same as build platform
-BUILD_TARGET        := $(BUILD_PLATFORM)
-else
- BUILD_TARGET       := $(strip $(BUILD_TARGET))
- ifneq ($(words $(BUILD_TARGET))$(filter-out darwin freebsd l4 linux nt os2 solaris win win32 win64,$(BUILD_TARGET)),1)
-  # OS/2 (have uppercase legacy)
-  ifeq ($(BUILD_TARGET),OS2)
-   $(error kBuild: BUILD_TARGET must be all lowercase!)
-  endif
-  $(error kBuild: BUILD_TARGET value '$(BUILD_TARGET)' was not recognized!)
- endif
-endif
-
-# Fill in defaults if needed.
+ BUILD_TARGET := $(BUILD_PLATFORM)
+else
+ ifneq (.$(words $(BUILD_TARGET)).$(BUILD_TARGET).,.$(strip $(BUILD_TARGET)).)
+  $(error kBuild: The BUILD_TARGET value '$(BUILD_TARGET)' contains spaces/tabs!)
+ endif
+ ifneq ($(words $(filter $(BUILD_TARGET),$(KBUILD_OSES))),1)
+  $(error kBuild: BUILD_TARGET value '$(BUILD_TARGET)' is not recognized (valid: $(KBUILD_OSES)))
+ endif
+endif
+
 ifndef BUILD_TARGET_ARCH
- BUILD_TARGET_ARCH  := x86
-endif
+ BUILD_TARGET_ARCH := $(BUILD_PLATFORM_ARCH)
+else
+ ifneq (.$(BUILD_TARGET_ARCH).,.$(strip $(BUILD_TARGET_ARCH)).)
+  $(error kBuild: The BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)' contains spaces/tabs!)
+ endif
+ ifneq ($(words $(filter $(BUILD_TARGET_ARCH),$(KBUILD_ARCHES))),1)
+  $(error kBuild: BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)' is not recognized (valid: $(KBUILD_ARCHES)))
+ endif
+endif
+
 ifndef BUILD_TARGET_CPU
- BUILD_TARGET_CPU   := i586
-endif
-
-# Adjust the DEPTH definition first
-ifeq ($(strip $(DEPTH)),)
-DEPTH := .
-endif
-
-#
-# Common definitions.
-#
+ BUILD_TARGET_CPU := $(BUILD_PLATFORM_CPU)
+else
+ ifeq ($(strip $(BUILD_TARGET_CPU)),)
+  $(error kBuild: The BUILD_TARGET_CPU value is missing (should be set by kmk)!)
+ endif
+ ifneq (.$(words $(BUILD_TARGET_CPU)).$(BUILD_TARGET_CPU).,.1.$(strip $(BUILD_TARGET_CPU)).)
+  $(error kBuild: The BUILD_TARGET_CPU value '$(BUILD_TARGET_CPU)' contains spaces/tabs!)
+ endif
+ ifneq ($(filter $(BUILD_TARGET_CPU), $(KBUILD_OSES) $(BUILD_ARCHES)),)
+  $(error kBuild: The BUILD_TARGET_CPU value was found in the OS or architecture keywords!)
+ endif
+ ifeq ($(BUILD_TARGET_CPU),$(BUILD_TYPE))
+  $(error kBuild: The BUILD_TARGET_CPU value '$(BUILD_TARGET_CPU)' is the same as the BUILD_TYPE!)
+ endif
+endif
+
+
+#
+# Paths and stuff.
+#
+
+# Adjust DEPTH first.
+DEPTH := $(strip $(DEPTH))
+ifeq ($(DEPTH),)
+ DEPTH := .
+endif
+
 ## PATH_CURRENT is the current directory (getcwd).
 PATH_CURRENT        := $(abspath $(CURDIR))
@@ -202,4 +247,5 @@
 ## PATH_SUB_ROOT points to the directory of the top-level makefile.
 ifneq ($(strip $(SUB_DEPTH)),)
+ SUB_DEPTH          := $(strip $(SUB_DEPTH))
  PATH_SUB_ROOT      := $(abspath $(PATH_CURRENT)/$(SUB_DEPTH))
 else
@@ -235,9 +281,13 @@
 PATH_DOC             = $(PATH_INS)/doc
 
-# Usually kBuild is external to the source tree.
-ifndef PATH_KBUILD
- PATH_KBUILD        := $(PATH_ROOT)/kBuild
-endif
-PATH_KBUILD         := $(abspath $(PATH_KBUILD))
+# PATH_KBUILD is determined by kmk.
+ifeq ($(strip $(PATH_KBUILD)),)
+ $(error kBuild: PATH_KBUILD is missing or empty! kmk is supposed to set it.)
+endif
+# PATH_KBUILD_BIN is determined by kmk.
+ifeq ($(strip $(PATH_KBUILD_BIN)),)
+ $(error kBuild: PATH_KBUILD_BIN is missing or empty! kmk is supposed to set it.)
+endif
+
 # kBuild files which might be of interest.
 FILE_KBUILD_HEADER  := $(PATH_KBUILD)/header.kmk
@@ -245,5 +295,4 @@
 FILE_KBUILD_FOOTER  := $(PATH_KBUILD)/footer.kmk
 
-SUFF_DEP            := .dep
 ## MAKEFILE is the name of the main makefile.
 MAKEFILE            := $(firstword $(MAKEFILE_LIST))
@@ -254,25 +303,4 @@
 
 #
-# Check make version.
-#
-ifdef KMK_VERSION
- ifneq ($(KBUILD_VERSION_MAJOR).$(KBUILD_VERSION_MINOR),0.1)
-  ifneq ($(KBUILD_VERSION_MAJOR),0)
-   $(warning kBuild: kmk major version mismatch, expected '0' found '$(KBUILD_VERSION_MAJOR)'!)
-  else
-   $(warning kBuild: kmk minor version mismatch, expected '1' found '$(KBUILD_VERSION_MINOR)'!)
-  endif
- endif
-endif
-
-
-#
-# The revision in which this file was last modified.
-# This can be useful when using development versions of kBuild.
-#
-KMK_REVISION := $(patsubst %:,,  $Rev$  )
-
-
-#
 # Build platform setup.
 #
@@ -313,26 +341,9 @@
 endif
 
-ifndef PATH_KBUILD_BIN
- PATH_KBUILD_BIN    := $(PATH_KBUILD)/bin/$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)
- ifeq ($(wildcard $(PATH_KBUILD_BIN)/kmk_ash$(HOSTSUFF_EXE)),)
-  ifeq ($(BUILD_TARGET_ARCH),amd64)
-   PATH_KBUILD_BIN  := $(PATH_KBUILD)/bin/$(BUILD_PLATFORM).x86
-  endif
-  ifeq ($(wildcard $(PATH_KBUILD_BIN)/kmk_ash$(HOSTSUFF_EXE)),)
-   ifeq ($(filter-out win64 win32 win nt ,$(BUILD_PLATFORM)),)
-    PATH_KBUILD_BIN := $(PATH_KBUILD)/bin/win.x86
-   endif
-  endif
-  ifeq ($(wildcard $(PATH_KBUILD_BIN)/kmk_ash$(HOSTSUFF_EXE)),)
-   # give up
-   PATH_KBUILD_BIN  := $(PATH_KBUILD)/bin/$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)
-  endif
- endif
-endif
-
 
 #
 # Build target setup.
 #
+SUFF_DEP            := .dep
 ifeq ($(filter-out win32 win64 win nt os2,$(BUILD_TARGET)),)
 SUFF_OBJ            := .obj
@@ -371,7 +382,8 @@
 # Standard kBuild tools.
 #
-ifeq ($(MAKE),kmk)
-MAKE        := $(PATH_KBUILD_BIN)/kmk$(HOSTSUFF_EXE)
-endif
+ifeq ($(KMK),kmk)
+KMK         := $(PATH_KBUILD_BIN)/kmk$(HOSTSUFF_EXE)
+endif
+MAKE        := $(KMK)
 
 DEP_EXT     := $(PATH_KBUILD_BIN)/kDep$(HOSTSUFF_EXE)
@@ -397,86 +409,43 @@
 
 APPEND_EXT  := $(PATH_KBUILD_BIN)/kmk_append$(HOSTSUFF_EXE)
-ifeq ($(filter append,$(KMK_BUILTIN)),append)
 APPEND      := kmk_builtin_append
-else
-APPEND      := $(APPEND_EXT)
-endif
 
 CAT_EXT     := $(PATH_KBUILD_BIN)/kmk_cat$(HOSTSUFF_EXE)
-ifeq ($(filter cat,$(KMK_BUILTIN)),cat)
 CAT         := kmk_builtin_cat
-else
-CAT         := $(CAT_EXT)
-endif
 
 CP_EXT      := $(PATH_KBUILD_BIN)/kmk_cp$(HOSTSUFF_EXE)
-ifeq ($(filter cp,$(KMK_BUILTIN)),cp)
 CP          := kmk_builtin_cp
-else
-CP          := $(CP_EXT)
-endif
 
 ECHO_EXT    := $(PATH_KBUILD_BIN)/kmk_echo$(HOSTSUFF_EXE)
-ifeq ($(filter echo,$(KMK_BUILTIN)),echo)
 ECHO        := kmk_builtin_echo
-else
-ECHO        := $(ECHO_EXT)
-endif
 
 INSTALL_EXT := $(PATH_KBUILD_BIN)/kmk_install$(HOSTSUFF_EXE)
-ifeq ($(filter install,$(KMK_BUILTIN)),install)
 INSTALL     := kmk_builtin_install
-else
-INSTALL     := $(INSTALL_EXT)
-endif
 
 LN_EXT      := $(PATH_KBUILD_BIN)/kmk_ln$(HOSTSUFF_EXE)
-ifeq ($(filter ln,$(KMK_BUILTIN)),ln)
 LN          := kmk_builtin_ln
-else
-LN          := $(LN_EXT)
-endif
 
 MKDIR_EXT   := $(PATH_KBUILD_BIN)/kmk_mkdir$(HOSTSUFF_EXE)
-ifeq ($(filter mkdir,$(KMK_BUILTIN)),mkdir)
 MKDIR       := kmk_builtin_mkdir
-else
-MKDIR       := $(MKDIR_EXT)
-endif
 
 MV_EXT      := $(PATH_KBUILD_BIN)/kmk_mv$(HOSTSUFF_EXE)
-ifeq ($(filter mv,$(KMK_BUILTIN)),mv)
 MV          := kmk_builtin_mv
-else
-MV          := $(MV_EXT)
-endif
 
 PRINTF_EXT  := $(PATH_KBUILD_BIN)/kmk_printf$(HOSTSUFF_EXE)
-ifeq ($(filter printf,$(KMK_BUILTIN)),printf)
 PRINTF      := kmk_builtin_printf
-else
-PRINTF      := $(PRINTF_EXT)
-endif
 
 RM_EXT      := $(PATH_KBUILD_BIN)/kmk_rm$(HOSTSUFF_EXE)
-ifeq ($(filter rm,$(KMK_BUILTIN)),rm)
 RM          := kmk_builtin_rm
-else
-RM          := $(RM_EXT)
-endif
 
 RMDIR_EXT   := $(PATH_KBUILD_BIN)/kmk_rmdir$(HOSTSUFF_EXE)
-ifeq ($(filter rmdir,$(KMK_BUILTIN)),rmdir)
 RMDIR       := kmk_builtin_rmdir
-else
-RMDIR       := $(RMDIR_EXT)
-endif
 
 SED_EXT     := $(PATH_KBUILD_BIN)/kmk_sed$(HOSTSUFF_EXE)
 ifeq ($(filter sed,$(KMK_BUILTIN)),sed)
-SED         := kmk_builtin_sed
-else
+SED_INT     := kmk_builtin_sed
+else
+SED_INT     := $(SED_EXT)
+endif
 SED         := $(SED_EXT)
-endif
 
 # Our default shell is the Almquist shell from *BSD.
@@ -517,14 +486,4 @@
 else
  CYGPATHMIXED = $(1)
-endif
-
-ifneq ($(filter xargs,$(KMK_FEATURES)),xargs) ## @todo Retire this to gnumake-header.kmk when it has been implemented.
-##
-# Fake xargs without doing any commandline splitting.
-# @param    $1      The initial command.
-# @param    $2      The command for the subseqent command lines. optional
-# @param    $3		The command for the final command lines. optional
-# @param    $($#)   The arguments.
-xargs = $(1) $(if $(4),$(4),$(if $(3),$(3),$(2)))
 endif
 
@@ -745,12 +704,4 @@
 
 #
-# Include the gnumake header hacks if we're not using kmk.
-#
-ifndef KMK_VERSION
- include $(PATH_KBUILD)/gnumake-header.kmk
-endif
-
-
-#
 # This is how we find the closest config.kmk.
 # It's a little hacky but I think it works fine.
@@ -771,4 +722,5 @@
 $(error kBuild: no Config.kmk file found! Check the DEPTH: DEPTH='$(DEPTH)' PATH_CURRENT='$(PATH_CURRENT)')
 endif
+
 
 #
@@ -955,3 +907,2 @@
 endif # __header_kmk__
 
-
