Index: /trunk/kBuild/envwin.cmd
===================================================================
--- /trunk/kBuild/envwin.cmd	(revision 477)
+++ /trunk/kBuild/envwin.cmd	(revision 478)
@@ -24,29 +24,66 @@
 REM # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 REM #
-REM # kBuild path.
-
-REM # deal with -32 and -64 options
-if ".%1" = ".-32" goto want_32_bit
-if ".%1" = ".-64" goto want_64_bit
-goto doesnt_want_anything
-
-:want_32_bit
-shift
+
+
+REM #
+REM # Deal with the arguments.
+REM #
+if ".%1" = ".-win"      goto want_win_bit
+if ".%1" = ".-win32"    goto want_win32_bit
+if ".%1" = ".-win64"    goto want_win64_bit
+if ".%1" = ".-nt"       goto want_nt_bit
+if ".%1" = ".-nt32"     goto want_nt32_bit
+if ".%1" = ".-nt64"     goto want_nt64_bit
+goto done_arguments
+
+:want_win_bit
+shift
+set BUILD_TARGET=win
+set BUILD_PLATFORM=win
+goto done_arguments
+
+:want_win32_bit
+shift
+set BUILD_PLATFORM=win32
 set BUILD_TARGET=win32
-set BUILD_PLATFORM=win32
-set BUILD_PLATFORM_ARCH=amd64
-goto doesnt_want_anything
-
-:want_64_bit
+set BUILD_TARGET_ARCH=x86
+goto done_arguments
+
+:want_win64_bit
 shift
 set BUILD_TARGET=win64
-goto doesnt_want_anything
-
-:doesnt_want_anything
-
+set BUILD_TARGET_ARCH=amd64
+goto done_arguments
+
+:want_nt_bit
+shift
+set BUILD_PLATFORM=nt
+set BUILD_TARGET=nt
+goto done_arguments
+
+:want_nt32_bit
+shift
+set BUILD_PLATFORM=nt
+set BUILD_TARGET=nt
+set BUILD_TARGET_ARCH=x86
+goto done_arguments
+
+:want_nt64_bit
+shift
+set BUILD_PLATFORM=nt
+set BUILD_TARGET=nt
+set BUILD_TARGET_ARCH=amd64
+goto done_arguments
+
+:done_arguments
+
+REM #
 REM # figure the current directory.
+REM #
 for /f "tokens=*" %d in ('cd') do set CURDIR=%d
 
+REM #
 REM # find kBuild.
+REM #
 if exist %PATH_KBUILD%\footer.kmk goto found_kbuild
 set PATH_KBUILD=%CURDIR
@@ -70,5 +107,7 @@
 set CURDIR=
 
+REM #
 REM # Type.
+REM #
 IF NOT ".%BUILD_TYPE%" = "." goto have_BUILD_TYPE
 set BUILD_TYPE=debug
@@ -76,6 +115,11 @@
 echo dbg: BUILD_TYPE=%BUILD_TYPE%
 
+
+REM #
 REM # Host platform.
+REM #
 IF NOT ".%BUILD_PLATFORM%" = "." goto have_2_BUILD_PLATFORM
+set BUILD_PLATFORM=win
+echo dbg: BUILD_PLATFORM=%BUILD_PLATFORM%
 
 IF NOT ".%BUILD_PLATFORM_ARCH%" = "."   goto have_BUILD_PLATFORM_ARCH
@@ -103,13 +147,4 @@
 :have_BUILD_PLATFORM_CPU
 echo dbg: BUILD_PLATFORM_CPU=%BUILD_PLATFORM_CPU%
-
-IF "%BUILD_PLATFORM_ARCH%" = "amd64"    set BUILD_PLATFORM=win64
-IF "%BUILD_PLATFORM_ARCH%" = "x86"      set BUILD_PLATFORM=win32
-IF NOT ".%BUILD_PLATFORM%" = "."        goto have_BUILD_PLATFORM
-echo kBuild: Cannot figure BUILD_PLATFORM!
-goto failed
-
-:have_BUILD_PLATFORM
-echo dbg: BUILD_PLATFORM=%BUILD_PLATFORM%
 goto process_BUILD_TARGET
 
@@ -120,4 +155,13 @@
 IF "%BUILD_PLATFORM%" = "win64"         set BUILD_PLATFORM_ARCH=amd64
 IF NOT ".%BUILD_PLATFORM_ARCH%" = "."   goto have_2_BUILD_PLATFORM_ARCH
+set TEST_PROCESSOR_ARCH=%PROCESSOR_ARCHITECTURE%
+IF NOT ".%PROCESSOR_ARCHITEW6432%" = "." set TEST_PROCESSOR_ARCH=%PROCESSOR_ARCHITEW6432%
+IF "%TEST_PROCESSOR_ARCH%" = "x86"      set BUILD_PLATFORM_ARCH=x86
+IF "%TEST_PROCESSOR_ARCH%" = "X86"      set BUILD_PLATFORM_ARCH=x86
+IF "%TEST_PROCESSOR_ARCH%" = "AMD64"    set BUILD_PLATFORM_ARCH=amd64
+IF "%TEST_PROCESSOR_ARCH%" = "x64"      set BUILD_PLATFORM_ARCH=amd64
+IF "%TEST_PROCESSOR_ARCH%" = "X64"      set BUILD_PLATFORM_ARCH=amd64
+IF NOT ".%BUILD_PLATFORM_ARCH%" = "."   goto have_2_BUILD_PLATFORM_ARCH
+set TEST_PROCESSOR_ARCH=
 echo kBuild: Cannot figure BUILD_PLATFORM_ARCH!
 goto failed
@@ -135,5 +179,7 @@
 
 
+REM #
 REM # Target platform.
+REM #
 :process_BUILD_TARGET
 IF NOT ".%BUILD_TARGET%" = "." goto have_BUILD_TARGET
@@ -174,4 +220,8 @@
 
 REM # The PATH.
+IF "%BUILD_PLATFORM_ARCH%.%BUILD_PLATFORM%" = "x86.nt"      set PATH=%PATH_KBUILD%\bin\x86.win32;%PATH%
+IF "%BUILD_PLATFORM_ARCH%.%BUILD_PLATFORM%" = "x86.win"     set PATH=%PATH_KBUILD%\bin\x86.win32;%PATH%
+IF "%BUILD_PLATFORM_ARCH%.%BUILD_PLATFORM%" = "amd64.nt"    set PATH=%PATH_KBUILD%\bin\amd64.nt;%PATH_KBUILD%\bin\x86.win32;%PATH%
+IF "%BUILD_PLATFORM_ARCH%.%BUILD_PLATFORM%" = "amd64.win"   set PATH=%PATH_KBUILD%\bin\amd64.win64;%PATH_KBUILD%\bin\x86.win32;%PATH%
 IF "%BUILD_PLATFORM_ARCH%.%BUILD_PLATFORM%" = "amd64.win64" set PATH=%PATH_KBUILD%\bin\x86.win32;%PATH%
 set PATH=%PATH_KBUILD%\bin\%BUILD_PLATFORM_ARCH%.%BUILD_PLATFORM%;%PATH%
Index: /trunk/kBuild/header.kmk
===================================================================
--- /trunk/kBuild/header.kmk	(revision 477)
+++ /trunk/kBuild/header.kmk	(revision 478)
@@ -75,5 +75,5 @@
 # @param    $1   String 1.
 # @param    $2   String 2
-STRCMP = $(
+STRCMP = $( todo )
 
 #
@@ -100,71 +100,31 @@
 # Assert build platform.
 #
-_BUILD_PLATFORM_OK  := 0
-# OS/2 (have uppercase legacy)
-ifeq ($(BUILD_PLATFORM),OS2)
-override BUILD_PLATFORM := os2
-endif
-ifeq ($(BUILD_PLATFORM),os2)
-_BUILD_PLATFORM_OK  := 1
-endif
-
-# Linux
-ifeq ($(BUILD_PLATFORM),LINUX)
-$(error kBuild: BUILD_PLATFORM must be all lowercase!)
-endif
-ifeq ($(BUILD_PLATFORM),linux)
-_BUILD_PLATFORM_OK  := 1
-endif
-
-# Win32
-ifeq ($(BUILD_PLATFORM),WIN32)
-$(error kBuild: BUILD_PLATFORM must be all lowercase!)
-endif
-ifeq ($(BUILD_PLATFORM),win32)
-_BUILD_PLATFORM_OK  := 1
-endif
-
-# Win64
-ifeq ($(BUILD_PLATFORM),WIN64)
-$(error kBuild: BUILD_PLATFORM must be all lowercase!)
-endif
-ifeq ($(BUILD_PLATFORM),win64)
-_BUILD_PLATFORM_OK  := 1
-endif
-
-# L4
-ifeq ($(BUILD_PLATFORM),L4)
-$(error kBuild: BUILD_PLATFORM must be all lowercase!)
-endif
-ifeq ($(BUILD_PLATFORM),l4)
-_BUILD_PLATFORM_OK  := 1
-endif
-
-# FreeBSD
-ifeq ($(BUILD_PLATFORM),FreeBSD)
-$(error kBuild: BUILD_PLATFORM must be all lowercase!)
-endif
-ifeq ($(BUILD_PLATFORM),freebsd)
-_BUILD_PLATFORM_OK  := 1
-endif
-
-ifeq ($(_BUILD_PLATFORM_OK),0)
-$(error kBuild: BUILD_PLATFORM value '$(BUILD_PLATFORM)' was not recongized!)
+ifndef BUILD_PLATFORM
+ $(error kBuild: BUILD_PLATFORM is undefined!)
+else
+ BUILD_PLATFORM     := $(strip $(BUILD_PLATFORM))
+ ifneq ($(words $(BUILD_PLATFORM))$(filter-out freebsd l4 linux nt os2 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
+ 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
+ ifeq ($(filter-out amd64,$(BUILD_PLATFORM_ARCH)),)
+  BUILD_PLATFORM_CPU:= k8
+ else
+  BUILD_PLATFORM_CPU:= i586
+ endif
 endif
 
@@ -177,64 +137,20 @@
 BUILD_TARGET        := $(BUILD_PLATFORM)
 else
-_BUILD_TARGET_OK    := 0
-# OS/2
-ifeq ($(BUILD_TARGET),OS2)
-$(error kBuild: BUILD_TARGET must be all lowercase!)
-endif
-ifeq ($(BUILD_TARGET),os2)
-_BUILD_TARGET_OK    := 1
-endif
-
-# Linux
-ifeq ($(BUILD_TARGET),LINUX)
-$(error kBuild: BUILD_TARGET must be all lowercase!)
-endif
-ifeq ($(BUILD_TARGET),linux)
-_BUILD_TARGET_OK    := 1
-endif
-
-# Win32
-ifeq ($(BUILD_TARGET),WIN32)
-$(error kBuild: BUILD_TARGET must be all lowercase!)
-endif
-ifeq ($(BUILD_TARGET),win32)
-_BUILD_TARGET_OK    := 1
-endif
-
-# Win64
-ifeq ($(BUILD_TARGET),WIN64)
-$(error kBuild: BUILD_TARGET must be all lowercase!)
-endif
-ifeq ($(BUILD_TARGET),win64)
-_BUILD_TARGET_OK    := 1
-endif
-
-# L4
-ifeq ($(BUILD_TARGET),L4)
-$(error kBuild: BUILD_TARGET must be all lowercase!)
-endif
-ifeq ($(BUILD_TARGET),l4)
-_BUILD_TARGET_OK    := 1
-endif
-
-# FreeBSD
-ifeq ($(BUILD_TARGET),FreeBSD)
-$(error kBuild: BUILD_TARGET must be all lowercase!)
-endif
-ifeq ($(BUILD_TARGET),freebsd)
-_BUILD_TARGET_OK    := 1
-endif
-
-ifeq ($(_BUILD_TARGET_OK),0)
-$(error kBuild: BUILD_TARGET value '$(BUILD_TARGET)' was not recongized!)
-endif
+ BUILD_TARGET       := $(strip $(BUILD_TARGET))
+ ifneq ($(words $(BUILD_TARGET))$(filter-out freebsd l4 linux nt os2 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.
 ifndef BUILD_TARGET_ARCH
-BUILD_TARGET_ARCH   := x86
+ BUILD_TARGET_ARCH  := x86
 endif
 ifndef BUILD_TARGET_CPU
-BUILD_TARGET_CPU    := i586
+ BUILD_TARGET_CPU   := i586
 endif
 
@@ -326,6 +242,4 @@
 # Build platform setup.
 #
-PATH_TOOLS          := $(PATH_KBUILD)/bin/$(BUILD_PLATFORM_ARCH).$(BUILD_PLATFORM)
-
 # OS/2
 ifeq ($(BUILD_PLATFORM),os2)
@@ -350,4 +264,20 @@
 EXEC_X86_WIN32      := wine
 HOSTSUFF_EXE        :=
+endif
+
+PATH_TOOLS          := $(PATH_KBUILD)/bin/$(BUILD_PLATFORM_ARCH).$(BUILD_PLATFORM)
+ifeq ($(wildcard $(PATH_TOOLS)/kmk_ash$(HOSTSUFF_EXE)),)
+ ifeq ($(BUILD_TARGET_ARCH),amd64)
+  PATH_TOOLS        := $(PATH_KBUILD)/bin/x86.$(BUILD_PLATFORM)
+ endif
+ ifeq ($(wildcard $(PATH_TOOLS)/kmk_ash$(HOSTSUFF_EXE)),)
+  ifeq ($(filter-out win64 nt,$(BUILD_PLATFORM)),)
+   PATH_TOOLS       := $(PATH_KBUILD)/bin/x86.win32
+  endif
+ endif
+ ifeq ($(wildcard $(PATH_TOOLS)/kmk_ash$(HOSTSUFF_EXE)),)
+  # give up
+  PATH_TOOLS        := $(PATH_KBUILD)/bin/$(BUILD_PLATFORM_ARCH).$(BUILD_PLATFORM)
+ endif
 endif
 
