Index: /trunk/ChangeLog
===================================================================
--- /trunk/ChangeLog	(revision 586)
+++ /trunk/ChangeLog	(revision 587)
@@ -2,4 +2,8 @@
 
 2006-11-23:
+    - Config.kmk, Makefile.kmk:
+        o #6: Hacking *nix install build for Gentoo.
+    - src/gmake/Makefile.kmk, src/lib/Makefile:
+        o Always include header.kmk when testing BUILD_TARGET*.
     - kBuild/header.kmk:
         o BUILD_TYPE defaults to 'release'.
Index: /trunk/Config.kmk
===================================================================
--- /trunk/Config.kmk	(revision 586)
+++ /trunk/Config.kmk	(revision 587)
@@ -40,4 +40,15 @@
 	KBUILD_VERSION_MINOR=$(KBUILD_VERSION_MINOR) \
 	KBUILD_VERSION_PATCH=$(KBUILD_VERSION_PATCH)
+
+#
+# Check if we're building a *nix installation.
+#
+ifdef NIX_INSTALL_DIR
+NIX_INSTALL_DIR_BIN    := $(patsubst /%,%,$(NIX_INSTALL_DIR))/bin
+NIX_INSTALL_DIR_SHARED := $(patsubst /%,%,$(NIX_INSTALL_DIR))/shared/kBuild
+DEFS += \
+	PATH_KBUILD=\"/$(NIX_INSTALL_DIR_SHARED)\" \
+	PATH_KBUILD_BIN=\"/$(NIX_INSTALL_DIR_BIN)\"
+endif
 					
 #
@@ -53,5 +64,9 @@
 TEMPLATE_BIN_CFLAGS.release     = -O3
 TEMPLATE_BIN_LDFLAGS            = -Zhigh-mem -Zstack=1024
+ ifdef NIX_INSTALL_DIR
+TEMPLATE_BIN_INST               = $(NIX_INSTALL_DIR_BIN)/
+ else
 TEMPLATE_BIN_INST               = kBuild/bin/x86.os2/
+ endif
 endif
 
@@ -61,5 +76,9 @@
 TEMPLATE_BIN_CFLAGS.release     = -O3
 TEMPLATE_BIN_LDFLAGS            = 
+ ifdef NIX_INSTALL_DIR
+TEMPLATE_BIN_INST               = $(NIX_INSTALL_DIR_BIN)/
+ else
 TEMPLATE_BIN_INST               = kBuild/bin/$(BUILD_TARGET_ARCH).$(BUILD_TARGET)/
+ endif
 endif
 
@@ -90,5 +109,9 @@
 	$(PATH_DEV)/x86.win32/sdk200209/lib/AdvAPI32.Lib
 TEMPLATE_BIN_LIBS.profile       = g:/coding/vbox/trunk/out/win32/debug/lib/kPrf2.lib
+ ifdef NIX_INSTALL_DIR
+TEMPLATE_BIN_INST               = $(NIX_INSTALL_DIR_BIN)/
+ else
 TEMPLATE_BIN_INST               = kBuild/bin/x86.win32/
+ endif
 endif
 
@@ -105,8 +128,10 @@
 TEMPLATE_BIN_INCS              += $(PATH_ROOT)/src/gmake/glob /usr/local/include
 endif
+ ifdef NIX_INSTALL_DIR
+TEMPLATE_BIN_INST               = $(NIX_INSTALL_DIR_BIN)/
+ else
 TEMPLATE_BIN_INST               = kBuild/bin/$(BUILD_TARGET_ARCH).$(BUILD_TARGET)/
+ endif
 endif
-
-
 
 #
@@ -120,4 +145,4 @@
 
 
-LIB_KDEP = $(PATH_OUT)/$(TEMPLATE_LIB_INST)$(TOOL_$(TEMPLATE_LIB_TOOL)_ARLIBPREF)kDep$(TOOL_$(TEMPLATE_LIB_TOOL)_ARLIBSUFF)
+LIB_KDEP = $(PATH_OBJ)/src/lib/kDep/$(TOOL_$(TEMPLATE_LIB_TOOL)_ARLIBPREF)kDep$(TOOL_$(TEMPLATE_LIB_TOOL)_ARLIBSUFF)
 
Index: /trunk/Makefile.kmk
===================================================================
--- /trunk/Makefile.kmk	(revision 586)
+++ /trunk/Makefile.kmk	(revision 587)
@@ -1,7 +1,53 @@
 # $Id$
+
+
+DEPTH = .
+include $(PATH_KBUILD)/header.kmk
 
 SUBDIRS = src
 
-DEPTH = .
-include $(PATH_KBUILD)/rules.kmk
 
+ifdef NIX_INSTALL_DIR
+#
+# When doing a unix install, install all the kBuild scripts.
+#
+INSTALLS += kBuild
+kBuild_INST = $(NIX_INSTALL_DIR_SHARED)
+kBuild_SOURCES := \
+        $(foreach src,\
+			$(wildcard kBuild/*.kmk kBuild/tools/*.kmk kBuild/sdks/*.kmk),\
+			$(src)=>$(subst kBuild/,,$(src)))
+
+#
+# And install any binary only tools and dlls.
+#
+INSTALLS += kBuild_bin
+kBuild_bin_INST = $(NIX_INSTALL_DIR_BIN)
+kBuild_bin_SOURCES = \
+	kBuild/bin/$(BUILD_TARGET_ARCH).$(BUILD_TARGET)/kmk_cat$(HOSTSUFF_EXE)=>kmk_cat$(HOSTSUFF_EXE) \
+	kBuild/bin/$(BUILD_TARGET_ARCH).$(BUILD_TARGET)/kmk_mv$(HOSTSUFF_EXE)=>kmk_mv$(HOSTSUFF_EXE) \
+	kBuild/bin/$(BUILD_TARGET_ARCH).$(BUILD_TARGET)/kmk_sed$(HOSTSUFF_EXE)=>kmk_sed$(HOSTSUFF_EXE) \
+	kBuild/bin/$(BUILD_TARGET_ARCH).$(BUILD_TARGET)/kmk_ash$(HOSTSUFF_EXE)=>kmk_ash$(HOSTSUFF_EXE)
+
+ifeq ($(filter-out nt win win32 win64,$(BUILD_TARGET)),)
+kBuild_bin_SOURCES.$(BUILD_TARGET) = \
+	kBuild/bin/$(BUILD_TARGET_ARCH).$(BUILD_TARGET)/cygiconv-2.dll=>cygiconv-2.dll \
+	kBuild/bin/$(BUILD_TARGET_ARCH).$(BUILD_TARGET)/cygintl-1.dll=>cygintl-1.dll \
+	kBuild/bin/$(BUILD_TARGET_ARCH).$(BUILD_TARGET)/cygintl-2.dll=>cygintl-2.dll \
+	kBuild/bin/$(BUILD_TARGET_ARCH).$(BUILD_TARGET)/cygintl-3.dll=>cygintl-3.dll \
+	kBuild/bin/$(BUILD_TARGET_ARCH).$(BUILD_TARGET)/cygwin1.dll=>cygwin1.dll
+endif
+
+## @todo this isn't quite right, but then we will probably never use this on OS/2 anyway.
+kBuild_bin_SOURCES.os2 = \
+	kBuild/bin/$(BUILD_TARGET_ARCH).$(BUILD_TARGET)/gcc29160.dll=>gcc29160.dll \
+	kBuild/bin/$(BUILD_TARGET_ARCH).$(BUILD_TARGET)/gnufu316.dll=>gnufu316.dll \
+	kBuild/bin/$(BUILD_TARGET_ARCH).$(BUILD_TARGET)/Iintl6i.dll=>Iintl6i.dll \
+	kBuild/bin/$(BUILD_TARGET_ARCH).$(BUILD_TARGET)/libc05.dll=>libc05.dll \ 
+	kBuild/bin/$(BUILD_TARGET_ARCH).$(BUILD_TARGET)/libc06.dll=>libc06.dll \ 
+	kBuild/bin/$(BUILD_TARGET_ARCH).$(BUILD_TARGET)/libc061.dll=>libc061.dll
+
+endif
+
+include $(PATH_KBUILD)/footer.kmk
+
