Index: /trunk/Config.kmk
===================================================================
--- /trunk/Config.kmk	(revision 1505)
+++ /trunk/Config.kmk	(revision 1506)
@@ -81,5 +81,5 @@
 TEMPLATE_BIN_INCS               = $(PATH_ROOT)/src/lib
 
-ifeq ($(BUILD_TARGET),os2)
+ifeq ($(KBUILD_TARGET),os2)
 TEMPLATE_BIN_TOOL               = GCC3OMF
 TEMPLATE_BIN_CFLAGS             = -g
@@ -94,5 +94,5 @@
 endif
 
-ifeq ($(BUILD_TARGET),darwin)
+ifeq ($(KBUILD_TARGET),darwin)
 TEMPLATE_BIN_TOOL               = GCC4MACHO
 TEMPLATE_BIN_CFLAGS             = -g
@@ -104,14 +104,14 @@
 TEMPLATE_BIN_INST               = $(NIX_INSTALL_DIR_BIN)/
  else
-TEMPLATE_BIN_INST               = kBuild/bin/$(BUILD_TARGET).$(BUILD_TARGET_ARCH)/
+TEMPLATE_BIN_INST               = kBuild/bin/$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)/
  endif
 endif
 
-ifeq ($(filter-out win nt,$(BUILD_TARGET)),)
- ifeq ($(BUILD_TARGET_ARCH),x86)
-  include $(PATH_KBUILD)/tools/VCC70.kmk	# fixme! template expanding does something bad to _LIBS /me thinks.
+ifeq ($(filter-out win nt,$(KBUILD_TARGET)),)
+ ifeq ($(KBUILD_TARGET_ARCH),x86)
+  include $(KBUILD_PATH)/tools/VCC70.kmk	# fixme! template expanding does something bad to _LIBS /me thinks.
   TEMPLATE_BIN_TOOL             = VCC70
   TEMPLATE_BIN_DEFS             = WINDOWS32 _CONSOLE __WIN__ WIN32 __WIN32__
- else ifeq ($(BUILD_TARGET_ARCH),amd64)
+ else ifeq ($(KBUILD_TARGET_ARCH),amd64)
   TEMPLATE_BIN_TOOL             = VCC80AMD64
   TEMPLATE_BIN_DEFS             = WINDOWS32 _CONSOLE __WIN__ WIN32 __WIN32__ __WIN64__ WIN64 \
@@ -141,9 +141,9 @@
  #	$(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/msvcprt.lib - avoid this to save space!
  endif
- TEMPLATE_BIN_LIBS.profile      = Y:/coding/libc/svn/trunk/out/win.$(BUILD_TARGET_ARCH)/debug/kStuff/lib/kPrf2.lib
+ TEMPLATE_BIN_LIBS.profile      = Y:/coding/libc/svn/trunk/out/win.$(KBUILD_TARGET_ARCH)/debug/kStuff/lib/kPrf2.lib
  ifdef NIX_INSTALL_DIR
  TEMPLATE_BIN_INST              = $(NIX_INSTALL_DIR_BIN)/
  else
- TEMPLATE_BIN_INST              = kBuild/bin/win.$(BUILD_TARGET_ARCH)/
+ TEMPLATE_BIN_INST              = kBuild/bin/win.$(KBUILD_TARGET_ARCH)/
  endif
 endif
@@ -151,5 +151,5 @@
 ifndef TEMPLATE_BIN_TOOL
  # Use GCC3 when we're certain that the system is using GNU ld and ar.
- ifeq ($(filter-out linux freebsd openbsd netbsd,$(BUILD_TARGET)),)
+ ifeq ($(filter-out linux freebsd openbsd netbsd,$(KBUILD_TARGET)),)
   TEMPLATE_BIN_TOOL              = GCC3
  else
@@ -159,11 +159,11 @@
  TEMPLATE_BIN_LDFLAGS           = -g
  TEMPLATE_BIN_CFLAGS.release    = -O3
- ifeq ($(BUILD_TARGET),freebsd)
+ ifeq ($(KBUILD_TARGET),freebsd)
   TEMPLATE_BIN_INCS            += $(PATH_GNUMAKE_SRC)/glob /usr/local/include
  endif
- ifeq ($(BUILD_TARGET),linux)
+ ifeq ($(KBUILD_TARGET),linux)
   TEMPLATE_BIN_LIBS            += rt
  endif
- ifeq ($(BUILD_TARGET),solaris)
+ ifeq ($(KBUILD_TARGET),solaris)
   TEMPLATE_BIN_CFLAGS.x86      += -m32
   TEMPLATE_BIN_CFLAGS.amd64    += -m64
@@ -178,5 +178,5 @@
   TEMPLATE_BIN_INST             = $(NIX_INSTALL_DIR_BIN)/
  else
-  TEMPLATE_BIN_INST             = kBuild/bin/$(BUILD_TARGET).$(BUILD_TARGET_ARCH)/
+  TEMPLATE_BIN_INST             = kBuild/bin/$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)/
  endif
 endif
Index: /trunk/bootstrap.gmk
===================================================================
--- /trunk/bootstrap.gmk	(revision 1505)
+++ /trunk/bootstrap.gmk	(revision 1506)
@@ -28,5 +28,5 @@
 #
 # ASSUMES:
-#   - BUILD_TARGET, BUILD_PLATFORM_ARCH, BUILD_PLATFORM_CPU and BUILD_TYPE in the env.
+#   - KBUILD_TARGET, KBUILD_HOST, KBUILD_HOST_ARCH, and KBUILD_TYPE in the env.
 #   - PATH_KBUILD points to ./kBuild with an absolute path.
 #   - PATH_KBUILD_BIN must *NOT* be defined anywhere.
@@ -36,5 +36,5 @@
 #   - cp -f works
 #   - cd somedir && command works.
-#   - echo done > file works.
+#   - echo done > some-file works.
 #   - GNU make implements CURDIR, if not please define SRCDIR.
 #
@@ -49,6 +49,41 @@
 #
 
+#
+# Deal with legacy env.vars. - no niceties here.
+#
+ifndef KBUILD_HOST
+ KBUILD_HOST := $(BUILD_PLATFORM)
+endif
+ifndef KBUILD_HOST_ARCH
+ KBUILD_HOST_ARCH := $(BUILD_PLATFORM_ARCH)
+endif
+ifndef KBUILD_HOST_CPU
+ KBUILD_HOST_CPU := $(BUILD_PLATFORM_CPU)
+endif
+
+ifndef KBUILD_TARGET
+ KBUILD_TARGET := $(BUILD_TARGET)
+endif
+ifndef KBUILD_TARGET_ARCH
+ KBUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH)
+endif
+ifndef KBUILD_TARGET_CPU
+ KBUILD_TARGET_CPU := $(BUILD_TARGET_CPU)
+endif
+
+ifndef KBUILD_TYPE
+ KBUILD_TYPE := $(BUILD_TYPE)
+endif
+
+ifndef KBUILD_PATH
+ KBUILD_PATH := $(PATH_KBUILD)
+endif
+
+
+#
+# Globals
+#
 SRCDIR = $(CURDIR)
-OUTDIR = $(SRCDIR)/out/$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)/$(BUILD_TYPE)/bootstrap
+OUTDIR = $(SRCDIR)/out/$(KBUILD_HOST).$(KBUILD_HOST_ARCH)/$(KBUILD_TYPE)/bootstrap
 
 # Override this on the make commandline if you need to (FreeBSD).
@@ -66,6 +101,6 @@
     $(OUTDIR)/kmk/kmk_ash \
     $(OUTDIR)/kmk/kmk_sed \
-    $(SRCDIR)/src/kmk/config.h.$(BUILD_TARGET) \
-    $(SRCDIR)/src/sed/config.h.$(BUILD_TARGET)
+    $(SRCDIR)/src/kmk/config.h.$(KBUILD_TARGET) \
+    $(SRCDIR)/src/sed/config.h.$(KBUILD_TARGET)
 
 # kmk
@@ -81,6 +116,6 @@
 $(OUTDIR)/kmk/config.h: $(OUTDIR)/kmk/ts-configured
 
-$(SRCDIR)/src/kmk/config.h.$(BUILD_TARGET): $(OUTDIR)/kmk/config.h
-	cp -f $(OUTDIR)/kmk/config.h $(SRCDIR)/src/kmk/config.h.$(BUILD_TARGET)
+$(SRCDIR)/src/kmk/config.h.$(KBUILD_TARGET): $(OUTDIR)/kmk/config.h
+	cp -f $(OUTDIR)/kmk/config.h $(SRCDIR)/src/kmk/config.h.$(KBUILD_TARGET)
 
 $(OUTDIR)/kmk/kmk: $(OUTDIR)/kmk/ts-configured
@@ -99,5 +134,5 @@
 $(OUTDIR)/sed/config.h: $(OUTDIR)/sed/ts-configured
 
-$(SRCDIR)/src/sed/config.h.$(BUILD_TARGET): $(OUTDIR)/sed/config.h
+$(SRCDIR)/src/sed/config.h.$(KBUILD_TARGET): $(OUTDIR)/sed/config.h
 	cp -f $< $@
 
@@ -120,6 +155,6 @@
 
 $(OUTDIR)/ts-stage2-build: \
-		$(SRCDIR)/src/kmk/config.h.$(BUILD_TARGET) \
-                $(SRCDIR)/src/sed/config.h.$(BUILD_TARGET) \
+		$(SRCDIR)/src/kmk/config.h.$(KBUILD_TARGET) \
+                $(SRCDIR)/src/sed/config.h.$(KBUILD_TARGET) \
 		$(OUTDIR)/kmk/kmk
 	$(OUTDIR)/kmk/kmk -C $(SRCDIR)
