Index: trunk/kBuild/env.sh
===================================================================
--- trunk/kBuild/env.sh	(revision 993)
+++ trunk/kBuild/env.sh	(revision 994)
@@ -30,9 +30,9 @@
 # Determin the kBuild path from the script location.
 #
-if [ -z "$PATH_KBUILD" ]; then
+if test -z "$PATH_KBUILD"; then
     PATH_KBUILD=`dirname "$0"`
     PATH_KBUILD=`cd "$PATH_KBUILD" ; /bin/pwd`
 fi
-if [ ! -f "$PATH_KBUILD/footer.kmk" -o ! -f "$PATH_KBUILD/header.kmk" -o ! -f "$PATH_KBUILD/rules.kmk" ]; then
+if test ! -f "$PATH_KBUILD/footer.kmk" -o ! -f "$PATH_KBUILD/header.kmk" -o ! -f "$PATH_KBUILD/rules.kmk"; then
     echo "$0: error: PATH_KBUILD ($PATH_KBUILD) is not pointing to a popluated kBuild directory.";
     sleep 1;
@@ -45,5 +45,5 @@
 # Set default build type.
 #
-if [ -z "$BUILD_TYPE" ]; then
+if test -z "$BUILD_TYPE"; then
     BUILD_TYPE=release
 fi
@@ -58,7 +58,52 @@
 # sure any new additions are unique. (See header.kmk, KBUILD_OSES/ARCHES.)
 #
-if [ -z "$BUILD_PLATFORM_ARCH" ]; then
+if test -z "$BUILD_PLATFORM"; then
+    BUILD_PLATFORM=`uname`
+    case "$BUILD_PLATFORM" in
+        linux|Linux|GNU/Linux|LINUX)
+            BUILD_PLATFORM=linux
+            ;;
+
+        os2|OS/2|OS2)
+            BUILD_PLATFORM=os2
+            ;;
+
+        freebsd|FreeBSD|FREEBSD)
+            BUILD_PLATFORM=freebsd
+            ;;
+
+        openbsd|OpenBSD|OPENBSD)
+            BUILD_PLATFORM=openbsd
+            ;;
+
+        netbsd|NetBSD|NETBSD)
+            BUILD_PLATFORM=netbsd
+            ;;
+
+        Darwin|darwin)
+            BUILD_PLATFORM=darwin
+            ;;
+
+        SunOS)
+            BUILD_PLATFORM=solaris
+            ;;
+
+        WindowsNT|CYGWIN_NT-*)
+            BUILD_PLATFORM=win
+            ;;
+
+        *)
+            echo "$0: unknown os $BUILD_PLATFORM"
+            sleep 1
+            exit 1
+            ;;
+    esac
+fi
+export BUILD_PLATFORM
+echo "dbg: BUILD_PLATFORM=$BUILD_PLATFORM"
+
+if test -z "$BUILD_PLATFORM_ARCH"; then
     # Try deduce it from the cpu if given.
-    if [ -s "$BUILD_PLATFORM_CPU" ]; then
+    if test -s "$BUILD_PLATFORM_CPU"; then
         case "$BUILD_PLATFORM_CPU" in
             i[3456789]86)
@@ -71,5 +116,5 @@
     fi
 fi
-if [ -z "$BUILD_PLATFORM_ARCH" ]; then
+if test -z "$BUILD_PLATFORM_ARCH"; then
     # Use uname (lots of guesses here, please help clean this up...)
     BUILD_PLATFORM_ARCH=`uname -m`
@@ -130,5 +175,5 @@
 echo "dbg: BUILD_PLATFORM_ARCH=$BUILD_PLATFORM_ARCH"
 
-if [ -z "$BUILD_PLATFORM_CPU" ]; then
+if test -z "$BUILD_PLATFORM_CPU"; then
     BUILD_PLATFORM_CPU="blend"
 fi
@@ -136,71 +181,29 @@
 echo "dbg: BUILD_PLATFORM_CPU=$BUILD_PLATFORM_CPU"
 
-if [ -z "$BUILD_PLATFORM" ]; then
-    BUILD_PLATFORM=`uname`
-    case "$BUILD_PLATFORM" in
-        linux|Linux|GNU/Linux|LINUX)
-            BUILD_PLATFORM=linux
-            ;;
-
-        os2|OS/2|OS2)
-            BUILD_PLATFORM=os2
-            ;;
-
-        freebsd|FreeBSD|FREEBSD)
-            BUILD_PLATFORM=freebsd
-            ;;
-
-        openbsd|OpenBSD|OPENBSD)
-            BUILD_PLATFORM=openbsd
-            ;;
-
-        netbsd|NetBSD|NETBSD)
-            BUILD_PLATFORM=netbsd
-            ;;
-
-        Darwin|darwin)
-            BUILD_PLATFORM=darwin
-            ;;
-
-        SunOS)
-            BUILD_PLATFORM=solaris
-            ;;
-
-        WindowsNT|CYGWIN_NT-*)
-            BUILD_PLATFORM=win
-            ;;
-
-        *)
-            echo "$0: unknown os $BUILD_PLATFORM"
-            sleep 1
-            exit 1
-            ;;
-    esac
-fi
-export BUILD_PLATFORM
-echo "dbg: BUILD_PLATFORM=$BUILD_PLATFORM"
-
-
 #
 # The target platform.
 # Defaults to the host when not specified.
 #
-if [ -z "$BUILD_TARGET_CPU" ]; then
-    BUILD_TARGET_CPU="$BUILD_PLATFORM_CPU"
+if test -z "$BUILD_TARGET"; then
+    BUILD_TARGET="$BUILD_PLATFORM"
+fi
+export BUILD_TARGET
+echo "dbg: BUILD_TARGET=$BUILD_TARGET"
+
+if test -z "$BUILD_TARGET_ARCH"; then
+    BUILD_TARGET_ARCH="$BUILD_PLATFORM_ARCH"
+fi
+export BUILD_TARGET_ARCH
+echo "dbg: BUILD_TARGET_ARCH=$BUILD_TARGET_ARCH"
+
+if test -z "$BUILD_TARGET_CPU"; then
+    if test "$BUILD_TARGET_ARCH" = "$BUILD_PLATFORM_ARCH"; then
+        BUILD_TARGET_CPU="$BUILD_PLATFORM_CPU"
+    else
+        BUILD_TARGET_CPU="blend"
+    fi
 fi
 export BUILD_TARGET_CPU
 echo "dbg: BUILD_TARGET_CPU=$BUILD_TARGET_CPU"
-
-if [ -z "$BUILD_TARGET_ARCH" ]; then
-    BUILD_TARGET_ARCH="$BUILD_PLATFORM_ARCH"
-fi
-export BUILD_TARGET_ARCH
-echo "dbg: BUILD_TARGET_ARCH=$BUILD_TARGET_ARCH"
-
-if [ -z "$BUILD_TARGET" ]; then
-    BUILD_TARGET="$BUILD_PLATFORM"
-fi
-export BUILD_TARGET
-echo "dbg: BUILD_TARGET=$BUILD_TARGET"
 
 
@@ -227,5 +230,5 @@
 
 # Sanity and x bits.
-if [ ! -d "$PATH_KBUILD/bin/$BUILD_PLATFORM.$BUILD_PLATFORM_ARCH/" ]; then
+if test ! -d "$PATH_KBUILD/bin/$BUILD_PLATFORM.$BUILD_PLATFORM_ARCH/"; then
     echo "$0: warning: The bin directory for this platform doesn't exists. ($PATH_KBUILD/bin/$BUILD_PLATFORM.$BUILD_PLATFORM_ARCH/)"
 else
@@ -233,5 +236,5 @@
     do
         chmod a+x $PATH_KBUILD/bin/$BUILD_PLATFORM.$BUILD_PLATFORM_ARCH/${prog} > /dev/null 2>&1
-        if [ ! -f "$PATH_KBUILD/bin/$BUILD_PLATFORM.$BUILD_PLATFORM_ARCH/${prog}${_SUFF_EXE}" ]; then
+        if test ! -f "$PATH_KBUILD/bin/$BUILD_PLATFORM.$BUILD_PLATFORM_ARCH/${prog}${_SUFF_EXE}"; then
             echo "$0: warning: The ${prog} program doesn't exist for this platform. ($PATH_KBUILD/bin/$BUILD_PLATFORM.$BUILD_PLATFORM_ARCH/${prog}${_SUFF_EXE})"
         fi
@@ -243,7 +246,7 @@
 
 # Execute command or spawn shell.
-if [ $# -eq 0 ]; then
+if test $# -eq 0; then
     echo "$0: info: Spawning work shell..."
-    if [ "$TERM" != 'dumb'  ] && [ -n "$BASH" ]; then
+    if test "$TERM" != 'dumb'  -a  -n "$BASH"; then
         export PS1='\[\033[01;32m\]\u@\h \[\033[01;34m\]\W \$ \[\033[00m\]'
     fi
Index: trunk/kBuild/header.kmk
===================================================================
--- trunk/kBuild/header.kmk	(revision 993)
+++ trunk/kBuild/header.kmk	(revision 994)
@@ -177,14 +177,15 @@
 
 ifeq ($(strip $(BUILD_PLATFORM_CPU)),)
- $(error kBuild: The BUILD_PLATFORM_CPU value is missing (should be set by kmk)!)
-endif
-ifneq (.$(words $(BUILD_PLATFORM_CPU)).$(BUILD_PLATFORM_CPU).,.1.$(strip $(BUILD_PLATFORM_CPU)).)
- $(error kBuild: The BUILD_PLATFORM_CPU value '$(BUILD_PLATFORM_CPU)' contains spaces/tabs!)
-endif
-ifneq ($(filter $(BUILD_PLATFORM_CPU), $(KBUILD_OSES) $(BUILD_ARCHES)),)
- $(error kBuild: The BUILD_PLATFORM_CPU value '$(BUILD_PLATFORM_CPU)' was found in the OS or architecture keywords!)
-endif
-ifeq ($(BUILD_PLATFORM_CPU),$(BUILD_TYPE))
- $(error kBuild: The BUILD_PLATFORM_CPU value '$(BUILD_PLATFORM_CPU)' is the same as the BUILD_TYPE!)
+ BUILD_PLATFORM_CPU := blend
+else
+ ifneq (.$(words $(BUILD_PLATFORM_CPU)).$(BUILD_PLATFORM_CPU).,.1.$(strip $(BUILD_PLATFORM_CPU)).)
+  $(error kBuild: The BUILD_PLATFORM_CPU value '$(BUILD_PLATFORM_CPU)' contains spaces/tabs!)
+ endif
+ ifneq ($(filter $(BUILD_PLATFORM_CPU), $(KBUILD_OSES) $(BUILD_ARCHES)),)
+  $(error kBuild: The BUILD_PLATFORM_CPU value '$(BUILD_PLATFORM_CPU)' was found in the OS or architecture keywords!)
+ endif
+ ifeq ($(BUILD_PLATFORM_CPU),$(BUILD_TYPE))
+  $(error kBuild: The BUILD_PLATFORM_CPU value '$(BUILD_PLATFORM_CPU)' is the same as the BUILD_TYPE!)
+ endif
 endif
 
@@ -218,8 +219,11 @@
 ifndef BUILD_TARGET_CPU
  BUILD_TARGET_CPU := $(BUILD_PLATFORM_CPU)
-else
- ifeq ($(strip $(BUILD_TARGET_CPU)),)
-  $(error kBuild: The BUILD_TARGET_CPU value is missing (should be set by kmk)!)
- endif
+else ifeq ($(strip $(BUILD_TARGET_CPU)),)
+ ifeq ($(BUILD_TARGET_ARCH),$(BUILD_PLATFORM_ARCH))
+  BUILD_TARGET_CPU := $(BUILD_PLATFORM_CPU)
+ else
+  BUILD_TARGET_CPU := blend
+ endif
+else
  ifneq (.$(words $(BUILD_TARGET_CPU)).$(BUILD_TARGET_CPU).,.1.$(strip $(BUILD_TARGET_CPU)).)
   $(error kBuild: The BUILD_TARGET_CPU value '$(BUILD_TARGET_CPU)' contains spaces/tabs!)
