Index: /trunk/ChangeLog
===================================================================
--- /trunk/ChangeLog	(revision 551)
+++ /trunk/ChangeLog	(revision 552)
@@ -2,7 +2,18 @@
 
 2006-09-23:
+    - kBuild/footer.kmk:
+        o Recursive template inheritance.
+    - kBuild/header.kmk, kBuild/footer.kmk:
+        o Removed some checks for features which are present in both gmake 3.81 and kmk.
+          Anyone trying to bootstrap kBuild will have to build gmake 3.81 first.
+    - Config.kmk, src/gmake:
+        o Allow all kinds of ways of saying Windows in BUILD_TARGET.
+    - kBuild/bin/x86.win32/:
+        o Rebuilt kmk.exe.
     - kBuild/bin/x86.os2/:
+        o Added kDepPre.exe and kDepIDB.exe.
         o Rebuilt kmk.exe and kmk_gmake.exe.
     - src/gmake:
+        o Update KMK_FEATURES to include the optimizations from earlier this week.
         o Regenerated config.h.os2 and make adjustments to make it all
           build quietly on OS/2.
Index: /trunk/Config.kmk
===================================================================
--- /trunk/Config.kmk	(revision 551)
+++ /trunk/Config.kmk	(revision 552)
@@ -43,5 +43,8 @@
 endif
 
-ifeq ($(BUILD_TARGET),win32)
+ifeq ($(filter-out x86.win32 x86.win x86.nt,$(BUILD_TARGET_ARCH).$(BUILD_TARGET)),)
+ifndef PATH_DEV
+$(error To build on windows you'll have to set PATH_DEV to point to somewhere kbuild can find VCC70.)
+endif
 TEMPLATE_BIN_TOOL               = VCC70
 TEMPLATE_BIN_DEFS               = WINDOWS32 _CONSOLE WIN32 __WIN32__
@@ -50,4 +53,5 @@
 TEMPLATE_BIN_CFLAGS.release     = -O2
 TEMPLATE_BIN_CFLAGS.profile     = -O2 -GH -Gh
+#todo use path macros from the tool
 TEMPLATE_BIN_INCS              += \
 	. \
Index: /trunk/kBuild/footer.kmk
===================================================================
--- /trunk/kBuild/footer.kmk	(revision 551)
+++ /trunk/kBuild/footer.kmk	(revision 552)
@@ -117,4 +117,5 @@
 # @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)) \
@@ -177,4 +178,5 @@
 #           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)))))))
@@ -234,21 +236,42 @@
 define def_template_extends_prop
 ifndef TEMPLATE_$(template)_$(prop)
-ifdef TEMPLATE_$(parent)_$(prop)
+ ifdef TEMPLATE_$(parent)_$(prop)
 TEMPLATE_$(template)_$(prop) = $$(TEMPLATE_$(parent)_$(prop))
-endif
-endif
-endef
+ endif
+endif
+endef
+
 
 define def_template_extends
 ifdef TEMPLATE_$(template)_EXTENDS
-parent := $(strip $(TEMPLATE_$(template)_EXTENDS))
-
-$(foreach prop, $(PROPS_SINGLE) $(PROPS_ACCUMULATE) $(PROPS_DEFERRED)\
-$(addsuffix .$(BUILD_TARGET),                      $(PROPS_SINGLE) $(PROPS_ACCUMULATE) $(PROPS_DEFERRED))\
-$(addsuffix .$(BUILD_TARGET).$(BUILD_TARGET_ARCH), $(PROPS_SINGLE) $(PROPS_ACCUMULATE) $(PROPS_DEFERRED))\
-$(addsuffix .$(BUILD_TARGET_ARCH),                 $(PROPS_SINGLE) $(PROPS_ACCUMULATE) $(PROPS_DEFERRED))\
-$(addsuffix .$(BUILD_TARGET_CPU),                  $(PROPS_SINGLE) $(PROPS_ACCUMULATE) $(PROPS_DEFERRED))\
-$(addsuffix .$(BUILD_TYPE),                        $(PROPS_SINGLE) $(PROPS_ACCUMULATE) $(PROPS_DEFERRED))\
-,$(eval $(def_template_extends_prop))) # exploits the 2 evaluation, so no value!
+ ifndef TEMPLATE_$(template)_EXTENDS_STATUS_
+  TEMPLATE_$(template)_EXTENDS_STATUS_ := 0
+  parent := $(strip $(TEMPLATE_$(template)_EXTENDS))
+
+  # recursivly process the parent if it's inherting from somebody too.
+  ifdef TEMPLATE_$(parent)_EXTENDS
+   ifneq ($(TEMPLATE_$(template)_EXTENDS_STATUS_),42)
+    # foreach will create 'template' in a new variable context hiding our current variable.
+    $(foreach template, $(TEMPLATE_$(parent)_EXTENDS), $(eval $(value def_template_extends)))
+    parent := $(strip $(TEMPLATE_$(template)_EXTENDS))
+   endif
+  endif
+
+  # inherit properties.
+  $(foreach prop, $(PROPS_SINGLE) $(PROPS_ACCUMULATE) $(PROPS_DEFERRED)\
+  $(addsuffix .$(BUILD_TARGET),                      $(PROPS_SINGLE) $(PROPS_ACCUMULATE) $(PROPS_DEFERRED))\
+  $(addsuffix .$(BUILD_TARGET).$(BUILD_TARGET_ARCH), $(PROPS_SINGLE) $(PROPS_ACCUMULATE) $(PROPS_DEFERRED))\
+  $(addsuffix .$(BUILD_TARGET_ARCH),                 $(PROPS_SINGLE) $(PROPS_ACCUMULATE) $(PROPS_DEFERRED))\
+  $(addsuffix .$(BUILD_TARGET_CPU),                  $(PROPS_SINGLE) $(PROPS_ACCUMULATE) $(PROPS_DEFERRED))\
+  $(addsuffix .$(BUILD_TYPE),                        $(PROPS_SINGLE) $(PROPS_ACCUMULATE) $(PROPS_DEFERRED))\
+  ,$(eval $(def_template_extends_prop))) # exploits the 2 evaluation, so no value!
+
+  TEMPLATE_$(template)_EXTENDS_STATUS_ := 42
+ else
+  # protect against inheritance loops.
+  ifneq ($(TEMPLATE_$(template)_EXTENDS_STATUS_),42)
+   $(error kBuild: inheritance loop! template=$(template))
+  endif
+ endif
 endif
 endef
@@ -495,5 +518,5 @@
 ## wrapper the compile command dependency check.
 ifndef NO_COMPILE_CMDS_DEPS
- ifdef NEW_KMK
+ ifneq ($(filter comp-vars,$(KMK_FEATURES)),)
 _DEP_COMPILE_CMDS = $(comp-vars $(target)_$(source)_CMDS_PREV_,$(target)_$(source)_CMDS_,FORCE)
  else
@@ -595,4 +618,5 @@
 # @param    bld_trg_arch  Build target arch.
 # @param    bld_trg_cpu   Build target cpu.
+# @remark 	obsoleted by kBuild helpers in kmk. Only required for gmake compatbility.
 #
 define def_target_source_c_cpp_asm_old
@@ -868,4 +892,5 @@
 	$($(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))\
@@ -966,5 +991,5 @@
 def_target_source_c_cpp_asm_new = $(kb-src-one x)
 
-ifdef NEW_KMK
+ifneq ($(filter kb-src-one,$(KMK_FEATURES)),)
 def_target_source_c_cpp_asm_var = def_target_source_c_cpp_asm_new
 else
Index: /trunk/kBuild/header.kmk
===================================================================
--- /trunk/kBuild/header.kmk	(revision 551)
+++ /trunk/kBuild/header.kmk	(revision 552)
@@ -163,6 +163,4 @@
 # Common definitions.
 #
-ifeq ($(filter abspath,$(KMK_FEATURES)),abspath)
-
 PATH_CURRENT        := $(abspath $(CURDIR))
 ifneq ($(strip $(SUB_DEPTH)),)
@@ -172,20 +170,4 @@
 endif
 PATH_ROOT           := $(abspath $(PATH_CURRENT)/$(DEPTH))
-
-else
-
-PATH_CURRENT        := $(CURDIR)
-PATH_SUB_CURRENT    := $(PATH_CURRENT)
-ifneq ($(strip $(SUB_DEPTH)),)
-ifneq ($(SUB_DEPTH),.)
-$(foreach d,$(subst /, ,$(SUB_DEPTH)), $(eval PATH_SUB_CURRENT := $(patsubst %/,%,$(dir $(PATH_SUB_CURRENT)))) )
-endif
-endif
-PATH_ROOT           := $(PATH_CURRENT)
-ifneq ($(DEPTH),.)
-$(foreach d,$(subst /, ,$(DEPTH)), $(eval PATH_ROOT := $(patsubst %/,%,$(dir $(PATH_ROOT)))) )
-endif
-
-endif
 
 # Subdirectory relative to the root.
@@ -220,7 +202,5 @@
 PATH_KBUILD         := $(PATH_ROOT)/kBuild
 endif
-ifeq ($(filter abspath,$(KMK_FEATURES)),abspath)
 PATH_KBUILD         := $(abspath $(PATH_KBUILD))
-endif
 # kBuild files which might be of interest.
 FILE_KBUILD_HEADER  := $(PATH_KBUILD)/header.kmk
@@ -455,12 +435,5 @@
 #
 # @param	$1	The paths to make absolute.
-ifeq ($(filter abspath,$(KMK_FEATURES)),abspath)
 ABSPATH = $(abspath $(1))
-else
-ABSPATH = $(foreach path,$(1)\
-            ,$(strip $(if $(subst <,,$(firstword $(subst /, ,<$(path)))),\
-                      $(if $(patsubst %:,,$(firstword $(subst :,: ,$(path)))),$(PATH_CURRENT)/$(path),$(path)),\
-                      $(path))))
-endif
 
 ## DIRDEP - make create directory dependencies.
Index: /trunk/src/gmake/Makefile.kmk
===================================================================
--- /trunk/src/gmake/Makefile.kmk	(revision 551)
+++ /trunk/src/gmake/Makefile.kmk	(revision 552)
@@ -10,5 +10,7 @@
 kmk_DEPS = $(PATH_TARGET)/config.h
 kmk_INCS = $(PATH_TARGET) .
-#kmk_INCS.win32      = kmkbuiltin/w32
+#ifeq ($(filter-out win32 win64 win nt,$(BUILD_TARGET)),)
+#kmk_INCS += kmkbuiltin/w32
+#endif
 
 kmk_DEFS = \
@@ -56,5 +58,6 @@
 	kbuild.c
 
-kmk_SOURCES.win32 = \
+ifeq ($(filter-out win32 win64 win nt,$(BUILD_TARGET)),)
+kmk_SOURCES += \
 	getopt.c \
 	getopt1.c \
@@ -67,4 +70,5 @@
 	w32/compat/dirent.c \
 	w32/pathstuff.c
+endif
 
 kmk_SOURCES.freebsd = \
@@ -92,8 +96,9 @@
 	kmkbuiltin/strlcpy.c
 
-kmk_SOURCES.win32 += \
+ifeq ($(filter-out win32 win64 win nt,$(BUILD_TARGET)),)
+kmk_SOURCES += \
 	kmkbuiltin/mscfakes.c \
 	kmkbuiltin/fts.c
-
+endif
 
 #
@@ -116,7 +121,8 @@
 	kmkbuiltin/strlcpy.c \
 	kmkbuiltin/err.c
-kmk_cp_INCS.win32 = $(PATH_TARGET) .
-kmk_cp_DEFS.win32 = HAVE_CONFIG_H
-kmk_cp_SOURCES.win32 = \
+ifeq ($(filter-out win32 win64 win nt,$(BUILD_TARGET)),)
+kmk_cp_INCS += $(PATH_TARGET) .
+kmk_cp_DEFS += HAVE_CONFIG_H
+kmk_cp_SOURCES += \
 	kmkbuiltin/mscfakes.c \
 	kmkbuiltin/fts.c \
@@ -124,4 +130,5 @@
 	getopt.c \
 	getopt1.c
+endif
 
 kmk_echo_TEMPLATE = BIN
@@ -129,7 +136,9 @@
 kmk_echo_SOURCES = \
 	kmkbuiltin/echo.c
-kmk_echo_SOURCES.win32 = \
+ifeq ($(filter-out win32 win64 win nt,$(BUILD_TARGET)),)
+kmk_echo_SOURCES += \
 	kmkbuiltin/mscfakes.c \
 	kmkbuiltin/err.c
+endif
 
 kmk_install_TEMPLATE = BIN
@@ -140,10 +149,12 @@
 	kmkbuiltin/strmode.c \
 	kmkbuiltin/setmode.c
-kmk_install_INCS.win32 = $(PATH_TARGET) .
-kmk_install_DEFS.win32 = HAVE_CONFIG_H
-kmk_install_SOURCES.win32 = \
-	kmkbuiltin/mscfakes.c \
-	getopt.c \
-	getopt1.c
+ifeq ($(filter-out win32 win64 win nt,$(BUILD_TARGET)),)
+kmk_install_INCS += $(PATH_TARGET) .
+kmk_install_DEFS += HAVE_CONFIG_H
+kmk_install_SOURCES += \
+	kmkbuiltin/mscfakes.c \
+	getopt.c \
+	getopt1.c
+endif
 
 kmk_ln_TEMPLATE = BIN
@@ -152,10 +163,12 @@
 	kmkbuiltin/ln.c \
 	kmkbuiltin/err.c
-kmk_ln_INCS.win32 = $(PATH_TARGET) .
-kmk_ln_DEFS.win32 = HAVE_CONFIG_H
-kmk_ln_SOURCES.win32 = \
+ifeq ($(filter-out win32 win64 win nt,$(BUILD_TARGET)),)
+kmk_ln_INCS += $(PATH_TARGET) .
+kmk_ln_DEFS += HAVE_CONFIG_H
+kmk_ln_SOURCES += \
 	kmkbuiltin/mscfakes.c\
 	getopt.c \
 	getopt1.c
+endif
 
 kmk_mkdir_TEMPLATE = BIN
@@ -165,10 +178,12 @@
 	kmkbuiltin/err.c \
 	kmkbuiltin/setmode.c
-kmk_mkdir_INCS.win32 = $(PATH_TARGET) .
-kmk_mkdir_DEFS.win32 = HAVE_CONFIG_H
-kmk_mkdir_SOURCES.win32 = \
-	kmkbuiltin/mscfakes.c \
-	getopt.c \
-	getopt1.c
+ifeq ($(filter-out win32 win64 win nt,$(BUILD_TARGET)),)
+kmk_mkdir_INCS += $(PATH_TARGET) .
+kmk_mkdir_DEFS += HAVE_CONFIG_H
+kmk_mkdir_SOURCES += \
+	kmkbuiltin/mscfakes.c \
+	getopt.c \
+	getopt1.c
+endif
 
 kmk_rm_TEMPLATE = BIN
@@ -178,10 +193,12 @@
 	kmkbuiltin/err.c \
 	kmkbuiltin/strmode.c
-kmk_rm_INCS.win32 = $(PATH_TARGET) .
-kmk_rm_DEFS.win32 = HAVE_CONFIG_H
-kmk_rm_SOURCES.win32 = \
+ifeq ($(filter-out win32 win64 win nt,$(BUILD_TARGET)),)
+kmk_rm_INCS += $(PATH_TARGET) .
+kmk_rm_DEFS += HAVE_CONFIG_H
+kmk_rm_SOURCES += \
 	kmkbuiltin/mscfakes.c\
 	getopt.c \
 	getopt1.c
+endif
 
 
@@ -223,5 +240,6 @@
 	remote-stub.c
 
-kmk_gmake_SOURCES.win32 = \
+ifeq ($(filter-out win32 win64 win nt,$(BUILD_TARGET)),)
+kmk_gmake_SOURCES += \
 	getopt.c \
 	getopt1.c \
@@ -234,4 +252,5 @@
 	w32/compat/dirent.c \
 	w32/pathstuff.c
+endif
 
 kmk_gmake_SOURCES.freebsd = \
Index: /trunk/src/gmake/variable.c
===================================================================
--- /trunk/src/gmake/variable.c	(revision 551)
+++ /trunk/src/gmake/variable.c	(revision 552)
@@ -988,6 +988,27 @@
 
   /* Define KMK_FEATURES to indicate various working KMK features. */
-  (void) define_variable ("KMK_FEATURES", 12, "abspath toupper tolower", o_default, 0);
-#endif
+# if defined(CONFIG_WITH_TOUPPER_TOLOWER) \
+  && defined(CONFIG_WITH_VALUE_LENGTH) && defined(CONFIG_WITH_COMPARE) \
+  && defined(KMK_HELPERS)
+  (void) define_variable ("KMK_FEATURES", 12, 
+                          "abspath"
+                          " toupper tolower"
+                          " comp-vars"
+                          " kb-src-tool kb-obj-base kb-obj-suff kb-src-prop kb-src-one"
+                          , o_default, 0);
+# else /* MSC can't deal with strings mixed with #if/#endif, thus the slow way. */
+  strcpy(buf, "abspath");
+#  if defined(CONFIG_WITH_TOUPPER_TOLOWER)
+  strcat(buf, " toupper tolower");
+#  endif
+#  if defined(CONFIG_WITH_VALUE_LENGTH) && defined(CONFIG_WITH_COMPARE)
+  strcat(buf, " comp-vars");
+#  endif 
+#  ifdef KMK_HELPERS
+  strcat(buf, " kb-src-tool kb-obj-base kb-obj-suff kb-src-prop kb-src-one");
+#  endif
+  (void) define_variable ("KMK_FEATURES", 12, buf, o_default, 0);
+# endif 
+#endif /* KMK */
 
 #ifdef CONFIG_WITH_KMK_BUILTIN
