Index: /trunk/kBuild/footer.kmk
===================================================================
--- /trunk/kBuild/footer.kmk	(revision 742)
+++ /trunk/kBuild/footer.kmk	(revision 743)
@@ -143,27 +143,4 @@
 	$(TOOL) \
 	))
-
-## Removes the drive letter from a path (if it has one)
-# @param	$1 		the path
-no-drive=$(word $(words	$(subst :, ,$(1))),$(subst :, ,$(1)))
-
-## Removes the root slash from a path (if it has one)
-# @param	$1 		the path
-no-root-slash=$(patsubst /%,%,$(1))
-
-ifneq ($(filter abspathex,$(KMK_FEATURES)),abspathex) ## @todo Retire this to gnumake-header.kmk when it has been implemented.
-## 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))))
-endif
-
-## Figure out where to put object files.
-# @param    $1      real target name.
-# @param    $2      normalized main target
-_TARGET_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(basename $(1))))
-
 
 ## Figure out the actual name of an installed file.
@@ -887,5 +864,5 @@
 $(out): $(comp-vars _TARGET_$(target)_DIGEST_PREV,_TARGET_$(target)_DIGEST,FORCE) | $(call DIRDEP,$(inst))
 	$$(QUIET)$$(RM) -f $$@
-	$$(call MSG_L1,$$(if $$(wildcard $(out).lst),$$(if $$(_TARGET_$(target)_DIGEST),Re-fetching,Removing),Fetching) $(target)...)
+	$$(call MSG_L1,$$(if $$(_TARGET_$(target)_DIGEST),$$(if $$(wildcard $(out).lst),Re-fetching,Fetching),Removing) $(target)...)
 	$$(QUIET)$$(if $$(wildcard $(out).lst      ),$$(MAKE) -f $(MAKEFILE) --no-print-directory $(out)_unfetched)
 	$$(QUIET)$$(if  $$(_TARGET_$(target)_DIGEST),$$(MAKE) -f $(MAKEFILE) --no-print-directory $(out).lst,$$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist $$(dir $$@))
@@ -1172,6 +1149,12 @@
 $(error kBuild: Library target $(target) does not have a tool defined!)
 endif
-outbase     := $(call _TARGET_BASE,$(target),$(target))
-PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
+outbase     := $(call TARGET_BASE,$(target),$(target))
+ifndef PATH_$(target)
+ PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
+else
+ ifneq ($(PATH_$(target)),$(patsubst %/,%,$(dir $(outbase))))
+  $(error kBuild internal error: PATH_$(target)=$(PATH_$(target)) expected $(patsubst %/,%,$(dir $(outbase))))
+ endif
+endif
 suff        := $(firstword\
 	$($(target)_LIBSUFF.$(bld_trg).$(bld_trg_arch))\
@@ -1192,5 +1175,5 @@
 # library linking
 tool        := $(call _TARGET_TOOL,$(target),AR)
-outbase     := $(call _TARGET_BASE,$(target),$(target))
+outbase     := $(call TARGET_BASE,$(target),$(target))
 flags       :=\
 	$(TOOL_$(tool)_ARFLAGS)\
@@ -1294,5 +1277,12 @@
 
 tool        := $(call _TARGET_TOOL,$(target),LD)
-outbase     := $(call _TARGET_BASE,$(target),$(target))
+outbase     := $(call TARGET_BASE,$(target),$(target))
+ifndef PATH_$(target)
+ PATH_$(target) := $(patsubst %/,%,$(dir $(outbase)))
+else
+ ifneq ($(PATH_$(target)),$(patsubst %/,%,$(dir $(outbase))))
+  $(error kBuild internal error: PATH_$(target)=$(PATH_$(target)) expected $(patsubst %/,%,$(dir $(outbase))))
+ endif
+endif
 suff        := $(firstword \
 	$($(target)_$(EXT)SUFF) \
@@ -1301,5 +1291,4 @@
 	$($(EXTPRE)SUFF_$(EXT)))
 out         := $(outbase)$(suff)
-PATH_$(target)   := $(patsubst %/,%,$(dir $(outbase)))
 TARGET_$(target) := $(out)
 $(target)_OBJS_  :=
@@ -1311,5 +1300,5 @@
 # more library stuff.
 tool        := $(call _TARGET_TOOL,$(target),LD)
-outbase     := $(call _TARGET_BASE,$(target),$(target))
+outbase     := $(call TARGET_BASE,$(target),$(target))
 flags       :=\
 	$(TOOL_$(tool)_LDFLAGS)\
Index: /trunk/kBuild/gnumake-header.kmk
===================================================================
--- /trunk/kBuild/gnumake-header.kmk	(revision 742)
+++ /trunk/kBuild/gnumake-header.kmk	(revision 743)
@@ -33,7 +33,31 @@
 $(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))
+
 
 #
-# Default variables.
+# Fix some default variables.
 #
 ifeq ($(MAKEFLAGS),$(MAKEFLAGS:R=x))
@@ -54,5 +78,5 @@
 
 #
-# Suffixes.
+# Zap suffixes.
 #
 .SUFFIXES:
@@ -60,5 +84,5 @@
 
 #
-# Implicit rules
+# Zap implicit rules
 #
 ifeq ($(MAKEFLAGS),$(MAKEFLAGS:r=x))
Index: /trunk/kBuild/header.kmk
===================================================================
--- /trunk/kBuild/header.kmk	(revision 742)
+++ /trunk/kBuild/header.kmk	(revision 743)
@@ -441,4 +441,10 @@
 LN_SYMLINK  := $(LN) -s
 
+
+#
+# Some Functions.
+# The lower cased ones are either fallbacks or candidates for functions.c. 
+#
+
 ## ABSPATH - make paths absolute.
 # This implementation is clumsy and doesn't resolve '..' and '.' components.
@@ -453,5 +459,4 @@
 DIRDEP = $(foreach path,$(patsubst %/,%,$(1)),$(path)/)
 
-
 ## Cygwin kludge.
 # This converts /cygdrive/x/% to x:%.
@@ -460,36 +465,35 @@
 # @remark	This macro is pretty much obsolete since we don't use cygwin base make.
 ifneq ($(patsubst /cygdrive/%,%,$(CURDIR)),$(CURDIR))
-CYGPATHMIXED = $(foreach path,$(1)\
+ CYGPATHMIXED = $(foreach path,$(1)\
    ,$(if $(patsubst /cygdrive/%,,$(path)),$(path),$(patsubst $(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path)))))/%,$(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path))))):/%,$(patsubst /cygdrive/%,%,$(path)))))
 else
-CYGPATHMIXED = $(1)
-endif
-
-
-ifneq ($(filter stack,$(KMK_FEATURES)),stack) ## @todo retire this to gnumake-header.kmk when all the programs have been recompiled.
-##
-# 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))
-endif
+ CYGPATHMIXED = $(1)
+endif
+
+ifneq ($(filter abspathex,$(KMK_FEATURES)),abspathex) ## @todo Retire this to gnumake-header.kmk when it has been implemented.
+## 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))))
+endif
+
+## Removes the drive letter from a path (if it has one)
+# @param	$1 		the path
+no-drive    = $(word $(words $(subst :, ,$(1))),$(subst :, ,$(1)))
+
+## Removes the root slash from a path (if it has one)
+# @param	$1 		the path
+no-root-slash = $(patsubst /%,%,$(1))
+
+## Figure out where to put object files.
+# @param    $1      real target name.
+# @param    $2      normalized main target
+TARGET_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(basename $(1))))
+
+## Figure out where to put object files.
+# @param    $1      normalized main target
+TARGET_PATH = $(PATH_TARGET)/$(1)
 
 
Index: /trunk/kBuild/subfooter.kmk
===================================================================
--- /trunk/kBuild/subfooter.kmk	(revision 742)
+++ /trunk/kBuild/subfooter.kmk	(revision 743)
@@ -29,5 +29,5 @@
 #
 ifdef __footer_kmk__
-$(error kBuild: footer.kmk has already been included. Fix your sub-makefiles!)
+ $(error kBuild: footer.kmk has already been included. Fix your sub-makefiles!)
 endif
 
@@ -36,10 +36,13 @@
 #
 define def_subheader
-ifndef $(target)_PATH
-$(target)_PATH := $(PATH_SUB_CURRENT)
-endif
-ifndef $(target)_MAKEFILE
-$(target)_MAKEFILE := $(MAKEFILE_CURRENT)
-endif
+ ifndef $(target)_PATH
+  $(target)_PATH := $(PATH_SUB_CURRENT)
+ endif
+ ifndef $(target)_MAKEFILE
+  $(target)_MAKEFILE := $(MAKEFILE_CURRENT)
+ endif
+ ifndef PATH_$(target)
+  PATH_$(target) := $(call TARGET_PATH,$(target))
+ endif
 endef
 
Index: /trunk/kBuild/subheader.kmk
===================================================================
--- /trunk/kBuild/subheader.kmk	(revision 742)
+++ /trunk/kBuild/subheader.kmk	(revision 743)
@@ -46,10 +46,13 @@
  #
  define def_subfooter
- ifndef $(target)_PATH
- $(target)_PATH := $(PATH_SUB_CURRENT)
- endif
- ifndef $(target)_MAKEFILE
- $(target)_MAKEFILE := $(MAKEFILE_CURRENT)
- endif
+  ifndef $(target)_PATH
+   $(target)_PATH := $(PATH_SUB_CURRENT)
+  endif
+  ifndef $(target)_MAKEFILE
+   $(target)_MAKEFILE := $(MAKEFILE_CURRENT)
+  endif
+  ifndef PATH_$(target)
+   PATH_$(target) := $(call TARGET_PATH,$(target))
+  endif
  endef
 
