Index: trunk/src/Makefile.kmk
===================================================================
--- trunk/src/Makefile.kmk	(revision 1643)
+++ trunk/src/Makefile.kmk	(revision 1665)
@@ -1,5 +1,5 @@
 # $Id$
 ## @file
-# Makefile for the source directory.
+# Sub-makefile for the source directory.
 #
 
@@ -25,12 +25,16 @@
 #
 
-DEPTH = ..
-include $(PATH_KBUILD)/header.kmk
+SUB_DEPTH = ..
+include $(KBUILD_PATH)/subheader.kmk
 
-SUBDIRS = lib kmk sed kDepPre kObjCache
+include $(PATH_SUB_CURRENT)/lib/Makefile.kmk
+include $(PATH_SUB_CURRENT)/kmk/Makefile.kmk
+include $(PATH_SUB_CURRENT)/sed/Makefile.kmk
+include $(PATH_SUB_CURRENT)/kDepPre/Makefile.kmk
+include $(PATH_SUB_CURRENT)/kObjCache/Makefile.kmk
 ifneq ($(KBUILD_TARGET),win)
-SUBDIRS += ash
+ include $(PATH_SUB_CURRENT)/ash/Makefile.kmk
 endif
 
-include $(FILE_KBUILD_FOOTER)
+include $(FILE_KBUILD_SUB_FOOTER)
 
Index: trunk/src/ash/Makefile.kmk
===================================================================
--- trunk/src/ash/Makefile.kmk	(revision 1643)
+++ trunk/src/ash/Makefile.kmk	(revision 1665)
@@ -1,5 +1,5 @@
 # $Id: Makefile.kmk 785 2007-01-24 22:21:56Z bird $
 ## @file
-# ash
+# Sub-makefile for kmk_ash.
 #
 
@@ -25,6 +25,6 @@
 #
 
-DEPTH = ../..
-include $(PATH_KBUILD)/header.kmk
+SUB_DEPTH = ../..
+include $(KBUILD_PATH)/subheader.kmk
 
 #INSTALLS = ash.man
@@ -46,6 +46,6 @@
 kmk_ash_DEFS.freebsd = \
 	HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME
-kmk_ash_INCS = $(PATH_TARGET) . # (the last is because of error.h)
-kmk_ash_CFLAGS.win = -I. ## @todo kBuild bug.
+kmk_ash_INCS = $(PATH_kmk_ash) . # (the last is because of error.h)
+kmk_ash_CFLAGS.win = -I. ## @todo kBuild bug?
 kmk_ash_INCS.win = win
 kmk_ash_SOURCES = \
@@ -75,8 +75,8 @@
 	bltin/kill.c \
 	bltin/test.c \
-	$(PATH_TARGET)/arith.c \
-	$(PATH_TARGET)/builtins.c \
-	$(PATH_TARGET)/init.c \
-	$(PATH_TARGET)/nodes.c
+	$(PATH_kmk_ash)/arith.c \
+	$(PATH_kmk_ash)/builtins.c \
+	$(PATH_kmk_ash)/init.c \
+	$(PATH_kmk_ash)/nodes.c
 kmk_ash_SOURCES.linux = \
 	sys_signame.c \
@@ -96,15 +96,15 @@
 
 kmk_ash_INTERMEDIATES = \
-	$(PATH_TARGET)/arith.h \
-	$(PATH_TARGET)/builtins.h \
-	$(PATH_TARGET)/nodes.h \
-	$(PATH_TARGET)/token.h
+	$(PATH_kmk_ash)/arith.h \
+	$(PATH_kmk_ash)/builtins.h \
+	$(PATH_kmk_ash)/nodes.h \
+	$(PATH_kmk_ash)/token.h
 kmk_ash_CLEAN = \
 	$(kmk_ash_INTERMEDIATES) \
-	$(PATH_TARGET)/arith.c \
-	$(PATH_TARGET)/arith_lex.c \
-	$(PATH_TARGET)/builtins.c \
-	$(PATH_TARGET)/init.c \
-	$(PATH_TARGET)/nodes.c
+	$(PATH_kmk_ash)/arith.c \
+	$(PATH_kmk_ash)/arith_lex.c \
+	$(PATH_kmk_ash)/builtins.c \
+	$(PATH_kmk_ash)/init.c \
+	$(PATH_kmk_ash)/nodes.c
 
 kmk_ash.man_TEMPLATE = usr.bin.man
@@ -115,16 +115,16 @@
 
 if1of ($(KBUILD_TARGET), win nt)
-
 #
 # Use the pregenerated code.
 #
 kmk_ash_DEPS :=
-kmk_ash_SOURCES += $(PATH_TARGET)/arith_lex.c
+kmk_ash_SOURCES += $(PATH_kmk_ash)/arith_lex.c
+
+include $(FILE_KBUILD_SUB_FOOTER)
 
 define def_copy_generated
-$(PATH_TARGET)/$(src): generated/$(src)
+$(PATH_kmk_ash)/$(src): generated/$(src)
 	$$(RM) -f $$@
 	$$(CP) -f $$^ $$@
-kmk_ash_DEPS += $(PATH_TARGET)/$(src)
 endef
 
@@ -132,7 +132,9 @@
 $(eval $(def_copy_generated)))
 
-include $(FILE_KBUILD_FOOTER)
 
 else
+#
+# Generate the code on the fly.
+#
 
 ifeq (1,2) #disabled for now.
@@ -142,8 +144,8 @@
 kmk_ash_LEXFLAGS = -8
 else
-kmk_ash_SOURCES += $(PATH_TARGET)/arith_lex.c
+kmk_ash_SOURCES += $(PATH_kmk_ash)/arith_lex.c
 endif
 
-include $(FILE_KBUILD_FOOTER)
+include $(FILE_KBUILD_SUB_FOOTER)
 
 #
@@ -160,29 +162,40 @@
 endif
 
-$(PATH_TARGET)/arith.h + $(PATH_TARGET)/arith.c: arith.y | $(call DIRDEP,$(PATH_TARGET))
+$(PATH_kmk_ash)/arith.h + $(PATH_kmk_ash)/arith.c: $(kmk_ash_PATH)/arith.y | $(call DIRDEP,$(PATH_kmk_ash))
 	$(YACC) -ld $^
-	$(MV) -f y.tab.c $(PATH_TARGET)/arith.c
-	$(MV) -f y.tab.h $(PATH_TARGET)/arith.h
+	$(MV) -f y.tab.c $(PATH_kmk_ash)/arith.c
+	$(MV) -f y.tab.h $(PATH_kmk_ash)/arith.h
 
 ifndef kmk_ash_LEXTOOL
-$(PATH_TARGET)/arith_lex.c: arith_lex.l | $(call DIRDEP,$(PATH_TARGET))
+$(PATH_kmk_ash)/arith_lex.c: $(kmk_ash_PATH)/arith_lex.l | $(call DIRDEP,$(PATH_kmk_ash))
 	flex -8 -o$@ $^                     # 8-bit lex scanner for arithmetic
 endif
 
-$(PATH_TARGET)/builtins.h + $(PATH_TARGET)/builtins.c: $(PATH_CURRENT)/mkbuiltins shell.h builtins.def | $(call DIRDEP,$(PATH_TARGET))
+$(PATH_kmk_ash)/builtins.h + $(PATH_kmk_ash)/builtins.c: \
+		$(kmk_ash_PATH)/mkbuiltins \
+		$(kmk_ash_PATH)/shell.h \
+		$(kmk_ash_PATH)/builtins.def \
+		| $(call DIRDEP,$(PATH_kmk_ash))
 	$(BOOTSTRAP_SHELL) $+ $(dir $@)
-	[ -f $(PATH_TARGET)/builtins.h ]
-
-$(PATH_TARGET)/nodes.h + $(PATH_TARGET)/nodes.c: $(PATH_CURRENT)/mknodes.sh nodetypes nodes.c.pat | $(call DIRDEP,$(PATH_TARGET))
+	[ -f $(PATH_kmk_ash)/builtins.h ]
+
+$(PATH_kmk_ash)/nodes.h + $(PATH_kmk_ash)/nodes.c: \
+		$(kmk_ash_PATH)/mknodes.sh \
+		$(kmk_ash_PATH)/nodetypes \
+		$(kmk_ash_PATH)/nodes.c.pat \
+		| $(call DIRDEP,$(PATH_kmk_ash))
 	$(BOOTSTRAP_SHELL) $+ $(dir $@)
 	[ -f $(dir $@)/nodes.h ]
 
-$(PATH_TARGET)/token.h: $(PATH_CURRENT)/mktokens | $(call DIRDEP,$(PATH_TARGET))
+$(PATH_kmk_ash)/token.h: $(kmk_ash_PATH)/mktokens | $(call DIRDEP,$(PATH_kmk_ash))
 	$(BOOTSTRAP_SHELL) $+
 	$(MV) token.h $@
 
-$(PATH_TARGET)/init.c: $(PATH_CURRENT)/mkinit.sh $(filter-out $(PATH_TARGET)/%,$(kmk_ash_SOURCES)) | $(call DIRDEP,$(PATH_TARGET))
+$(PATH_kmk_ash)/init.c: \
+		$(kmk_ash_PATH)/mkinit.sh \
+		$(abspathex $(filter-out $(PATH_kmk_ash)/%,$(kmk_ash_SOURCES)), $(kmk_ash_PATH)) \
+		| $(call DIRDEP,$(PATH_kmk_ash))
 	$(BOOTSTRAP_SHELL) $+
 	$(MV) init.c $@
 
-endif
+endif # generate on the fly
Index: trunk/src/fastdep/Makefile.kmk
===================================================================
--- trunk/src/fastdep/Makefile.kmk	(revision 1643)
+++ trunk/src/fastdep/Makefile.kmk	(revision 1665)
@@ -1,5 +1,5 @@
 # $Id: Makefile.kmk 785 2007-01-24 22:21:56Z bird $
 ## @file
-# Testing the VAC308 tool / ancient dependency generator.
+# Sub-makefile for testing the VAC308 tool / ancient dependency generator.
 #
 
@@ -25,6 +25,6 @@
 #
 
-DEPTH = ../..
-include $(PATH_KBUILD)/header.kmk
+SUB_DEPTH = ../..
+include $(KBUILD_PATH)/subheader.kmk
 
 
@@ -55,4 +55,4 @@
 
 
-include $(FILE_KBUILD_FOOTER)
+include $(FILE_KBUILD_SUB_FOOTER)
 
Index: trunk/src/kDepPre/Makefile.kmk
===================================================================
--- trunk/src/kDepPre/Makefile.kmk	(revision 1643)
+++ trunk/src/kDepPre/Makefile.kmk	(revision 1665)
@@ -1,5 +1,5 @@
 # $Id$
 ## @file
-# kDepPre - Precompiler base dependency generator.
+# Sub-makefile for kDepPre, the precompiler based dependency generator.
 #
 
@@ -25,6 +25,6 @@
 #
 
-DEPTH = ../..
-include $(PATH_KBUILD)/header.kmk
+SUB_DEPTH = ../..
+include $(KBUILD_PATH)/subheader.kmk
 
 PROGRAMS += kDepPre
@@ -35,5 +35,6 @@
 kDepPre_DEFS           += NEED_ISBLANK=1 __WIN32__=1
 endif
-kDepPre_SOURCES         = $(PATH_CURRENT)/kDepPre.c
+kDepPre_SOURCES         = kDepPre.c
 
-include $(FILE_KBUILD_FOOTER)
+include $(FILE_KBUILD_SUB_FOOTER)
+
Index: trunk/src/kObjCache/Makefile.kmk
===================================================================
--- trunk/src/kObjCache/Makefile.kmk	(revision 1643)
+++ trunk/src/kObjCache/Makefile.kmk	(revision 1665)
@@ -1,5 +1,5 @@
 # $Id: Makefile.kmk 785 2007-01-24 22:21:56Z bird $
 ## @file
-# kObjCache
+# Sub-makefile for kObjCache.
 #
 
@@ -25,6 +25,5 @@
 #
 
-DEPTH ?= ../..
-#SUB_DEPTH = ../..
+SUB_DEPTH = ../..
 include $(PATH_KBUILD)/subheader.kmk
 
Index: trunk/src/kash/Makefile.kmk
===================================================================
--- trunk/src/kash/Makefile.kmk	(revision 1643)
+++ trunk/src/kash/Makefile.kmk	(revision 1665)
@@ -1,5 +1,5 @@
 # $Id$
 ## @file
-# kBuild Makefile for kash.
+# Sub-makefile for kash.
 #
 
@@ -25,6 +25,6 @@
 #
 
-DEPTH = ../..
-include $(PATH_KBUILD)/header.kmk
+SUB_DEPTH = ../..
+include $(KBUILD_PATH)/subheader.kmk
 
 #
@@ -49,5 +49,5 @@
 kash_DEFS.freebsd = \
 	HAVE_SYS_SIGNAME HAVE_SYSCTL_H HAVE_SETPROGNAME
-kash_INCS = $(PATH_TARGET) . # (the last is because of error.h)
+kash_INCS = $(PATH_kash) . # (the last is because of error.h)
 kash_SOURCES = \
 	main.c \
@@ -77,9 +77,9 @@
 	bltin/test.c \
 	\
-	$(PATH_TARGET)/arith.c \
-	$(PATH_TARGET)/arith_lex.c \
-	$(PATH_TARGET)/builtins.c \
-	$(PATH_TARGET)/init.c \
-	$(PATH_TARGET)/nodes.c \
+	$(PATH_kash)/arith.c \
+	$(PATH_kash)/arith_lex.c \
+	$(PATH_kash)/builtins.c \
+	$(PATH_kash)/init.c \
+	$(PATH_kash)/nodes.c \
 	\
 	setmode.c \
@@ -98,15 +98,15 @@
 
 kash_ORDERDEPS = \
-	$(PATH_TARGET)/arith.h \
-	$(PATH_TARGET)/builtins.h \
-	$(PATH_TARGET)/nodes.h \
-	$(PATH_TARGET)/token.h
+	$(PATH_kash)/arith.h \
+	$(PATH_kash)/builtins.h \
+	$(PATH_kash)/nodes.h \
+	$(PATH_kash)/token.h
 kash_CLEAN = \
 	$(kash_ORDERDEPS)	\
-	$(PATH_TARGET)/arith.c \
-	$(PATH_TARGET)/arith_lex.c \
-	$(PATH_TARGET)/builtins.c \
-	$(PATH_TARGET)/init.c \
-	$(PATH_TARGET)/nodes.c
+	$(PATH_kash)/arith.c \
+	$(PATH_kash)/arith_lex.c \
+	$(PATH_kash)/builtins.c \
+	$(PATH_kash)/init.c \
+	$(PATH_kash)/nodes.c
 
 ##
@@ -125,11 +125,11 @@
 kash_ORDERDEPS :=
 kash_INCS += generated
-kash_SOURCES := $(patsubst $(PATH_TARGET)/%,generated/%,$(kash_SOURCES))
+kash_SOURCES := $(patsubst $(PATH_kash)/%,generated/%,$(kash_SOURCES))
 
-include $(FILE_KBUILD_FOOTER)
+include $(FILE_KBUILD_SUB_FOOTER)
 
 else
 
-include $(FILE_KBUILD_FOOTER)
+include $(FILE_KBUILD_SUB_FOOTER)
 
 #
@@ -144,25 +144,25 @@
 YACC ?= yacc
 
-$(PATH_TARGET)/arith.h $(PATH_TARGET)/arith.c: arith.y | $(call DIRDEP,$(PATH_TARGET))
+$(PATH_kash)/arith.h $(PATH_kash)/arith.c: arith.y | $(call DIRDEP,$(PATH_kash))
 	$(YACC) -ld $^
-	$(MV) -f y.tab.c $(PATH_TARGET)/arith.c
-	$(MV) -f y.tab.h $(PATH_TARGET)/arith.h
+	$(MV) -f y.tab.c $(PATH_kash)/arith.c
+	$(MV) -f y.tab.h $(PATH_kash)/arith.h
 
-$(PATH_TARGET)/arith_lex.c: arith_lex.l | $(call DIRDEP,$(PATH_TARGET))
+$(PATH_kash)/arith_lex.c: arith_lex.l | $(call DIRDEP,$(PATH_kash))
 	flex -8 -o$@ $^                     # 8-bit lex scanner for arithmetic
 
-$(PATH_TARGET)/builtins.h $(PATH_TARGET)/builtins.c: $(PATH_CURRENT)/mkbuiltins shell.h builtins.def | $(call DIRDEP,$(PATH_TARGET))
+$(PATH_kash)/builtins.h $(PATH_kash)/builtins.c: $(kash_PATH)/mkbuiltins shell.h builtins.def | $(call DIRDEP,$(PATH_kash))
 	$(BOOTSTRAP_SHELL) $+ $(dir $@)
-	[ -f $(PATH_TARGET)/builtins.h ]
+	[ -f $(PATH_kash)/builtins.h ]
 
-$(PATH_TARGET)/nodes.h $(PATH_TARGET)/nodes.c: $(PATH_CURRENT)/mknodes.sh nodetypes nodes.c.pat | $(call DIRDEP,$(PATH_TARGET))
+$(PATH_kash)/nodes.h $(PATH_kash)/nodes.c: $(kash_PATH)/mknodes.sh nodetypes nodes.c.pat | $(call DIRDEP,$(PATH_kash))
 	$(BOOTSTRAP_SHELL) $+ $(dir $@)
 	[ -f $(dir $@)/nodes.h ]
 
-$(PATH_TARGET)/token.h: $(PATH_CURRENT)/mktokens | $(call DIRDEP,$(PATH_TARGET))
+$(PATH_kash)/token.h: $(kash_PATH)/mktokens | $(call DIRDEP,$(PATH_kash))
 	$(BOOTSTRAP_SHELL) $+
 	$(MV) token.h $@
 
-$(PATH_TARGET)/init.c: $(PATH_CURRENT)/mkinit.sh $(filter-out $(PATH_TARGET)/%,$(kash_SOURCES)) | $(call DIRDEP,$(PATH_TARGET))
+$(PATH_kash)/init.c: $(kash_PATH)/mkinit.sh $(filter-out $(PATH_kash)/%,$(kash_SOURCES)) | $(call DIRDEP,$(PATH_kash))
 	$(BOOTSTRAP_SHELL) $+
 	$(MV) init.c $@
Index: trunk/src/kmk/Makefile.kmk
===================================================================
--- trunk/src/kmk/Makefile.kmk	(revision 1643)
+++ trunk/src/kmk/Makefile.kmk	(revision 1665)
@@ -1,5 +1,5 @@
 # $Id$
 ## @file
-# kmk / GNU Make
+# Sub-makefile for kmk / GNU Make.
 #
 
@@ -25,7 +25,6 @@
 #
 
-
-DEPTH = ../..
-include $(PATH_KBUILD)/header.kmk
+SUB_DEPTH = ../..
+include $(KBUILD_PATH)/subheader.kmk
 
 
@@ -39,21 +38,21 @@
 	$(TEMPLATE_BIN_DEFS) \
 	KBUILD_SVN_REV=$(KBUILD_SVN_REV)
-TEMPLATE_BIN-KMK_DEPS = $(PATH_TARGET)/config.h
+TEMPLATE_BIN-KMK_DEPS = $(PATH_kmk)/config.h
 TEMPLATE_BIN-KMK_CLEAN = $(TEMPLATE_BIN-KMK_DEPS)
 TEMPLATE_BIN-KMK_DEPS.solaris = \
-	$(PATH_TARGET)/fts.h \
-	$(PATH_TARGET)/paths.h
+	$(PATH_kmk)/fts.h \
+	$(PATH_kmk)/paths.h
 TEMPLATE_BIN-KMK_CLEAN.solaris = $(TEMPLATE_BIN-KMK_DEPS.solaris)
 TEMPLATE_BIN-KMK_DEPS.win     = \
-	$(PATH_TARGET)/fts.h \
-	$(PATH_TARGET)/sysexits.h \
-	$(PATH_TARGET)/unistd.h \
-	$(PATH_TARGET)/paths.h \
-	$(PATH_TARGET)/grp.h \
-	$(PATH_TARGET)/pwd.h \
-	$(PATH_TARGET)/inttypes.h
+	$(PATH_kmk)/fts.h \
+	$(PATH_kmk)/sysexits.h \
+	$(PATH_kmk)/unistd.h \
+	$(PATH_kmk)/paths.h \
+	$(PATH_kmk)/grp.h \
+	$(PATH_kmk)/pwd.h \
+	$(PATH_kmk)/inttypes.h
 TEMPLATE_BIN-KMK_CFLAGS.win.amd64 = $(TEMPLATE_BIN_CFLAGS.win.amd64) -wd4244 -wd4267
 TEMPLATE_BIN-KMK_CLEAN.win = $(TEMPLATE_BIN-KMK_DEPS.win)
-TEMPLATE_BIN-KMK_INCS = $(PATH_TARGET) . $(TEMPLATE_BIN_INCS)
+TEMPLATE_BIN-KMK_INCS = $(PATH_kmk) . $(TEMPLATE_BIN_INCS)
 TEMPLATE_BIN-KMK_INCS.darwin = glob
 TEMPLATE_BIN-KMK_INCS.dragonfly = glob
@@ -63,7 +62,7 @@
 ifdef ELECTRIC_HEAP # for electric heap (see electric.c) - windows only.
 ifeq ($(KBUILD_TARGET),win)
- TEMPLATE_BIN-KMK_CFLAGS = $(TEMPLATE_BIN_CFLAGS) /FI$(PATH_CURRENT)/electric.h -DELECTRIC_HEAP=1
+ TEMPLATE_BIN-KMK_CFLAGS = $(TEMPLATE_BIN_CFLAGS) /FI$(kmk_PATH)/electric.h -DELECTRIC_HEAP=1
 else
- TEMPLATE_BIN-KMK_CFLAGS = $(TEMPLATE_BIN_CFLAGS) -include $(PATH_CURRENT)/electric.h -DELECTRIC_HEAP=1
+ TEMPLATE_BIN-KMK_CFLAGS = $(TEMPLATE_BIN_CFLAGS) -include $(kmk_PATH)/electric.h -DELECTRIC_HEAP=1
 endif
 endif
@@ -377,5 +376,5 @@
 
 
-include $(FILE_KBUILD_FOOTER)
+include $(FILE_KBUILD_SUB_FOOTER)
 
 
@@ -383,6 +382,6 @@
 # Use checked in config.h instead of running ./Configure for it.
 #
-config.h.$(KBUILD_TARGET) := config.h.$(KBUILD_TARGET)
-$(PATH_TARGET)/config.h: $(config.h.$(KBUILD_TARGET))
+kmk_config.h.$(KBUILD_TARGET) := $(kmk_PATH)/config.h.$(KBUILD_TARGET)
+$(PATH_kmk)/config.h: $(kmk_config.h.$(KBUILD_TARGET))
 	$(MKDIR) -p $(dir $@)
 	$(CP) $^ $@
@@ -391,23 +390,23 @@
 # Some missing headers.
 #
-$(PATH_TARGET)/fts.h: kmkbuiltin/ftsfake.h | $(call DIRDEP,$(PATH_TARGET))
+$(PATH_kmk)/fts.h: kmkbuiltin/ftsfake.h | $(call DIRDEP,$(PATH_kmk))
 	$(CP) $^ $@
 
-$(PATH_TARGET)/unistd.h: | $(call DIRDEP,$(PATH_TARGET))
-	$(ECHO_EXT) > $@
-
-$(PATH_TARGET)/sysexits.h: | $(call DIRDEP,$(PATH_TARGET))
-	$(ECHO_EXT) > $@
-
-$(PATH_TARGET)/inttypes.h: | $(call DIRDEP,$(PATH_TARGET))
-	$(ECHO_EXT) > $@
-
-$(PATH_TARGET)/paths.h: | $(call DIRDEP,$(PATH_TARGET))
-	$(ECHO_EXT) > $@
-
-$(PATH_TARGET)/pwd.h: | $(call DIRDEP,$(PATH_TARGET))
-	$(ECHO_EXT) > $@
-
-$(PATH_TARGET)/grp.h: | $(call DIRDEP,$(PATH_TARGET))
+$(PATH_kmk)/unistd.h: | $(call DIRDEP,$(PATH_kmk))
+	$(ECHO_EXT) > $@
+
+$(PATH_kmk)/sysexits.h: | $(call DIRDEP,$(PATH_kmk))
+	$(ECHO_EXT) > $@
+
+$(PATH_kmk)/inttypes.h: | $(call DIRDEP,$(PATH_kmk))
+	$(ECHO_EXT) > $@
+
+$(PATH_kmk)/paths.h: | $(call DIRDEP,$(PATH_kmk))
+	$(ECHO_EXT) > $@
+
+$(PATH_kmk)/pwd.h: | $(call DIRDEP,$(PATH_kmk))
+	$(ECHO_EXT) > $@
+
+$(PATH_kmk)/grp.h: | $(call DIRDEP,$(PATH_kmk))
 	$(ECHO_EXT) > $@
 
@@ -463,14 +462,14 @@
 
 test_stack:
-	$(MAKE) -f testcase-stack.kmk
+	$(MAKE) -f $(kmk_PATH)/testcase-stack.kmk
 
 test_math:
-	$(MAKE) -f testcase-math.kmk
+	$(MAKE) -f $(kmk_PATH)/testcase-math.kmk
 
 test_if1of:
-	$(MAKE) -f testcase-if1of.kmk
+	$(MAKE) -f $(kmk_PATH)/testcase-if1of.kmk
 
 test_local:
-	$(MAKE) -f testcase-local.kmk
+	$(MAKE) -f $(kmk_PATH)/testcase-local.kmk
 
 test_30_continued_on_failure_worker:
Index: trunk/src/kmk/w32/Makefile.kmk
===================================================================
--- trunk/src/kmk/w32/Makefile.kmk	(revision 1643)
+++ trunk/src/kmk/w32/Makefile.kmk	(revision 1665)
@@ -1,5 +1,5 @@
 # $Id: Makefile.kmk 785 2007-01-24 22:21:56Z bird $
 ## @file
-# tstFileInfo / w32
+# Sub-makefile for tstFileInfo / w32.
 #
 
@@ -25,7 +25,6 @@
 #
 
-
-DEPTH = ../../..
-include $(PATH_KBUILD)/header.kmk
+SUB_DEPTH = ../../..
+include $(KBUILD_PATH)/subheader.kmk
 
 #
@@ -36,3 +35,4 @@
 tstFileInfo_SOURCES = tstFileInfo.c
 
-include $(FILE_KBUILD_FOOTER)
+include $(FILE_KBUILD_SUB_FOOTER)
+
Index: trunk/src/lib/Makefile.kmk
===================================================================
--- trunk/src/lib/Makefile.kmk	(revision 1643)
+++ trunk/src/lib/Makefile.kmk	(revision 1665)
@@ -1,5 +1,5 @@
 # $Id$
 ## @file
-# Various libraries and stuff.
+# Sub-makefile for various libraries and stuff.
 #
 
@@ -25,6 +25,6 @@
 #
 
-DEPTH = ../..
-include $(PATH_KBUILD)/header.kmk
+SUB_DEPTH = ../..
+include $(KBUILD_PATH)/subheader.kmk
 
 LIBRARIES += kDep
@@ -52,4 +52,4 @@
 wrapper_NOINST = 1
 
-include $(FILE_KBUILD_FOOTER)
+include $(FILE_KBUILD_SUB_FOOTER)
 
Index: trunk/src/sed/Makefile.kmk
===================================================================
--- trunk/src/sed/Makefile.kmk	(revision 1643)
+++ trunk/src/sed/Makefile.kmk	(revision 1665)
@@ -1,5 +1,5 @@
 # $Id$
 ## @file
-# sed
+# Sub-Makefile for kmk_sed.
 #
 
@@ -25,6 +25,6 @@
 #
 
-DEPTH = ../..
-include $(PATH_KBUILD)/header.kmk
+SUB_DEPTH = ../..
+include $(KBUILD_PATH)/subheader.kmk
 
 #
@@ -35,9 +35,9 @@
 kmk_sed_TEMPLATE = BIN
 kmk_sed_DEPS = \
-	$(PATH_TARGET)/config.h \
-	$(PATH_TARGET)/regex.h
+	$(PATH_kmk_sed)/config.h \
+	$(PATH_kmk_sed)/regex.h
 kmk_sed_CLEAN = $(kmk_sed_DEPS)
 kmk_sed_INCS = \
-	$(PATH_TARGET) \
+	$(PATH_kmk_sed) \
 	. \
 	lib \
@@ -79,18 +79,18 @@
 	../lib/startuphacks-win.c
 
-include $(FILE_KBUILD_FOOTER)
+include $(FILE_KBUILD_SUB_FOOTER)
 
 #
 # Use checked in config.h instead of running ./configure for it.
 #
-config.h.$(KBUILD_TARGET) := config.h.$(KBUILD_TARGET)
+kmk_sed_config.h.$(KBUILD_TARGET) := $(kmk_sed_PATH)/config.h.$(KBUILD_TARGET)
 
-$(PATH_TARGET)/config.h: $(config.h.$(KBUILD_TARGET)) | $(call DIRDEP,$(PATH_TARGET))
-	$(CP) $^ $@
+$(PATH_kmk_sed)/config.h: $(kmk_sed_config.h.$(KBUILD_TARGET)) | $(call DIRDEP,$(PATH_kmk_sed))
+	$(CP) -f $^ $@
 
 #
 # Use the regex lib shipped with sed and not anything installed on the system.
 #
-$(PATH_TARGET)/regex.h: lib/regex_.h | $(call DIRDEP,$(PATH_TARGET))
-	$(CP) $^ $@
+$(PATH_kmk_sed)/regex.h: $(kmk_sed_PATH)/lib/regex_.h | $(call DIRDEP,$(PATH_kmk_sed))
+	$(CP) -f $^ $@
 
