Index: /tags/InnoTek-old-step/kBuild/Examples/Library/Makefile
===================================================================
--- /tags/InnoTek-old-step/kBuild/Examples/Library/Makefile	(revision 497)
+++ /tags/InnoTek-old-step/kBuild/Examples/Library/Makefile	(revision 497)
@@ -0,0 +1,14 @@
+# $Id$
+
+#
+# Library example file.
+#
+
+
+TEMPLATE			:= mylib
+LIBRARIES           := libHello
+libHello_SOURCES    := hello.c
+
+DEPTH = ../../..
+include $(DEPTH)/kBuild/rules.kmk
+
Index: /tags/InnoTek-old-step/kBuild/Examples/Library/config.kmk
===================================================================
--- /tags/InnoTek-old-step/kBuild/Examples/Library/config.kmk	(revision 497)
+++ /tags/InnoTek-old-step/kBuild/Examples/Library/config.kmk	(revision 497)
@@ -0,0 +1,21 @@
+# define template mylib
+TEMPLATE_mylib := Sample template for testing kBuild
+TEMPLATE_mylib_TOOL       := GCC
+TEMPLATE_mylib_DEFS       := MYLIB_DEFS
+TEMPLATE_mylib_INCS       := /mylib_incs
+
+TEMPLATE_mylib_CDEFS      := MYLIB_CDEFS
+TEMPLATE_mylib_CINCS      := /mylib_cincs
+TEMPLATE_mylib_CFLAGS     := -DMYLIB_CFLAGS=1
+TEMPLATE_mylib_COPTS      := Debug
+
+TEMPLATE_mylib_CXXDEFS    := MYLIB_CXXDEFS
+TEMPLATE_mylib_CXXINCS    := /mylib_cxxincs
+TEMPLATE_mylib_CXXFLAGS   := -DMYLIB_CXXFLAGS=1
+TEMPLATE_mylib_CXXOPTS    := Debug
+
+TEMPLATE_mylib_ASDEFS     := MYLIB_ASDEFS
+TEMPLATE_mylib_ASINCS     := /mylib_asincs
+TEMPLATE_mylib_ASFLAGS    := -DMYLIB_ASFLAGS=1
+TEMPLATE_mylib_ASOPTS     := Debug
+						
Index: /tags/InnoTek-old-step/kBuild/Examples/Library/hello.c
===================================================================
--- /tags/InnoTek-old-step/kBuild/Examples/Library/hello.c	(revision 497)
+++ /tags/InnoTek-old-step/kBuild/Examples/Library/hello.c	(revision 497)
@@ -0,0 +1,6 @@
+#include <stdio.h>
+int main()
+{
+    printf("hello world\n");
+    return 0;
+}
Index: /tags/InnoTek-old-step/kBuild/Examples/Makefile
===================================================================
--- /tags/InnoTek-old-step/kBuild/Examples/Makefile	(revision 497)
+++ /tags/InnoTek-old-step/kBuild/Examples/Makefile	(revision 497)
@@ -0,0 +1,12 @@
+# $Id$
+
+#
+# Example makefile
+#
+
+SUBDIRS := Library
+SUBDIRS_AFTER := Program
+
+DEPTH := ../..
+include $(DEPTH)/kBuild/rules.kmk
+
Index: /tags/InnoTek-old-step/kBuild/Examples/Outline/Makefile.kmk
===================================================================
--- /tags/InnoTek-old-step/kBuild/Examples/Outline/Makefile.kmk	(revision 497)
+++ /tags/InnoTek-old-step/kBuild/Examples/Outline/Makefile.kmk	(revision 497)
@@ -0,0 +1,23 @@
+# $Id$
+
+#
+# This is an example makefile.
+#
+
+DEPTH = ../../..
+include $(DEPTH)/kBuild/header.kMk
+
+PROGRAMS = helloworld hello world
+helloworld_SOURCES = hello.c
+hello_SOURCES = hello.c
+world_SOURCES = hello.c
+
+LIBRARIES = helloworld
+
+include $(DEPTH)/kBuild/footer.kMk
+	
+ok:
+	@echo _CFGFILES: $(_CFGFILES)
+	@echo _CFGFILE: $(_CFGFILE)
+#	@echo _CFGDIR: $(_CFGDIR)
+	
Index: /tags/InnoTek-old-step/kBuild/Examples/Outline/config.kmk
===================================================================
--- /tags/InnoTek-old-step/kBuild/Examples/Outline/config.kmk	(revision 497)
+++ /tags/InnoTek-old-step/kBuild/Examples/Outline/config.kmk	(revision 497)
@@ -0,0 +1,8 @@
+# $Id$
+#
+# This is an example configuration file.
+#
+#
+
+#.include "../../config.kMk"
+
Index: /tags/InnoTek-old-step/kBuild/Examples/Outline/hello.c
===================================================================
--- /tags/InnoTek-old-step/kBuild/Examples/Outline/hello.c	(revision 497)
+++ /tags/InnoTek-old-step/kBuild/Examples/Outline/hello.c	(revision 497)
@@ -0,0 +1,6 @@
+#include <stdio.h>
+int main()
+{
+    printf("hello world\n");
+    return 0;
+}
Index: /tags/InnoTek-old-step/kBuild/Examples/Program/Makefile
===================================================================
--- /tags/InnoTek-old-step/kBuild/Examples/Program/Makefile	(revision 497)
+++ /tags/InnoTek-old-step/kBuild/Examples/Program/Makefile	(revision 497)
@@ -0,0 +1,15 @@
+# $Id$
+
+#
+# This is an example makefile.
+#
+
+TOOL = GCC
+PROGRAMS = helloworld hello world
+helloworld_SOURCES = hello.c
+hello_SOURCES = hello.c
+world_SOURCES = hello.c
+
+DEPTH = ../../..
+include $(DEPTH)/kBuild/rules.kMk
+
Index: /tags/InnoTek-old-step/kBuild/Examples/Program/hello.c
===================================================================
--- /tags/InnoTek-old-step/kBuild/Examples/Program/hello.c	(revision 497)
+++ /tags/InnoTek-old-step/kBuild/Examples/Program/hello.c	(revision 497)
@@ -0,0 +1,6 @@
+#include <stdio.h>
+int main()
+{
+    printf("hello world\n");
+    return 0;
+}
Index: /tags/InnoTek-old-step/kBuild/StampOutPredefines.kmk
===================================================================
--- /tags/InnoTek-old-step/kBuild/StampOutPredefines.kmk	(revision 497)
+++ /tags/InnoTek-old-step/kBuild/StampOutPredefines.kmk	(revision 497)
@@ -0,0 +1,151 @@
+# $Id$
+## @file
+#
+# kBuild - Stamp out GNU Make predefines.
+#
+# Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
+#
+#
+# This file is part of kBuild.
+#
+# kBuild is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# kBuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kBuild; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#
+
+#
+# Default variables.
+#
+ifeq ($(MAKEFLAGS),$(MAKEFLAGS:R=x))
+# add the -R makeflag to avoid doing this for submakes
+MAKEFLAGS := R$(MAKEFLAGS)
+
+define def_undefine_default
+ifeq ($(origin $1), default)
+$1:=
+endif
+endef
+									
+_DEFAULT_VARIABLES := .LIBPATTERNS .VARIABLES AR ARFLAGS AS CC CHECKOUT,v CO COFLAGS COMPILE.C COMPILE.F COMPILE.S COMPILE.c COMPILE.cc COMPILE.cpp COMPILE.def COMPILE.f COMPILE.mod COMPILE.p COMPILE.r COMPILE.s CPP CTANGLE CWEAVE CXX F77 F77FLAGS FC GET LD LEX LEX.l LINK.C LINK.F LINK.S LINK.c LINK.cc LINK.cpp LINK.f LINK.o LINK.p LINK.r LINK.s LINT LINT.c M2C MAKEINFO OUTPUT_OPTION PC PREPROCESS.F PREPROCESS.S PREPROCESS.r RM TANGLE TEX TEXI2DVI WEAVE YACC YACC.y
+$(foreach i, $(_DEFAULT_VARIABLES), $(eval $(call def_undefine_default,$(i))))
+_DEFAULT_VARIABLES :=
+def_undefine_default :=
+endif
+
+#
+# Suffixes.
+#
+.SUFFIXES:
+SUFFIXES :=
+
+#
+# Implicit rules
+#
+ifeq ($(MAKEFLAGS),$(MAKEFLAGS:r=x))
+MAKEFLAGS := r$(MAKEFLAGS)
+# add the -r makeflag to avoid doing this for submakes
+
+%.C:
+%.F:
+%.S:
+%.a:
+%.c:
+%.c: %.l
+%.c: %.w
+%.c: %.w %.ch
+%.c: %.y
+%.cc:
+%.ch:
+%.cpp:
+%.def:
+%.dll:
+%.dvi:
+%.dvi: %.tex
+%.dvi: %.texi
+%.dvi: %.texinfo
+%.dvi: %.txinfo
+%.el:
+%.elc:
+%.exe:
+%.f:
+%.f: %.F
+%.f: %.r
+%.h:
+%.info:
+%.info: %.texi
+%.info: %.texinfo
+%.info: %.txinfo
+%.l:
+%.lib:
+%.ln:
+%.ln: %.c
+%.ln: %.l
+%.ln: %.y
+%.mod:
+%.o:
+%.o: %.C
+%.o: %.F
+%.o: %.S
+%.o: %.c
+%.o: %.cc
+%.o: %.cpp
+%.o: %.f
+%.o: %.mod
+%.o: %.p
+%.o: %.r
+%.o: %.s
+%.obj:
+%.out:
+%.out: %
+%.p:
+%.p: %.web
+%.r:
+%.r: %.l
+%.s:
+%.s: %.S
+%.sh:
+%.sym:
+%.sym: %.def
+%.tex:
+%.tex: %.w
+%.tex: %.w %.ch
+%.tex: %.web
+%.texi:
+%.texinfo:
+%.txinfo:
+%.w:
+%.web:
+%.y:
+%: %.C
+%: %.F
+%: %.S
+%: %.c
+%: %.cc
+%: %.cpp
+%: %.f
+%: %.mod
+%: %.o
+%: %.p
+%: %.r
+%: %.s
+%: %.sh
+%:: %,v
+%:: RCS/%
+%:: RCS/%,v
+%:: SCCS/s.%
+%:: s.%
+(%): %
+endif
+
+
Index: /tags/InnoTek-old-step/kBuild/cfg/x86.win32.vc2003.kmk
===================================================================
--- /tags/InnoTek-old-step/kBuild/cfg/x86.win32.vc2003.kmk	(revision 497)
+++ /tags/InnoTek-old-step/kBuild/cfg/x86.win32.vc2003.kmk	(revision 497)
@@ -0,0 +1,102 @@
+# $Id$
+## @file
+#
+# kBuild - x86 Win32 Visual C++ Toolkit 2003
+#
+# Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
+#
+#
+# This file is part of kBuild.
+#
+# kBuild is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# kBuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kBuild; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#
+
+PATH_X86_WIN32_VC2003               ?= $(PATH_DEV)/x86.win32/VC2003
+
+# C compiler
+X86_WIN32_VC2003_CC	                := $(EXEC_X86_WIN32) $(PATH_X86_WIN32_VC2003)/bin/cl.exe -TC -c -nologo
+X86_WIN32_VC2003_CC_RELEASE         := -Ogitb2 -Oy-
+X86_WIN32_VC2003_CC_DEBUG           := -DDEBUG=1 -Od
+X86_WIN32_VC2003_CC_WARN            := -W3
+X86_WIN32_VC2003_CC_WARN_LOW        := -W2
+X86_WIN32_VC2003_CC_WARN_ALL        := -Wall
+X86_WIN32_VC2003_CCINCS             := $(PATH_VC2003)/include
+
+# C++ compiler			
+X86_WIN32_VC2003_CXX                := $(EXEC_X86_WIN32) $(PATH_X86_WIN32_VC2003)/bin/cl.exe -TD -c -nologo
+X86_WIN32_VC2003_CXX_RELEASE        := -Ogitb2 -Oy-
+X86_WIN32_VC2003_CXX_DEBUG          := -DDEBUG=1 -Od
+X86_WIN32_VC2003_CXX_WARN           := -W3
+X86_WIN32_VC2003_CXX_WARN_LOW       := -W2
+X86_WIN32_VC2003_CXX_WARN_ALL       := -Wall
+X86_WIN32_VC2003_CXXINCS            := $(PATH_VC2003)/include
+
+# Link editor
+X86_WIN32_VC2003_LD                 := $(EXEC_X86_WIN32) $(PATH_VC2003)/bin/link.exe -nologo
+
+# Lib directories and libraries
+PATH_X86_WIN32_VC2003_LIB           := $(PATH_X86_WIN32_VC2003)/lib
+LIB_X86_WIN32_VC2003_KERNEL32       := $(PATH_X86_WIN32_VC2003_LIB)/lib/kernel32.lib
+LIB_X86_WIN32_VC2003_LIBC           := $(PATH_X86_WIN32_VC2003_LIB)/lib/libc.lib
+LIB_X86_WIN32_VC2003_LIBCD          := $(PATH_X86_WIN32_VC2003_LIB)/lib/libcd.lib
+LIB_X86_WIN32_VC2003_LIBCMT         := $(PATH_X86_WIN32_VC2003_LIB)/lib/libcmt.lib
+LIB_X86_WIN32_VC2003_LIBCP          := $(PATH_X86_WIN32_VC2003_LIB)/lib/libcpt.lib
+LIB_X86_WIN32_VC2003_LIBCPD         := $(PATH_X86_WIN32_VC2003_LIB)/lib/libcpd.lib
+LIB_X86_WIN32_VC2003_LIBCPMT        := $(PATH_X86_WIN32_VC2003_LIB)/lib/libcpmt.lib
+LIB_X86_WIN32_VC2003_MSCOREE        := $(PATH_X86_WIN32_VC2003_LIB)/lib/mscoree.lib
+LIB_X86_WIN32_VC2003_OLDNAMES       := $(PATH_X86_WIN32_VC2003_LIB)/lib/oldnames.lib
+			
+
+# @todo implement options
+
+
+# C++ sources: $1 == output base name, $2 == source, $3 == normalized main target,
+define def_x86_win32_vc2003_compile_cxx
+$1/$(basename $2)$(SUFF_OBJ): $2 $(dir $1/$(basename $2))
+	$(X86_WIN32_VC2003_CXX) -c $($3_$2_CXXFLAGS) $($2_CXXFLAGS) $($3_CXXFLAGS) $(X86_WIN32_VC2003_CXXFLAGS) $(X86_WIN32_VC2003_CXXFLAGS_$(BUILD_TYPE)) \
+		$(addprefix -I, $($3_$2_CXXINCS) $($3_$2_INCS) $($2_CXXINCS) $($2_INCS) $($3_CXXINCS) $($3_INCS) $(X86_WIN32_VC2003_CXXINCS) $(INCS)) \
+		$(addprefix -D, $($3_$2_CXXDEFS) $($3_$2_DEFS) $($2_CXXDEFS) $($2_DEFS) $($3_CXXDEFS) $($3_DEFS) $(X86_WIN32_VC2003_CXXDEFS) $(DEFS)) \
+		-Fo$$@ -Fa$$@.lst $3
+
+_DIRS    += $(dir $1/$(basename $2))
+_OBJS_$3 += $1/$(basename $2)$(SUFF_OBJ)
+endef
+		
+# C sources: $1 == target root dir, $2 == source, $3 == normalized main target
+define def_x86_win32_vc2003_compile_cc
+$1/$(basename $2)$(SUFF_OBJ): $2 $(dir $1/$(basename $2))
+	$(X86_WIN32_VC2003_CC) -c $($3_$2_CCFLAGS) $($2_CCFLAGS) $($3_CCFLAGS) $(X86_WIN32_VC2003_CCFLAGS) $(X86_WIN32_VC2003_CCFLAGS_$(BUILD_TYPE)) \
+		$(addprefix -I, $($3_$2_CCINCS) $($3_$2_INCS) $($2_CCINCS) $($2_INCS) $($3_CCINCS) $($3_INCS) $(X86_WIN32_VC2003_CCINCS) $(INCS)) \
+		$(addprefix -D, $($3_$2_CCDEFS) $($3_$2_DEFS) $($2_CCDEFS) $($2_DEFS) $($3_CCDEFS) $($3_DEFS) $(X86_WIN32_VC2003_CCDEFS) $(DEFS)) \
+		-Fo$$@ -Fa$$@.lst $3
+
+_DIRS    += $(dir $1/$(basename $2))
+_OBJS_$3 += $1/$(basename $2)$(SUFF_OBJ)
+endef
+
+# LD: $1 == target root dir, $2 == target name, $3 == normalized main target
+define def_x86_win32_vc2003_link
+$1/$2: $2 $(dir $1/$2) \
+		$(_OBJS_$3) \
+		$($3_DEFFILE) \
+		$($3_LIBS)
+	$(X86_WIN32_VC2003_LD) $($3_$2_LDFLAGS) $($2_LDFLAGS) $($3_LDFLAGS) $(X86_WIN32_VC2003_LDFLAGS) $(X86_WIN32_VC2003_LDFLAGS_$(BUILD_TYPE)) \
+		-OUT:$$@ -MAP:$$@ $($3_DEFFILE) $($3_LIBS)
+
+_DIRS += $(dir $1/$2)
+_OBJS += $(_OBJS_$3)
+endef
+
Index: /tags/InnoTek-old-step/kBuild/config.kmk
===================================================================
--- /tags/InnoTek-old-step/kBuild/config.kmk	(revision 497)
+++ /tags/InnoTek-old-step/kBuild/config.kmk	(revision 497)
@@ -0,0 +1,117 @@
+# $Id$
+#
+# Base config for kBuild
+#
+# It is recommended to include this file in your config.kMk file and then
+# override any default options defined there. In addition you will have to
+# decide the location of the object directory in your config.kMk file, and
+# of course manage to find this file.
+#
+#
+# Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net>
+#
+#
+# This file is part of kBuild.
+#
+# kBuild is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# kBuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kBuild; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#
+
+ifdef rewrite_me
+
+.ifndef __KBLD_config_kMk_
+__KBLD_config_kMk_ = 1
+
+#
+# Determin default target (if not set) / Check default target (if set)
+#
+.ifndef TARGET_MACHINE_TYPE
+## The TARGET_MACHINE_TYPE is a generalized machine type for the
+# default target machine. Current types are "UX" for UNIX like systems
+# and "PC" for PC like systems. PC like systems are DOS, OS/2, and Win32.
+# While the rest is UNIX like at the moment.
+.if ${MACHINE} == "ibmos2" || ${MACHINE} == "win32" || ${MACHINE} == "dos"
+TARGET_MACHINE_TYPE := PC
+.else
+TARGET_MACHINE_TYPE := UX
+.endif
+
+.elif ${TARGET_MACHINE_TYPE} != "UX" && ${TARGET_MACHINE_TYPE} != "PC"
+.error Invalid TARGET_MACHINE_TYPE define. Must be either UX or PC.
+.endif
+
+## @group Typical PC Suffixes
+# Note that suffixes includes the '.' if present.
+# @{
+SFX_EXE_PC      := .exe
+SFX_DLL_PC      := .dll
+SFX_DEF_PC      := .def
+SFX_RES_PC      := .res
+SFX_OBJ_PC      := .obj
+SFX_CLS_PC      := .class
+# @}
+
+## @group Typical UNIX Suffixes
+# Note that suffixes includes the '.' if present.
+# @{
+SFX_EXE_UX      :=
+SFX_DLL_UX      := .so
+SFX_OBJ_UX      := .o
+SFX_CLS_UX      := .class
+# @}
+
+
+## @group Default Target Suffixes.
+# @{
+## Executable Program.
+SFX_EXE         = ${SFX_EXE_${TARGET_MACHINE_TYPE}}
+## DLL/Shared Library.
+SFX_DLL         = ${SFX_DLL_${TARGET_MACHINE_TYPE}}
+## Object file.
+SFX_OBJ         = ${SFX_OBJ_${TARGET_MACHINE_TYPE}}
+## Resource object file (PC thingy).
+SFX_RES         = ${SFX_RES_${TARGET_MACHINE_TYPE}}
+## Definition (~=linkerscript) file (PC thingy).
+SFX_DEF         = ${SFX_RES_${TARGET_MACHINE_TYPE}}
+## Java class files
+SFX_CLS         = ${SFX_RES_${TARGET_MACHINE_TYPE}}
+## @}
+
+
+## @group Suffix lists used for transformations
+# @{
+## C source file suffixes
+SFXS_C          := .c
+## C++ source file suffixes
+SFXS_CXX        := .cpp .cxx .cc .c++
+## C/C++ header file suffixes (list)
+SFXS_H          := .h .hpp
+## Java source file suffixes
+SFXS_JAVA       := .java .jav
+## IDL source file suffixes
+SFXS_IDL        := .idl
+## @}
+
+
+## @group kBuild helper defines.
+# @{
+## The kBuild path.
+KBUILD_PATH     := $(MAKEFILE:H)
+## The rules file.
+KBUILD_RULEZ    := $(KBUILD_PATH)/rules.kMk
+## @}
+
+.endif
+endif
Index: /tags/InnoTek-old-step/kBuild/env.sh
===================================================================
--- /tags/InnoTek-old-step/kBuild/env.sh	(revision 497)
+++ /tags/InnoTek-old-step/kBuild/env.sh	(revision 497)
@@ -0,0 +1,182 @@
+#!/bin/bash
+# $Id$
+## @file
+#
+# Environment setup script.
+#
+# Copyright (c) 2005 knut st. osmundsen <bird@innotek.de>
+#
+#
+# This file is part of kBuild.
+#
+# kBuild is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# kBuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kBuild; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#
+#set -x
+
+# kBuild path.
+if [ -z "$PATH_KBUILD" ]; then
+    PATH_KBUILD=`readlink -f $0`
+    PATH_KBUILD=`dirname "$PATH_KBUILD"`
+fi
+if [ ! -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;
+    exit 1;
+fi
+export PATH_KBUILD
+echo "dbg: PATH_KBUILD=$PATH_KBUILD"
+
+# Type.
+if [ -z "$BUILD_TYPE" ]; then
+    BUILD_TYPE=debug
+fi
+export BUILD_TYPE
+echo "dbg: BUILD_TYPE=$BUILD_TYPE"
+
+
+# Host platform.
+if [ -z "$BUILD_PLATFORM_CPU" ]; then
+    BUILD_PLATFORM_CPU=`uname -m`
+fi
+export BUILD_PLATFORM_CPU
+echo "dbg: BUILD_PLATFORM_CPU=$BUILD_PLATFORM_CPU"
+
+if [ -z "$BUILD_PLATFORM_ARCH" ]; then
+    case "$BUILD_PLATFORM_CPU" in
+        i[3456789]86|x86)
+            BUILD_PLATFORM_ARCH='x86'
+            ;;
+
+        *)  echo "$0: unknown cpu/arch - $BUILD_PLATFORM_CPU"
+            sleep 1
+            exit 1
+            ;;
+    esac
+
+fi
+export BUILD_PLATFORM_ARCH
+echo "dbg: BUILD_PLATFORM_ARCH=$BUILD_PLATFORM_ARCH"
+
+
+if [ -z "$BUILD_PLATFORM" ]; then
+    BUILD_PLATFORM=`uname -o`
+    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
+            ;;
+
+        *)
+            echo "$0: unknown os $BUILD_PLATFORM"
+            sleep 1
+            exit 1
+            ;;
+    esac
+fi
+export BUILD_PLATFORM
+echo "dbg: BUILD_PLATFORM=$BUILD_PLATFORM"
+
+
+# Target platform.
+if [ -z "$BUILD_TARGET_CPU" ]; then
+    BUILD_TARGET_CPU=$BUILD_PLATFORM_CPU
+fi
+export BUILD_TARGET_CPU
+echo "dbg: BUILD_TARGET_CPU=$BUILD_TARGET_CPU"
+
+if [ -z "$BUILD_TARGET_ARCH" ]; then
+    case "$BUILD_TARGET_CPU" in
+        i[3456789]86|x86)
+            BUILD_TARGET_ARCH='x86'
+            ;;
+
+        *)  echo "$0: unknown cpu/arch - $BUILD_TARGET_CPU"
+            sleep 1
+            exit 1
+            ;;
+    esac
+
+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_TYPE"
+
+
+# Determin executable extension and path separator.
+_SUFF_EXE=
+_PATH_SEP=":"
+case "$BUILD_PLATFORM" in
+    os2|win32|winnt|win2k|winxp)
+        _SUFF_EXE=".exe"
+        _PATH_SEP=";"
+        ;;
+esac
+
+# Make shell
+export MAKESHELL="$PATH_KBUILD/bin/$BUILD_PLATFORM_ARCH.$BUILD_PLATFORM/ash${_SUFF_EXE}";
+
+# The PATH.
+PATH="$PATH_KBUILD/bin/$BUILD_PLATFORM_ARCH.$BUILD_PLATFORM/${_PATH_SEP}$PATH"
+export PATH
+echo "dbg: PATH=$PATH"
+
+# Sanity and x bits.
+if [ ! -d "$PATH_KBUILD/bin/$BUILD_PLATFORM_ARCH.$BUILD_PLATFORM/" ]; then
+    echo "$0: warning: The bin directory for this platform doesn't exists. ($PATH_KBUILD/bin/$BUILD_PLATFORM_ARCH.$BUILD_PLATFORM/)"
+else
+    for prog in kmk kDepCCxx cat cp mkdir mv rm sed;
+    do
+        chmod a+x $PATH_KBUILD/bin/$BUILD_PLATFORM_ARCH.$BUILD_PLATFORM/${prog} > /dev/null 2>&1
+        if [ ! -f "$PATH_KBUILD/bin/$BUILD_PLATFORM_ARCH.$BUILD_PLATFORM/${prog}${_SUFF_EXE}" ]; then
+            echo "$0: warning: The ${prog} program doesn't exist for this platform. ($PATH_KBUILD/bin/$BUILD_PLATFORM_ARCH.$BUILD_PLATFORM/${prog}${_SUFF_EXE})"
+        fi
+    done
+fi
+
+unset _SUFF_EXE
+unset _PATH_SEP
+
+# Execute command or spawn shell.
+if [ $# -eq 0 ]; then
+    echo "$0: info: Spawning work shell..."
+    if [ "$TERM" != 'dumb'  ] && [ -n "$BASH" ]; then
+        export PS1='\[\033[01;32m\]\u@\h \[\033[01;34m\]\W \$ \[\033[00m\]'
+    fi
+    $SHELL -i
+else
+    echo "$0: info: Executing command: $*"
+    $*
+fi
Index: /tags/InnoTek-old-step/kBuild/footer.kmk
===================================================================
--- /tags/InnoTek-old-step/kBuild/footer.kmk	(revision 497)
+++ /tags/InnoTek-old-step/kBuild/footer.kmk	(revision 497)
@@ -0,0 +1,1628 @@
+# $Id$
+## @file
+#
+# kBuild - File included at top of makefile.
+#
+# Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
+#
+#
+# This file is part of kBuild.
+#
+# kBuild is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version source of the License, or
+# (at your option) any later version.
+#
+# kBuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kBuild; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite typetype0, Boston, MA  0sourcetargettargettarget-targettype07  USA
+#
+#
+
+ifndef __footer_kmk__
+# start-of-file-content
+
+#
+# Variables.
+# (Some of these need initialization before including definitions using them.)
+#
+
+# all targets.
+ALL_TARGETS := \
+	$(BLDPROGS)    $(BLDPROGS.$(BUILD_PLATFORM)) \
+	$(LIBRARIES)   $(LIBRARIES.$(BUILD_TARGET)) \
+	$(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)) \
+	$(DLLS)        $(DLLS.$(BUILD_TARGET)) \
+	$(PROGRAMS)    $(PROGRAMS.$(BUILD_TARGET)) \
+	$(SYSMODS)     $(SYSMODS.$(BUILD_TARGET)) \
+	$(OTHERS)      $(OTHERS.$(BUILD_TARGET))
+
+# dependency files.
+_DEPFILES :=
+
+# All kind of output files except for _OBJS and _DEPFILES.
+# Compiling or linking definition outputting other things that $@ and any
+# required dependency file must add those output files to this variable.
+_OUT_FILES :=
+
+# all of a type
+_OBJS     :=
+_BLDPROGS :=
+_LIBS     :=
+_DLLS     :=
+_PROGRAMS :=
+_SYSMODS  :=
+_DIRS     :=
+_IMPORT_LIBS :=
+
+# misc
+pass_prev :=
+
+
+# all objs of a specific target
+define def_objs_var
+_OBJS_$target :=
+endef
+$(foreach target, $(ALL_TARGETS), $(eval _OBJS_$(target) := ))
+
+#
+# Basic macros
+#
+
+## Figure out the tool for a source
+# @param    $target      source file
+# @param    $source      normalized main target
+# @param    $type      tooltype
+# @param    bld_trg      build target.
+_SOURCE_TOOL = $(strip $(firstword \
+	$($(target)_$(source)_$(type)TOOL.$(bld_trg)) \
+	$($(target)_$(source)_$(type)TOOL) \
+	$($(target)_$(source)_TOOL.$(bld_trg)) \
+	$($(target)_$(source)_TOOL) \
+	$($(target)_$(type)TOOL.$(bld_trg)) \
+	$($(target)_$(type)TOOL) \
+	$($(target)_TOOL.$(bld_trg)) \
+	$($(target)_TOOL) \
+	$($(source)_$(type)TOOL.$(bld_trg)) \
+	$($(source)_$(type)TOOL) \
+	$($(source)_TOOL.$(bld_trg)) \
+	$($(source)_TOOL) \
+	$($(type)TOOL.$(bld_trg)) \
+	$($(type)TOOL) \
+	$(TOOL.$(bld_trg)) \
+	$(TOOL) ))
+
+## Figure out the tool for a target.
+# @param    $target 		normalized target.
+# @param    $source      tooltype.
+# @param    bld_trg      build target.
+_TARGET_TOOL = $(strip $(firstword \
+	$($(target)_$(source)TOOL.$(bld_trg)) \
+	$($(target)_$(source)TOOL) \
+	$($(target)_TOOL.$(bld_trg)) \
+	$($(target)_TOOL) \
+	$($(source)TOOL.$(bld_trg)) \
+	$($(source)TOOL) \
+	$(TOOL.$(bld_trg)) \
+	$(TOOL) \
+	))
+
+## Removes the drive letter from a path (if it has one)
+# @param	$1 		the path
+no-drive=$(word $(words	$(subst :, ,$(1))),$(subst :, ,$(1)))
+
+## Removes the root slash from a path (if it has one)
+# @param	$1 		the path
+no-root-slash=$(patsubst /%,%,$(1))
+
+## Figure out where to put object files.
+# @param    $1      source file
+# @param    $2      normalized main target
+_OBJECT_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(basename $(patsubst $(PATH_TARGET)/$(2)/%,gen/%,$(1)))))
+
+## Figure out where to put object files.
+# @param    $1      real target name.
+# @param    $2      normalized main target
+_TARGET_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(basename $(1))))
+
+
+#
+# Check syntax which leads to weird syntax errors.
+#
+
+## Check
+# @param	$(target)	Target name.
+define def_check_target
+ifneq ("$($(target)_TEMPLATE)","$(strip $($(target)_TEMPLATE))")
+$$(error $(target) have an incorrect template name. Remove any tabs!)
+endif
+endef
+$(foreach target, $(ALL_TARGETS),$(eval $(def_check_target)))
+
+
+#
+# Include templates
+#
+_TEMPLATES := $(TEMPLATE)
+define def_templates
+ifdef $(target)_TEMPLATE
+_TEMPLATES += $($(target)_TEMPLATE)
+endif
+endef
+$(foreach target, $(ALL_TARGETS), $(eval $(def_templates)))
+_TEMPLATES := $(sort $(_TEMPLATES))
+# $ (warning dbg: _TEMPLATES=$(_TEMPLATES))
+
+define def_templates_include
+ifndef TEMPLATE_$(template)
+include $(firstword $(wildcard $(PATH_KBUILD)/templates/$(template).kmk))
+endif
+endef
+$(foreach template, $(_TEMPLATES), $(eval $(def_templates)))
+
+
+#
+# Common Inheritance
+#
+
+## Inherit defaults property
+# @param    $(prop)     Property name
+# @param    $(target)   Target name.
+define def_inherit_defaults_one
+ifndef $(target)_$(prop)
+ifndef $(target)_$(prop).$(BUILD_TARGET)
+ifdef $(prop)
+$$(eval $(target)_$(prop) := $($(prop)))
+endif
+ifdef $(prop).$(BUILD_TARGET)
+$$(eval $(target)_$(prop).$(BUILD_TARGET) := $($(prop).$(BUILD_TARGET)))
+endif
+endif
+endif
+endef
+
+## Inherit default properties for one target.
+# A bit tricky this one, but it depends a bit on whether or not TEMPLATE
+# is inherited from the default properties.
+# @param    $(target)	Target name
+#
+define def_inherit_defaults
+ifdef $(target)_TEMPLATE
+ifeq ($(strip $(TEMPLATE_$($(target)_TEMPLATE)_TOOL) $(TEMPLATE_$($(target)_TEMPLATE)_TOOL.$(BUILD_TARGET))),)
+$$(foreach prop,TOOL, $$(eval $$(def_inherit_defaults_one)))
+endif
+ifeq ($(strip $(TEMPLATE_$($(target)_TEMPLATE)_SDKS) $(TEMPLATE_$($(target)_TEMPLATE)_SDKS.$(BUILD_TARGET))),)
+$$(foreach prop,SDKS, $$(eval $$(def_inherit_defaults_one)))
+endif
+else
+$$(foreach prop,TEMPLATE TOOL SDKS, $$(eval $$(def_inherit_defaults_one)))
+endif
+endef
+# Inherit default properties.
+# !!!!!!THIS IS MESSY AND NOT NECESSARY!!!!!!
+$(foreach target, $(ALL_TARGETS),$(eval $(def_inherit_defaults)))
+
+
+## Inherit one template property in a accumulative manner.
+# @param    $(prop)     Property name
+# @param    $(target)	Target name
+# @todo fix the precedence order for some properties.
+define def_inherit_template_one
+ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
+ifndef $(target)_$(prop)
+#$$ (warning dbgtarget: $(target)_$(prop):='$(TEMPLATE_$($(target)_TEMPLATE)_$(prop))' TEMPLATE_$($(target)_TEMPLATE)_$(prop))
+$$(target)_$$(prop) := $$(TEMPLATE_$$($$(target)_TEMPLATE)_$$(prop))
+endif
+endif
+ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)
+ifndef $(target)_$(prop).$(BUILD_TARGET)
+#$$ (warning dbgsource: $(target)_$(prop).$(BUILD_TARGET)="TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)" TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
+$$(target)_$$(prop).$$(BUILD_TARGET) := $$(TEMPLATE_$$($$(target)_TEMPLATE)_$$(prop).$$(BUILD_TARGET))
+endif
+endif
+endef
+
+## Inherit one template property.
+# @param    $(prop)     Property name
+# @param    $(target)	Target name
+define def_inherit_template_one_accumulate
+ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop)
+#$$ (warning dbgtype: TEMPLATE_$($(target)_TEMPLATE)_$(prop) $(target)_$(prop)=$($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
+$$(eval $(target)_$(prop) := $($(target)_$(prop)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop)))
+#$$ (warning dbgtype: $(target)_$(prop)=$($(target)_$(prop)))
+endif
+ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)
+#$$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE))
+$$(eval $(target)_$(prop).$(BUILD_TYPE) := $($(target)_$(prop).$(BUILD_TYPE)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TYPE)))
+endif
+ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)
+#$$ (warning dbg4: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET))
+$$(eval $(target)_$(prop).$(BUILD_TARGET) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET)))
+endif
+ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU)
+#$$ (warning dbg5: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU))
+$$(eval $(target)_$(prop).$(BUILD_TARGET_CPU) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_CPU)))
+endif
+ifdef TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH)
+#$$ (warning dbg6: TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH))
+$$(eval $(target)_$(prop).$(BUILD_TARGET_ARCH) := $($(target)_$(prop).$(BUILD_TARGET)) $(TEMPLATE_$($(target)_TEMPLATE)_$(prop).$(BUILD_TARGET_ARCH)))
+endif
+endef
+
+
+## Inherit template properties for on target.
+# @param    $(target)    Target name.
+define def_inherit_template
+$$(foreach prop, TOOL ARTOOL CTOOL CXXTOOL ASTOOL LDTOOL\
+	,$$(eval $$(def_inherit_template_one)))
+$$(foreach prop,SDKS DEFS INCS COPTS CFLAGS CDEFS CINCS CXXOPTS CXXFLAGS CXXDEFS CXXINCS ASOPTS ASFLAGS ASDEFS ASINCS LDFLAGS LIBS LIBPATH \
+	        BLD_TYPE BLD_TRG BLD_TRG_ARCH BLD_TRG_CPU\
+	,$$(eval $$(def_inherit_template_one_accumulate)))
+endef
+# Inherit template properties
+$(foreach target, $(ALL_TARGETS),$(eval $(def_inherit_template)))
+
+
+#
+# Include tools
+#
+_TOOLS := $(TOOL)
+define def_tools_target_source
+$(foreach tool,\
+	$($(source)_TOOL.$(BUILD_TARGET)) $($(target)_$(source)_TOOL.$(BUILD_TARGET))\
+	$($(source)_TOOL) $($(target)_$(source)_TOOL)\
+	$($(source)_CTOOL.$(BUILD_TARGET)) $($(target)_$(source)_CTOOL.$(BUILD_TARGET))\
+	$($(source)_CTOOL) $($(target)_$(source)_CTOOL)\
+	$($(source)_CXXTOOL.$(BUILD_TARGET)) $($(target)_$(source)_CXXTOOL.$(BUILD_TARGET))\
+	$($(source)_CXXTOOL) $($(target)_$(source)_CXXTOOL)\
+	$($(source)_ASTOOL.$(BUILD_TARGET)) $($(target)_$(source)_ASTOOL.$(BUILD_TARGET))\
+	$($(source)_ASTOOL) $($(target)_$(source)_ASTOOL)\
+	$($(source)_ARTOOL.$(BUILD_TARGET)) $($(target)_$(source)_ARTOOL.$(BUILD_TARGET))\
+	$($(source)_ARTOOL) $($(target)_$(source)_ARTOOL)\
+	$($(source)_LDTOOL.$(BUILD_TARGET)) $($(target)_$(source)_LDTOOL.$(BUILD_TARGET))\
+	$($(source)_LDTOOL) $($(target)_$(source)_LDTOOL)\
+	,$(eval _TOOLS += $(tool)))
+endef
+define def_tools_target
+$(foreach tool,\
+	$($(target)_TOOL.$(BUILD_TARGET))\
+	$($(target)_TOOL)\
+	$($(target)_CTOOL.$(BUILD_TARGET))\
+	$($(target)_CTOOL)\
+	$($(target)_CXXTOOL.$(BUILD_TARGET))\
+	$($(target)_CXXTOOL)\
+	$($(target)_ASTOOL.$(BUILD_TARGET))\
+	$($(target)_ASTOOL)\
+	$($(target)_ARTOOL.$(BUILD_TARGET))\
+	$($(target)_ARTOOL)\
+	$($(target)_LDTOOL.$(BUILD_TARGET))\
+	$($(target)_LDTOOL)\
+	,$(eval _TOOLS += $(tool)))
+$(foreach source, $($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TYPE)) \
+	, $(eval $(def_tools_target_source)))
+endef
+$(foreach target, $(ALL_TARGETS), $(eval $(def_tools_target)))
+_TOOLS := $(sort $(_TOOLS))
+
+define def_tools_include
+ifndef TOOL_$(tool)
+include $(firstword $(wildcard $(PATH_KBUILD)/tools/$(tool).kmk))
+endif
+endef
+$(foreach tool, $(_TOOLS), $(eval $(def_tools_include)))
+
+
+#
+# Include SDKs
+#
+_SDKS := $(SDKS)
+define def_sdks_target_source
+$(foreach sdk, $($(source)_SDKS) $($(source)_SDKS.$(BUILD_TARGET)) $($(source)_SDKS.$(BUILD_TYPE)) \
+			   $($(target)_$(source)_SDKS) $($(target)_$(source)_SDKS.$(BUILD_TARGET)) $($(target)_$(source)_SDKS.$(BUILD_TYPE)), \
+	$(eval _SDKS += $(sdk)))
+endef
+define def_sdks_target
+$(foreach sdk, $($(target)_SDKS) $($(target)_SDKS.$(BUILD_TARGET)) $($(target)_SDKS.$(BUILD_TYPE))\
+	, $(eval _SDKS += $(sdk)))
+$(foreach source, $($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TYPE))\
+	, $(eval $(def_sdks_target_source)))
+endef
+$(foreach target, $(ALL_TARGETS), $(eval $(def_sdks_target)))
+_SDKS := $(sort $(_SDKS))
+
+define def_sdks_include_one
+ifndef SDK_$(sdk)
+include $(firstword $(wildcard $(PATH_KBUILD)/sdks/$(sdk).kmk))
+endif
+endef
+$(foreach sdk, $(_SDKS), $(eval $(def_sdks_include_one)))
+
+#
+# Object processing.
+#
+
+
+## Generic macro for processing C, C++ and Assembly sources.
+# @param    $(target)     Normalized target name.
+# @param    $(source)     Source file name.
+# @param    $(type)       Source type. {C,CXX,AS}
+# @param    bld_type      Build type.
+# @param    bld_trg       Build target.
+# @param    bld_trg_arch  Build target arch.
+# @param    bld_trg_cpu   Build target cpu.
+#
+# @remark   I've no clue why I've to $(eval ..) everything in this define. MAKE bug?
+# @remark	I now have a clue. Have to use $$ if not.
+define def_target_source_c_cpp_asm
+#$ (warning dbg: def_target_source_c_cpp_asm: source='$(source)' target='$(target)' type='$(type)')
+
+$(eval tool:=$(call _SOURCE_TOOL,$(source),$(target),$(type)))
+$(eval outbase     := $(call _OBJECT_BASE,$(source),$(target)))
+$(eval PATH_$(target)_$(source) := $(patsubst %/,%,$(dir $(outbase))))
+$(eval dirdep      := $(dir $(outbase)).dir_created)
+$(eval defs        :=\
+	$(TOOL_$(tool)_DEFS)\
+	$(TOOL_$(tool)_DEFS.$(bld_type))\
+	$(TOOL_$(tool)_DEFS.$(bld_trg))\
+	$(TOOL_$(tool)_DEFS.$(bld_trg_arch))\
+	$(TOOL_$(tool)_DEFS.$(bld_trg_cpu))\
+	$(TOOL_$(tool)_$(type)DEFS)\
+	$(TOOL_$(tool)_$(type)DEFS.$(bld_type))\
+	$(foreach sdk, $(SDKS.$(bld_trg)) \
+				   $(SDKS.$(bld_type)) \
+				   $(SDKS),\
+	$(SDK_$(sdk)_DEFS)\
+	$(SDK_$(sdk)_DEFS.$(bld_type))\
+	$(SDK_$(sdk)_DEFS.$(bld_trg))\
+	$(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
+	$(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
+	$(SDK_$(sdk)_$(type)DEFS)\
+	$(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
+	$(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
+	$(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
+	$(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
+	$(DEFS)\
+	$(DEFS.$(bld_type))\
+	$(DEFS.$(bld_trg))\
+	$(DEFS.$(bld_trg_arch))\
+	$(DEFS.$(bld_trg_cpu))\
+	$($(type)DEFS)\
+	$($(type)DEFS.$(bld_type))\
+	$($(type)DEFS.$(bld_trg))\
+	$($(type)DEFS.$(bld_trg_arch))\
+	$($(type)DEFS.$(bld_trg_cpu))\
+	$(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
+				   $($(target)_SDKS.$(bld_type)) \
+				   $($(target)_SDKS),\
+	$(SDK_$(sdk)_DEFS)\
+	$(SDK_$(sdk)_DEFS.$(bld_type))\
+	$(SDK_$(sdk)_DEFS.$(bld_trg))\
+	$(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
+	$(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
+	$(SDK_$(sdk)_$(type)DEFS)\
+	$(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
+	$(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
+	$(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
+	$(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
+	$($(target)_DEFS)\
+	$($(target)_DEFS.$(bld_type))\
+	$($(target)_DEFS.$(bld_trg))\
+	$($(target)_DEFS.$(bld_trg_arch))\
+	$($(target)_DEFS.$(bld_trg_cpu))\
+	$($(target)_$(type)DEFS)\
+	$($(target)_$(type)DEFS.$(bld_type))\
+	$($(target)_$(type)DEFS.$(bld_trg))\
+	$($(target)_$(type)DEFS.$(bld_trg_arch))\
+	$($(target)_$(type)DEFS.$(bld_trg_cpu))\
+	$(foreach sdk, $($(source)_SDKS.$(bld_trg)) \
+				   $($(source)_SDKS.$(bld_type)) \
+				   $($(source)_SDKS),\
+	$(SDK_$(sdk)_DEFS)\
+	$(SDK_$(sdk)_DEFS.$(bld_type))\
+	$(SDK_$(sdk)_DEFS.$(bld_trg))\
+	$(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
+	$(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
+	$(SDK_$(sdk)_$(type)DEFS)\
+	$(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
+	$(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
+	$(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
+	$(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
+	$($(source)_DEFS)\
+	$($(source)_DEFS.$(bld_type))\
+	$($(source)_DEFS.$(bld_trg))\
+	$($(source)_DEFS.$(bld_trg_arch))\
+	$($(source)_DEFS.$(bld_trg_cpu))\
+	$($(source)_$(type)DEFS)\
+	$($(source)_$(type)DEFS.$(bld_type))\
+	$($(source)_$(type)DEFS.$(bld_trg))\
+	$($(source)_$(type)DEFS.$(bld_trg_arch))\
+	$($(source)_$(type)DEFS.$(bld_trg_cpu))\
+	$(foreach sdk, $($(target)_$(source)_SDKS.$(bld_trg)) \
+				   $($(target)_$(source)_SDKS.$(bld_type)) \
+				   $($(target)_$(source)_SDKS),\
+	$(SDK_$(sdk)_DEFS)\
+	$(SDK_$(sdk)_DEFS.$(bld_type))\
+	$(SDK_$(sdk)_DEFS.$(bld_trg))\
+	$(SDK_$(sdk)_DEFS.$(bld_trg_arch))\
+	$(SDK_$(sdk)_DEFS.$(bld_trg_cpu))\
+	$(SDK_$(sdk)_$(type)DEFS)\
+	$(SDK_$(sdk)_$(type)DEFS.$(bld_type))\
+	$(SDK_$(sdk)_$(type)DEFS.$(bld_trg))\
+	$(SDK_$(sdk)_$(type)DEFS.$(bld_trg_arch))\
+	$(SDK_$(sdk)_$(type)DEFS.$(bld_trg_cpu)))\
+	$($(target)_$(source)_DEFS)\
+	$($(target)_$(source)_DEFS.$(bld_type))\
+	$($(target)_$(source)_DEFS.$(bld_trg))\
+	$($(target)_$(source)_DEFS.$(bld_trg_arch))\
+	$($(target)_$(source)_DEFS.$(bld_trg_cpu))\
+	$($(target)_$(source)_$(type)DEFS)\
+	$($(target)_$(source)_$(type)DEFS.$(bld_type))\
+	$($(target)_$(source)_$(type)DEFS.$(bld_trg))\
+	$($(target)_$(source)_$(type)DEFS.$(bld_trg_arch))\
+	$($(target)_$(source)_$(type)DEFS.$(bld_trg_cpu))\
+	)
+$(eval incs        :=\
+	$($(target)_$(source)_$(type)INCS.$(bld_trg_cpu))\
+	$($(target)_$(source)_$(type)INCS.$(bld_trg_arch))\
+	$($(target)_$(source)_$(type)INCS.$(bld_trg))\
+	$($(target)_$(source)_$(type)INCS.$(bld_type))\
+	$($(target)_$(source)_$(type)INCS)\
+	$($(target)_$(source)_INCS.$(bld_trg_cpu))\
+	$($(target)_$(source)_INCS.$(bld_trg_arch))\
+	$($(target)_$(source)_INCS.$(bld_trg))\
+	$($(target)_$(source)_INCS.$(bld_type))\
+	$($(target)_$(source)_INCS)\
+	$(foreach sdk, $($(target)_$(source)_SDKS.$(bld_trg)) \
+				   $($(target)_$(source)_SDKS.$(bld_type)) \
+				   $($(target)_$(source)_SDKS),\
+	$(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
+	$(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
+	$(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
+	$(SDK_$(sdk)_$(type)INCS.$(bld_type))\
+	$(SDK_$(sdk)_$(type)INCS)\
+	$(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
+	$(SDK_$(sdk)_INCS.$(bld_trg_arch))\
+	$(SDK_$(sdk)_INCS.$(bld_trg))\
+	$(SDK_$(sdk)_INCS.$(bld_type))\
+	$(SDK_$(sdk)_INCS))\
+	$($(source)_$(type)INCS.$(bld_trg_cpu))\
+	$($(source)_$(type)INCS.$(bld_trg_arch))\
+	$($(source)_$(type)INCS.$(bld_trg))\
+	$($(source)_$(type)INCS.$(bld_type))\
+	$($(source)_$(type)INCS)\
+	$($(source)_INCS.$(bld_trg_cpu))\
+	$($(source)_INCS.$(bld_trg_arch))\
+	$($(source)_INCS.$(bld_trg))\
+	$($(source)_INCS.$(bld_type))\
+	$($(source)_INCS)\
+	$(foreach sdk, $($(source)_SDKS.$(bld_trg)) \
+				   $($(source)_SDKS.$(bld_type)) \
+				   $($(source)_SDKS),\
+	$(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
+	$(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
+	$(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
+	$(SDK_$(sdk)_$(type)INCS.$(bld_type))\
+	$(SDK_$(sdk)_$(type)INCS)\
+	$(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
+	$(SDK_$(sdk)_INCS.$(bld_trg_arch))\
+	$(SDK_$(sdk)_INCS.$(bld_trg))\
+	$(SDK_$(sdk)_INCS.$(bld_type))\
+	$(SDK_$(sdk)_INCS))\
+	$($(target)_$(type)INCS.$(bld_trg_cpu))\
+	$($(target)_$(type)INCS.$(bld_trg_arch))\
+	$($(target)_$(type)INCS.$(bld_trg))\
+	$($(target)_$(type)INCS.$(bld_type))\
+	$($(target)_$(type)INCS)\
+	$($(target)_INCS.$(bld_trg_cpu))\
+	$($(target)_INCS.$(bld_trg_arch))\
+	$($(target)_INCS.$(bld_trg))\
+	$($(target)_INCS.$(bld_type))\
+	$($(target)_INCS)\
+	$(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
+				   $($(target)_SDKS.$(bld_type)) \
+				   $($(target)_SDKS),\
+	$(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
+	$(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
+	$(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
+	$(SDK_$(sdk)_$(type)INCS.$(bld_type))\
+	$(SDK_$(sdk)_$(type)INCS)\
+	$(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
+	$(SDK_$(sdk)_INCS.$(bld_trg_arch))\
+	$(SDK_$(sdk)_INCS.$(bld_trg))\
+	$(SDK_$(sdk)_INCS.$(bld_type))\
+	$(SDK_$(sdk)_INCS))\
+	$(INCS.$(bld_trg_cpu))\
+	$(INCS.$(bld_trg_arch))\
+	$(INCS.$(bld_trg))\
+	$(INCS.$(bld_type))\
+	$(INCS)\
+	$(foreach sdk, $(SDKS.$(bld_trg)) \
+				   $(SDKS.$(bld_type)) \
+				   $(SDKS),\
+	$(SDK_$(sdk)_$(type)INCS.$(bld_trg_cpu))\
+	$(SDK_$(sdk)_$(type)INCS.$(bld_trg_arch))\
+	$(SDK_$(sdk)_$(type)INCS.$(bld_trg))\
+	$(SDK_$(sdk)_$(type)INCS.$(bld_type))\
+	$(SDK_$(sdk)_$(type)INCS)\
+	$(SDK_$(sdk)_INCS.$(bld_trg_cpu))\
+	$(SDK_$(sdk)_INCS.$(bld_trg_arch))\
+	$(SDK_$(sdk)_INCS.$(bld_trg))\
+	$(SDK_$(sdk)_INCS.$(bld_type))\
+	$(SDK_$(sdk)_INCS))\
+	$(TOOL_$(tool)_$(type)INCS.$(bld_trg_cpu))\
+	$(TOOL_$(tool)_$(type)INCS.$(bld_trg_arch))\
+	$(TOOL_$(tool)_$(type)INCS.$(bld_trg))\
+	$(TOOL_$(tool)_$(type)INCS.$(bld_type))\
+	$(TOOL_$(tool)_$(type)INCS)\
+	)
+$(eval flags        :=\
+	$(TOOL_$(tool)_$(type)FLAGS)\
+	$(TOOL_$(tool)_$(type)FLAGS.$(bld_type))\
+	$(TOOL_$(tool)_$(type)FLAGS.$(bld_trg))\
+	$(TOOL_$(tool)_$(type)FLAGS.$(bld_trg_arch))\
+	$(TOOL_$(tool)_$(type)FLAGS.$(bld_trg_cpu))\
+	$($(type)FLAGS)\
+	$($(type)FLAGS.$(bld_type))\
+	$($(type)FLAGS.$(bld_trg))\
+	$($(type)FLAGS.$(bld_trg_arch))\
+	$($(type)FLAGS.$(bld_trg_cpu))\
+	$($(target)_$(type)FLAGS)\
+	$($(target)_$(type)FLAGS.$(bld_type))\
+	$($(target)_$(type)FLAGS.$(bld_trg))\
+	$($(target)_$(type)FLAGS.$(bld_trg_arch))\
+	$($(target)_$(type)FLAGS.$(bld_trg_cpu))\
+	$($(source)_$(type)FLAGS)\
+	$($(source)_$(type)FLAGS.$(bld_type))\
+	$($(source)_$(type)FLAGS.$(bld_trg))\
+	$($(source)_$(type)FLAGS.$(bld_trg_arch))\
+	$($(source)_$(type)FLAGS.$(bld_trg_cpu))\
+	$($(target)_$(source)_$(type)FLAGS)\
+	$($(target)_$(source)_$(type)FLAGS.$(bld_type))\
+	$($(target)_$(source)_$(type)FLAGS.$(bld_trg))\
+	$($(target)_$(source)_$(type)FLAGS.$(bld_trg_arch))\
+	$($(target)_$(source)_$(type)FLAGS.$(bld_trg_cpu))\
+	)
+$(eval objsuff     := $(firstword \
+	$($(target)_$(source)_OBJSUFF.$(bld_trg))\
+	$($(target)_$(source)_OBJSUFF)\
+	$($(source)_OBJSUFF.$(bld_trg))\
+	$($(source)_OBJSUFF)\
+	$($(target)_OBJSUFF.$(bld_trg))\
+	$($(target)_OBJSUFF)\
+	$(TOOL_$(tool)_$(type)OBJSUFF.$(bld_trg))\
+	$(TOOL_$(tool)_$(type)OBJSUFF)\
+	$(SUFF_OBJ)\
+	))
+$(eval obj         := $(outbase)$(objsuff))
+$(eval dep         := $(outbase)$(SUFF_DEP))
+$(eval deps        := \
+	$($(target)_$(source)_DEPS)\
+    $($(target)_$(source)_DEPS.$(bld_type))\
+    $($(target)_$(source)_DEPS.$(bld_trg))\
+    $($(target)_$(source)_DEPS.$(bld_trg_arch))\
+    $($(target)_$(source)_DEPS.$(bld_trg_cpu))\
+	$($(source)_DEPS)\
+	$($(source)_DEPS.$(bld_type))\
+	$($(source)_DEPS.$(bld_trg))\
+	$($(target)_DEPS)\
+	$($(target)_DEPS.$(bld_trg_arch))\
+	$($(target)_DEPS.$(bld_trg_cpu)))
+
+
+#$ (warning dbg: target=$(target) source=$(source) tool=$(tool) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff) deps=$(deps))
+ifndef TOOL_$(tool)_COMPILE_$(type)
+$$(warning kBuild: TOOL_$(tool)_COMPILE_$(type) is not defined. source=$(source) target=$(target) )
+$$(warning kBuild: tools: \
+	1 $($(target)_$(source)_$(type)TOOL.$(bld_trg)) \
+	2 $($(target)_$(source)_$(type)TOOL) \
+	3 $($(target)_$(source)_TOOL.$(bld_trg)) \
+	4 $($(target)_$(source)_TOOL) \
+	5 $($(target)_$(type)TOOL.$(bld_trg)) \
+	6 $($(target)_$(type)TOOL) \
+	7 $($(target)_TOOL.$(bld_trg)) \
+	8 $($(target)_TOOL) \
+	9 $($(source)_$(type)TOOL.$(bld_trg)) \
+	10 $($(source)_$(type)TOOL) \
+	11 $($(source)_TOOL.$(bld_trg)) \
+	12 $($(source)_TOOL) \
+	13 $($(type)TOOL.$(bld_trg)) \
+	14 $($(type)TOOL) \
+	15 $(TOOL.$(bld_trg)) \
+	16 $(TOOL) )
+endif
+$(eval $(TOOL_$(tool)_COMPILE_$(type)))
+
+$$(basename $$(notdir $$(obj))).o::
+	+ $$(MAKE) -B -f $$(MAKEFILE) $(obj)
+$$(basename $$(notdir $$(obj))).obj::
+	+ $$(MAKE) -B -f $$(MAKEFILE) $(obj)
+
+$(eval _OBJS_$(target) += $(obj))
+$(eval _DEPFILES       += $(dep))
+
+endef
+
+## Generic macro for processing all target sources.
+# @param    $(target)   Normalized target name.
+define def_target_sources
+#$ (warning def_target_sources)
+# C sources
+$(foreach type,C,$(foreach source, $(filter %.c, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type)))\
+	,$(eval $(def_target_source_c_cpp_asm)) ))
+
+# C++ sources
+$(foreach type,CXX,$(foreach source, $(filter %.cpp %.cxx %.xx, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type)))\
+	,$(eval $(def_target_source_c_cpp_asm)) ))
+
+# ASM sources
+$(foreach type,AS,$(foreach source, $(filter %.asm %.s %.S, $($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type)))\
+	,$(eval $(def_target_source_c_cpp_asm)) ))
+endef
+
+
+#
+# BLDPROGS
+#
+
+## Build program (one).
+# @param    $(target)   Normalized target (program) name.
+define def_bldprog
+# basics
+$(eval bld_type    := $(firstword $($(target)_BLD_TYPE)     $(BUILD_TYPE)))
+$(eval bld_trg     := $(firstword $($(target)_BLD_TRG)      $(BUILD_PLATFORM)))
+$(eval bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_PLATFORM_ARCH)))
+$(eval bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU)  $(BUILD_PLATFORM_CPU)))
+$(eval tool        := $(call _TARGET_TOOL,$(target),LD))
+$(eval outbase     := $(call _TARGET_BASE,$(target),$(target)))
+$(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
+$(eval exesuff     := $(firstword $($(target)_EXESUFF) $($(target)_EXESUFF) $(TOOL_$(tool)_LDEXESUFF) $(HOSTSUFF_EXE)))
+$(eval exe         := $(outbase)$(exesuff))
+$(eval TARGET_$(target) := $(exe))
+
+# source -> object
+$(eval $(def_target_sources))
+
+# more library stuff.
+$(eval tool        := $(call _TARGET_TOOL,$(target),LD))
+$(eval outbase     := $(call _TARGET_BASE,$(target),$(target)))
+$(eval objs         = $(_OBJS_$(target)))
+$(eval flags       :=\
+	$(TOOL_$(tool)_LDFLAGS)\
+	$(TOOL_$(tool)_LDFLAGS.$(bld_type))\
+	$(TOOL_$(tool)_LDFLAGS.$(bld_trg))\
+	$(TOOL_$(tool)_LDFLAGS.$(bld_trg_arch))\
+	$(TOOL_$(tool)_LDFLAGS.$(bld_trg_cpu))\
+	$(LDFLAGS)\
+	$(LDFLAGS.$(bld_type))\
+	$(LDFLAGS.$(bld_trg))\
+	$(LDFLAGS.$(bld_trg_arch))\
+	$(LDFLAGS.$(bld_trg_cpu))\
+	$($(target)_LDFLAGS)\
+	$($(target)_LDFLAGS.$(bld_type))\
+	$($(target)_LDFLAGS.$(bld_trg))\
+	$($(target)_LDFLAGS.$(bld_trg_arch))\
+	$($(target)_LDFLAGS.$(bld_trg_cpu))\
+)
+$(eval libs        :=\
+	$($(target)_LIBS.$(bld_trg_cpu))\
+	$($(target)_LIBS.$(bld_trg_arch))\
+	$($(target)_LIBS.$(bld_trg))\
+	$($(target)_LIBS.$(bld_type))\
+	$($(target)_LIBS)\
+	$(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
+				   $($(target)_SDKS.$(bld_type)) \
+				   $($(target)_SDKS),\
+	$(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
+	$(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
+	$(SDK_$(sdk)_LIBS.$(bld_trg))\
+	$(SDK_$(sdk)_LIBS.$(bld_type))\
+	$(SDK_$(sdk)_LIBS))\
+	$(LIBS.$(bld_trg_cpu))\
+	$(LIBS.$(bld_trg_arch))\
+	$(LIBS.$(bld_trg))\
+	$(LIBS.$(bld_type))\
+	$(LIBS)\
+	$(foreach sdk, $(SDKS.$(bld_trg)) \
+				   $(SDKS.$(bld_type)) \
+				   $(SDKS),\
+	$(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
+	$(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
+	$(SDK_$(sdk)_LIBS.$(bld_trg))\
+	$(SDK_$(sdk)_LIBS.$(bld_type))\
+	$(SDK_$(sdk)_LIBS))\
+	$(TOOL_$(tool)_LIBS.$(bld_trg_cpu))\
+	$(TOOL_$(tool)_LIBS.$(bld_trg_arch))\
+	$(TOOL_$(tool)_LIBS.$(bld_trg))\
+	$(TOOL_$(tool)_LIBS.$(bld_type))\
+	$(TOOL_$(tool)_LIBS)\
+)
+$(eval libpath    :=\
+	$($(target)_LIBPATH.$(bld_trg_cpu))\
+	$($(target)_LIBPATH.$(bld_trg_arch))\
+	$($(target)_LIBPATH.$(bld_trg))\
+	$($(target)_LIBPATH.$(bld_type))\
+	$($(target)_LIBPATH)\
+	$(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
+				   $($(target)_SDKS.$(bld_type)) \
+				   $($(target)_SDKS),\
+	$(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
+	$(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
+	$(SDK_$(sdk)_LIBPATH.$(bld_trg))\
+	$(SDK_$(sdk)_LIBPATH.$(bld_type))\
+	$(SDK_$(sdk)_LIBPATH))\
+	$(LIBPATH.$(bld_trg_cpu))\
+	$(LIBPATH.$(bld_trg_arch))\
+	$(LIBPATH.$(bld_trg))\
+	$(LIBPATH.$(bld_type))\
+	$(LIBPATH)\
+	$(foreach sdk, $(SDKS.$(bld_trg)) \
+				   $(SDKS.$(bld_type)) \
+				   $(SDKS),\
+	$(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
+	$(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
+	$(SDK_$(sdk)_LIBPATH.$(bld_trg))\
+	$(SDK_$(sdk)_LIBPATH.$(bld_type))\
+	$(SDK_$(sdk)_LIBPATH))\
+	$(TOOL_$(tool)_LIBPATH.$(bld_trg_cpu))\
+	$(TOOL_$(tool)_LIBPATH.$(bld_trg_arch))\
+	$(TOOL_$(tool)_LIBPATH.$(bld_trg))\
+	$(TOOL_$(tool)_LIBPATH.$(bld_type))\
+	$(TOOL_$(tool)_LIBPATH)\
+)
+$(eval dirdep      := $(dir $(exe)).dir_created)
+## @todo fix dependencies
+$(eval deps        := $($(target)_DEPS))
+#
+$(eval custom_pre    := $(strip $(firstword
+	$($(target)_CUSTOM_PRE.$(bld_trg).$(bld_type))\
+	$($(target)_CUSTOM_PRE.$(bld_trg))\
+	$($(target)_CUSTOM_PRE.$(bld_type))\
+	$($(target)_CUSTOM_PRE)\
+	$(CUSTOM_PRE.$(bld_trg).$(bld_type))\
+	$(CUSTOM_PRE.$(bld_trg))\
+	$(CUSTOM_PRE.$(bld_type))\
+	$(CUSTOM_PRE)\
+)))
+$(eval custom_post    := $(strip $(firstword
+	$($(target)_CUSTOM_POST.$(bld_trg).$(bld_type))\
+	$($(target)_CUSTOM_POST.$(bld_trg))\
+	$($(target)_CUSTOM_POST.$(bld_type))\
+	$($(target)_CUSTOM_POST)\
+	$(CUSTOM_POST.$(bld_trg).$(bld_type))\
+	$(CUSTOM_POST.$(bld_trg))\
+	$(CUSTOM_POST.$(bld_type))\
+	$(CUSTOM_POST)\
+)))
+$(eval othersrc    := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type))))
+
+ifndef TOOL_$(tool)_LINK_PROGRAM
+$$(warning kBuild: TOOL_$(tool)_LINK_PROGRAM is not defined. target=$(target) )
+$$(warning kBuild: tools: \
+	1 $($(target)_$(source)TOOL.$(bld_trg)) \
+	2 $($(target)_$(source)TOOL) \
+	3 $($(target)_TOOL.$(bld_trg)) \
+	4 $($(target)_TOOL) \
+	5 $(TOOL.$(bld_trg)) \
+	6 $(TOOL) )
+endif
+
+$(eval $(TOOL_$(tool)_LINK_PROGRAM))
+# publish rule (still need work)
+ifdef $(target)_INST
+$(eval pubexe := $(PATH_BIN)/$(notdir $(exe)))
+$(pubexe) : $(exe) $(dir $(pubexe)).dir_created
+	$(CP) $(exe) $(pubexe)
+
+_BLDPROGS   += $(pubexe)
+_OUT_FILES += $(exe) $(pubexe)
+else
+_BLDPROGS   += $(exe)
+_OUT_FILES += $(exe)
+endif
+_OBJS += $(_OBJS_$(target))
+endef
+
+# Process build programs.
+$(foreach target, $(BLDPROGS) $(BLDPROGS.$(BUILD_PLATFORM)), $(eval $(def_bldprog)))
+
+
+
+#
+# LIBRARIES
+#
+
+## Library (one).
+# @param    $(target)   Normalized library (target) name.
+define def_lib
+# library basics
+## @todo prefix
+$(eval bld_type    := $(firstword $($(target)_BLD_TYPE)     $(BUILD_TYPE)))
+$(eval bld_trg     := $(firstword $($(target)_BLD_TRG)      $(BUILD_TARGET)))
+$(eval bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH)))
+$(eval bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU)  $(BUILD_TARGET_CPU)))
+$(eval tool        := $(call _TARGET_TOOL,$(target),AR))
+ifeq ($(tool),)
+$$(error kBuild: Library target $(target) doesn't have a tool defined!)
+endif
+$(eval outbase     := $(call _TARGET_BASE,$(target),$(target)))
+$(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
+$(eval libsuff     := $(firstword\
+	$($(target)_LIBSUFF.$(bld_trg))\
+	$($(target)_LIBSUFF)\
+	$(TOOL_$(tool)_ARLIBSUFF.$(bld_trg))\
+	$(TOOL_$(tool)_ARLIBSUFF)\
+	$(SUFF_LIB)\
+))
+$(eval lib         := $(outbase)$(libsuff))
+$(eval TARGET_$(target) := $(lib))
+
+# source -> object
+$(eval $(def_target_sources))
+
+# library linking
+$(eval tool        := $(call _TARGET_TOOL,$(target),AR))
+$(eval outbase     := $(call _TARGET_BASE,$(target),$(target)))
+$(eval flags       :=\
+	$(TOOL_$(tool)_ARFLAGS)\
+	$(TOOL_$(tool)_ARFLAGS.$(bld_type))\
+	$(ARFLAGS)\
+	$(ARFLAGS.$(bld_type))\
+	$($(target)_ARFLAGS)\
+	$($(target)_ARFLAGS.$(bld_type))\
+	)
+$(eval objs         = $(_OBJS_$(target)))
+$(eval othersrc    := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type))))
+$(eval dirdep      := $(dir $(lib)).dir_created)
+## @todo fix dependencies on makefiles an such
+$(eval deps        := $($(target)_DEPS))
+
+$(eval $(TOOL_$(tool)_LINK_LIBRARY))
+
+# publish rule (still need work)
+ifndef $(target)_NOINST
+$(eval publib := $(PATH_LIB)/$(notdir $(lib)))
+$(publib) : $(lib) $(dir $(publib)).dir_created
+	$(CP) $(lib) $(publib)
+
+_LIBS += $(publib)
+_OUT_FILES += $(lib) $(publib)
+else
+_LIBS += $(lib)
+_OUT_FILES += $(lib)
+endif
+_OBJS += $(_OBJS_$(target))
+endef
+
+# Process libraries
+$(foreach target, $(LIBRARIES) $(LIBRARIES.$(BUILD_TARGET)), $(eval $(def_lib)))
+
+
+
+#
+# DLLS
+#
+
+## DLL (one).
+# @param    $(target)   Normalized target (program) name.
+define def_dll
+# dllmod basics
+$(eval bld_type    := $(firstword $($(target)_BLD_TYPE)     $(BUILD_TYPE)))
+$(eval bld_trg     := $(firstword $($(target)_BLD_TRG)      $(BUILD_TARGET)))
+$(eval bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH)))
+$(eval bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU)  $(BUILD_TARGET_CPU)))
+$(eval tool        := $(call _TARGET_TOOL,$(target),LD))
+$(eval outbase     := $(call _TARGET_BASE,$(target),$(target)))
+$(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
+$(eval dllsuff     := $(firstword $($(target)_DLLSUFF) $($(target)_DLLSUFF) $(TOOL_$(tool)_LDDLLSUFF) $(SUFF_DLL)))
+$(eval dll         := $(outbase)$(dllsuff))
+$(eval TARGET_$(target) := $(dll))
+
+# source -> object
+$(eval $(def_target_sources))
+
+# dllmod linking.
+$(eval tool        := $(call _TARGET_TOOL,$(target),LD))
+$(eval outbase     := $(call _TARGET_BASE,$(target),$(target)))
+$(eval objs         = $(_OBJS_$(target)))
+$(eval flags       :=\
+	$(TOOL_$(tool)_LDFLAGS)\
+	$(TOOL_$(tool)_LDFLAGS.$(bld_type))\
+	$(TOOL_$(tool)_LDFLAGS.$(bld_trg))\
+	$(TOOL_$(tool)_LDFLAGS.$(bld_trg_arch))\
+	$(TOOL_$(tool)_LDFLAGS.$(bld_trg_cpu))\
+	$(LDFLAGS)\
+	$(LDFLAGS.$(bld_type))\
+	$(LDFLAGS.$(bld_trg))\
+	$(LDFLAGS.$(bld_trg_arch))\
+	$(LDFLAGS.$(bld_trg_cpu))\
+	$($(target)_LDFLAGS)\
+	$($(target)_LDFLAGS.$(bld_type))\
+	$($(target)_LDFLAGS.$(bld_trg))\
+	$($(target)_LDFLAGS.$(bld_trg_arch))\
+	$($(target)_LDFLAGS.$(bld_trg_cpu))\
+)
+$(eval libs        :=\
+	$($(target)_LIBS.$(bld_trg_cpu))\
+	$($(target)_LIBS.$(bld_trg_arch))\
+	$($(target)_LIBS.$(bld_trg))\
+	$($(target)_LIBS.$(bld_type))\
+	$($(target)_LIBS)\
+	$(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
+				   $($(target)_SDKS.$(bld_type)) \
+				   $($(target)_SDKS),\
+	$(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
+	$(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
+	$(SDK_$(sdk)_LIBS.$(bld_trg))\
+	$(SDK_$(sdk)_LIBS.$(bld_type))\
+	$(SDK_$(sdk)_LIBS))\
+	$(LIBS.$(bld_trg_cpu))\
+	$(LIBS.$(bld_trg_arch))\
+	$(LIBS.$(bld_trg))\
+	$(LIBS.$(bld_type))\
+	$(LIBS)\
+	$(foreach sdk, $(SDKS.$(bld_trg)) \
+				   $(SDKS.$(bld_type)) \
+				   $(SDKS),\
+	$(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
+	$(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
+	$(SDK_$(sdk)_LIBS.$(bld_trg))\
+	$(SDK_$(sdk)_LIBS.$(bld_type))\
+	$(SDK_$(sdk)_LIBS))\
+	$(TOOL_$(tool)_LIBS.$(bld_trg_cpu))\
+	$(TOOL_$(tool)_LIBS.$(bld_trg_arch))\
+	$(TOOL_$(tool)_LIBS.$(bld_trg))\
+	$(TOOL_$(tool)_LIBS.$(bld_type))\
+	$(TOOL_$(tool)_LIBS)\
+)
+$(eval libpath    :=\
+	$($(target)_LIBPATH.$(bld_trg_cpu))\
+	$($(target)_LIBPATH.$(bld_trg_arch))\
+	$($(target)_LIBPATH.$(bld_trg))\
+	$($(target)_LIBPATH.$(bld_type))\
+	$($(target)_LIBPATH)\
+	$(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
+				   $($(target)_SDKS.$(bld_type)) \
+				   $($(target)_SDKS),\
+	$(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
+	$(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
+	$(SDK_$(sdk)_LIBPATH.$(bld_trg))\
+	$(SDK_$(sdk)_LIBPATH.$(bld_type))\
+	$(SDK_$(sdk)_LIBPATH))\
+	$(LIBPATH.$(bld_trg_cpu))\
+	$(LIBPATH.$(bld_trg_arch))\
+	$(LIBPATH.$(bld_trg))\
+	$(LIBPATH.$(bld_type))\
+	$(LIBPATH)\
+	$(foreach sdk, $(SDKS.$(bld_trg)) \
+				   $(SDKS.$(bld_type)) \
+				   $(SDKS),\
+	$(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
+	$(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
+	$(SDK_$(sdk)_LIBPATH.$(bld_trg))\
+	$(SDK_$(sdk)_LIBPATH.$(bld_type))\
+	$(SDK_$(sdk)_LIBPATH))\
+	$(TOOL_$(tool)_LIBPATH.$(bld_trg_cpu))\
+	$(TOOL_$(tool)_LIBPATH.$(bld_trg_arch))\
+	$(TOOL_$(tool)_LIBPATH.$(bld_trg))\
+	$(TOOL_$(tool)_LIBPATH.$(bld_type))\
+	$(TOOL_$(tool)_LIBPATH)\
+)
+$(eval dirdep      := $(dir $(dll)).dir_created)
+## @todo fix dependencies
+$(eval deps        := $($(target)_DEPS))
+#
+$(eval custom_pre    := $(strip $(firstword
+	$($(target)_CUSTOM_PRE.$(bld_trg).$(bld_type))\
+	$($(target)_CUSTOM_PRE.$(bld_trg))\
+	$($(target)_CUSTOM_PRE.$(bld_type))\
+	$($(target)_CUSTOM_PRE)\
+	$(CUSTOM_PRE.$(bld_trg).$(bld_type))\
+	$(CUSTOM_PRE.$(bld_trg))\
+	$(CUSTOM_PRE.$(bld_type))\
+	$(CUSTOM_PRE)\
+)))
+$(eval custom_post    := $(strip $(firstword
+	$($(target)_CUSTOM_POST.$(bld_trg).$(bld_type))\
+	$($(target)_CUSTOM_POST.$(bld_trg))\
+	$($(target)_CUSTOM_POST.$(bld_type))\
+	$($(target)_CUSTOM_POST)\
+	$(CUSTOM_POST.$(bld_trg).$(bld_type))\
+	$(CUSTOM_POST.$(bld_trg))\
+	$(CUSTOM_POST.$(bld_type))\
+	$(CUSTOM_POST)\
+)))
+$(eval othersrc    := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type))))
+
+ifndef TOOL_$(tool)_LINK_DLL
+$$(warning kBuild: TOOL_$(tool)_LINK_DLL is not defined. target=$(target) )
+$$(warning kBuild: tools: \
+	1 $($(target)_$(source)TOOL.$(bld_trg)) \
+	2 $($(target)_$(source)TOOL) \
+	3 $($(target)_TOOL.$(bld_trg)) \
+	4 $($(target)_TOOL) \
+	5 $($(source)TOOL) \
+	6 $($(source)TOOL.$(bld_trg)) \
+	7 $(TOOL.$(bld_trg)) \
+	8 $(TOOL) )
+endif
+
+$(eval $(TOOL_$(tool)_LINK_DLL))
+
+
+# publish rule (still need work)
+ifndef $(target)_NOINST
+$(eval pubdll := $(PATH_BIN)/$(notdir $(dll)))
+$(pubdll) : $(dll) $(dir $(pubdll)).dir_created
+	$(CP) $(dll) $(pubdll)
+
+$(eval TARGET_PUB_$(target) := $(pubdll))
+_DLLS += $(pubdll)
+_OUT_FILES += $(dll) $(pubdll)
+else
+_DLLS += $(dll)
+_OUT_FILES += $(dll)
+endif
+_OBJS += $(_OBJS_$(target))
+endef
+
+# Process dlls
+$(foreach target, $(DLLS) $(DLLS.$(BUILD_TARGET)), $(eval $(def_dll)))
+
+
+
+#
+# Process import libraries.
+#
+#   - On OS/2 and windows these are libraries.
+#   - On other platforms they are fake DLLs.
+ifeq ($(subst win32,os2,$(BUILD_TARGET)),os2)
+$(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval $(def_lib)))
+else
+$(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval $(def_dll)))
+endif
+$(foreach target, $(IMPORT_LIBS) $(IMPORT_LIBS.$(BUILD_TARGET)), $(eval _IMPORT_LIBS += $(firstword $(TARGET_PUB_$(target)) $(TARGET_$(target)))))
+
+    
+
+#
+# PROGRAMS
+#
+
+## Program (one).
+# @param    $(target)   Normalized target (program) name.
+define def_program
+# basics
+$(eval bld_type    := $(firstword $($(target)_BLD_TYPE)     $(BUILD_TYPE)))
+$(eval bld_trg     := $(firstword $($(target)_BLD_TRG)      $(BUILD_TARGET)))
+$(eval bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH)))
+$(eval bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU)  $(BUILD_TARGET_CPU)))
+$(eval tool        := $(call _TARGET_TOOL,$(target),LD))
+$(eval outbase     := $(call _TARGET_BASE,$(target),$(target)))
+$(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
+$(eval exesuff     := $(firstword $($(target)_EXESUFF) $($(target)_EXESUFF) $(TOOL_$(tool)_LDEXESUFF) $(SUFF_EXE)))
+$(eval exe         := $(outbase)$(exesuff))
+$(eval TARGET_$(target) := $(exe))
+
+# source -> object
+$(eval $(def_target_sources))
+
+# more library stuff.
+$(eval tool        := $(call _TARGET_TOOL,$(target),LD))
+$(eval outbase     := $(call _TARGET_BASE,$(target),$(target)))
+$(eval objs         = $(_OBJS_$(target)))
+$(eval flags       :=\
+	$(TOOL_$(tool)_LDFLAGS)\
+	$(TOOL_$(tool)_LDFLAGS.$(bld_type))\
+	$(TOOL_$(tool)_LDFLAGS.$(bld_trg))\
+	$(TOOL_$(tool)_LDFLAGS.$(bld_trg_arch))\
+	$(TOOL_$(tool)_LDFLAGS.$(bld_trg_cpu))\
+	$(LDFLAGS)\
+	$(LDFLAGS.$(bld_type))\
+	$(LDFLAGS.$(bld_trg))\
+	$(LDFLAGS.$(bld_trg_arch))\
+	$(LDFLAGS.$(bld_trg_cpu))\
+	$($(target)_LDFLAGS)\
+	$($(target)_LDFLAGS.$(bld_type))\
+	$($(target)_LDFLAGS.$(bld_trg))\
+	$($(target)_LDFLAGS.$(bld_trg_arch))\
+	$($(target)_LDFLAGS.$(bld_trg_cpu))\
+)
+$(eval libs        :=\
+	$($(target)_LIBS.$(bld_trg_cpu))\
+	$($(target)_LIBS.$(bld_trg_arch))\
+	$($(target)_LIBS.$(bld_trg))\
+	$($(target)_LIBS.$(bld_type))\
+	$($(target)_LIBS)\
+	$(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
+				   $($(target)_SDKS.$(bld_type)) \
+				   $($(target)_SDKS),\
+	$(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
+	$(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
+	$(SDK_$(sdk)_LIBS.$(bld_trg))\
+	$(SDK_$(sdk)_LIBS.$(bld_type))\
+	$(SDK_$(sdk)_LIBS))\
+	$(LIBS.$(bld_trg_cpu))\
+	$(LIBS.$(bld_trg_arch))\
+	$(LIBS.$(bld_trg))\
+	$(LIBS.$(bld_type))\
+	$(LIBS)\
+	$(foreach sdk, $(SDKS.$(bld_trg)) \
+				   $(SDKS.$(bld_type)) \
+				   $(SDKS),\
+	$(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
+	$(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
+	$(SDK_$(sdk)_LIBS.$(bld_trg))\
+	$(SDK_$(sdk)_LIBS.$(bld_type))\
+	$(SDK_$(sdk)_LIBS))\
+	$(TOOL_$(tool)_LIBS.$(bld_trg_cpu))\
+	$(TOOL_$(tool)_LIBS.$(bld_trg_arch))\
+	$(TOOL_$(tool)_LIBS.$(bld_trg))\
+	$(TOOL_$(tool)_LIBS.$(bld_type))\
+	$(TOOL_$(tool)_LIBS)\
+)
+$(eval libpath    :=\
+	$($(target)_LIBPATH.$(bld_trg_cpu))\
+	$($(target)_LIBPATH.$(bld_trg_arch))\
+	$($(target)_LIBPATH.$(bld_trg))\
+	$($(target)_LIBPATH.$(bld_type))\
+	$($(target)_LIBPATH)\
+	$(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
+				   $($(target)_SDKS.$(bld_type)) \
+				   $($(target)_SDKS),\
+	$(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
+	$(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
+	$(SDK_$(sdk)_LIBPATH.$(bld_trg))\
+	$(SDK_$(sdk)_LIBPATH.$(bld_type))\
+	$(SDK_$(sdk)_LIBPATH))\
+	$(LIBPATH.$(bld_trg_cpu))\
+	$(LIBPATH.$(bld_trg_arch))\
+	$(LIBPATH.$(bld_trg))\
+	$(LIBPATH.$(bld_type))\
+	$(LIBPATH)\
+	$(foreach sdk, $(SDKS.$(bld_trg)) \
+				   $(SDKS.$(bld_type)) \
+				   $(SDKS),\
+	$(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
+	$(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
+	$(SDK_$(sdk)_LIBPATH.$(bld_trg))\
+	$(SDK_$(sdk)_LIBPATH.$(bld_type))\
+	$(SDK_$(sdk)_LIBPATH))\
+	$(TOOL_$(tool)_LIBPATH.$(bld_trg_cpu))\
+	$(TOOL_$(tool)_LIBPATH.$(bld_trg_arch))\
+	$(TOOL_$(tool)_LIBPATH.$(bld_trg))\
+	$(TOOL_$(tool)_LIBPATH.$(bld_type))\
+	$(TOOL_$(tool)_LIBPATH)\
+)
+$(eval dirdep      := $(dir $(exe)).dir_created)
+## @todo fix dependencies
+$(eval deps        := $($(target)_DEPS))
+#
+$(eval custom_pre    := $(strip $(firstword
+	$($(target)_CUSTOM_PRE.$(bld_trg).$(bld_type))\
+	$($(target)_CUSTOM_PRE.$(bld_trg))\
+	$($(target)_CUSTOM_PRE.$(bld_type))\
+	$($(target)_CUSTOM_PRE)\
+	$(CUSTOM_PRE.$(bld_trg).$(bld_type))\
+	$(CUSTOM_PRE.$(bld_trg))\
+	$(CUSTOM_PRE.$(bld_type))\
+	$(CUSTOM_PRE)\
+)))
+$(eval custom_post    := $(strip $(firstword
+	$($(target)_CUSTOM_POST.$(bld_trg).$(bld_type))\
+	$($(target)_CUSTOM_POST.$(bld_trg))\
+	$($(target)_CUSTOM_POST.$(bld_type))\
+	$($(target)_CUSTOM_POST)\
+	$(CUSTOM_POST.$(bld_trg).$(bld_type))\
+	$(CUSTOM_POST.$(bld_trg))\
+	$(CUSTOM_POST.$(bld_type))\
+	$(CUSTOM_POST)\
+)))
+$(eval othersrc    := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type))))
+
+$(eval $(TOOL_$(tool)_LINK_PROGRAM))
+# publish rule (still need work)
+ifndef $(target)_NOINST
+$(eval pubexe := $(PATH_BIN)/$(notdir $(exe)))
+$(pubexe) : $(exe) $(dir $(pubexe)).dir_created
+	$(CP) $(exe) $(pubexe)
+
+_PROGRAMS  += $(pubexe)
+_OUT_FILES += $(exe) $(pubexe)
+else
+_PROGRAMS  += $(exe)
+_OUT_FILES += $(exe)
+endif
+_OBJS += $(_OBJS_$(target))
+endef
+
+# Process libraries
+$(foreach target, $(PROGRAMS) $(PROGRAMS.$(BUILD_TARGET)), $(eval $(def_program)))
+
+
+
+#
+# SYSMODS
+#
+
+## System module (one).
+# @param    $(target)   Normalized target (program) name.
+define def_sysmod
+# sysmod basics
+$(eval bld_type    := $(firstword $($(target)_BLD_TYPE)     $(BUILD_TYPE)))
+$(eval bld_trg     := $(firstword $($(target)_BLD_TRG)      $(BUILD_TARGET)))
+$(eval bld_trg_arch:= $(firstword $($(target)_BLD_TRG_ARCH) $(BUILD_TARGET_ARCH)))
+$(eval bld_trg_cpu := $(firstword $($(target)_BLD_TRG_CPU)  $(BUILD_TARGET_CPU)))
+$(eval tool        := $(call _TARGET_TOOL,$(target),LD))
+$(eval outbase     := $(call _TARGET_BASE,$(target),$(target)))
+$(eval PATH_$(target) := $(patsubst %/,%,$(dir $(outbase))))
+$(eval syssuff     := $(firstword $($(target)_SYSSUFF) $($(target)_SYSSUFF) $(TOOL_$(tool)_LDSYSSUFF) $(SUFF_SYS)))
+$(eval sys         := $(outbase)$(syssuff))
+$(eval TARGET_$(target) := $(sys))
+
+# source -> object
+$(eval $(def_target_sources))
+
+# sysmod linking
+$(eval tool        := $(call _TARGET_TOOL,$(target),LD))
+$(eval outbase     := $(call _TARGET_BASE,$(target),$(target)))
+$(eval objs         = $(_OBJS_$(target)))
+$(eval flags       :=\
+	$(TOOL_$(tool)_LDFLAGS)\
+	$(TOOL_$(tool)_LDFLAGS.$(bld_type))\
+	$(TOOL_$(tool)_LDFLAGS.$(bld_trg))\
+	$(TOOL_$(tool)_LDFLAGS.$(bld_trg_arch))\
+	$(TOOL_$(tool)_LDFLAGS.$(bld_trg_cpu))\
+	$(LDFLAGS)\
+	$(LDFLAGS.$(bld_type))\
+	$(LDFLAGS.$(bld_trg))\
+	$(LDFLAGS.$(bld_trg_arch))\
+	$(LDFLAGS.$(bld_trg_cpu))\
+	$($(target)_LDFLAGS)\
+	$($(target)_LDFLAGS.$(bld_type))\
+	$($(target)_LDFLAGS.$(bld_trg))\
+	$($(target)_LDFLAGS.$(bld_trg_arch))\
+	$($(target)_LDFLAGS.$(bld_trg_cpu))\
+)
+$(eval libs        :=\
+	$($(target)_LIBS.$(bld_trg_cpu))\
+	$($(target)_LIBS.$(bld_trg_arch))\
+	$($(target)_LIBS.$(bld_trg))\
+	$($(target)_LIBS.$(bld_type))\
+	$($(target)_LIBS)\
+	$(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
+				   $($(target)_SDKS.$(bld_type)) \
+				   $($(target)_SDKS),\
+	$(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
+	$(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
+	$(SDK_$(sdk)_LIBS.$(bld_trg))\
+	$(SDK_$(sdk)_LIBS.$(bld_type))\
+	$(SDK_$(sdk)_LIBS))\
+	$(LIBS.$(bld_trg_cpu))\
+	$(LIBS.$(bld_trg_arch))\
+	$(LIBS.$(bld_trg))\
+	$(LIBS.$(bld_type))\
+	$(LIBS)\
+	$(foreach sdk, $(SDKS.$(bld_trg)) \
+				   $(SDKS.$(bld_type)) \
+				   $(SDKS),\
+	$(SDK_$(sdk)_LIBS.$(bld_trg_cpu))\
+	$(SDK_$(sdk)_LIBS.$(bld_trg_arch))\
+	$(SDK_$(sdk)_LIBS.$(bld_trg))\
+	$(SDK_$(sdk)_LIBS.$(bld_type))\
+	$(SDK_$(sdk)_LIBS))\
+	$(TOOL_$(tool)_LIBS.$(bld_trg_cpu))\
+	$(TOOL_$(tool)_LIBS.$(bld_trg_arch))\
+	$(TOOL_$(tool)_LIBS.$(bld_trg))\
+	$(TOOL_$(tool)_LIBS.$(bld_type))\
+	$(TOOL_$(tool)_LIBS)\
+)
+$(eval libpath    :=\
+	$($(target)_LIBPATH.$(bld_trg_cpu))\
+	$($(target)_LIBPATH.$(bld_trg_arch))\
+	$($(target)_LIBPATH.$(bld_trg))\
+	$($(target)_LIBPATH.$(bld_type))\
+	$($(target)_LIBPATH)\
+	$(foreach sdk, $($(target)_SDKS.$(bld_trg)) \
+				   $($(target)_SDKS.$(bld_type)) \
+				   $($(target)_SDKS),\
+	$(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
+	$(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
+	$(SDK_$(sdk)_LIBPATH.$(bld_trg))\
+	$(SDK_$(sdk)_LIBPATH.$(bld_type))\
+	$(SDK_$(sdk)_LIBPATH))\
+	$(LIBPATH.$(bld_trg_cpu))\
+	$(LIBPATH.$(bld_trg_arch))\
+	$(LIBPATH.$(bld_trg))\
+	$(LIBPATH.$(bld_type))\
+	$(LIBPATH)\
+	$(foreach sdk, $(SDKS.$(bld_trg)) \
+				   $(SDKS.$(bld_type)) \
+				   $(SDKS),\
+	$(SDK_$(sdk)_LIBPATH.$(bld_trg_cpu))\
+	$(SDK_$(sdk)_LIBPATH.$(bld_trg_arch))\
+	$(SDK_$(sdk)_LIBPATH.$(bld_trg))\
+	$(SDK_$(sdk)_LIBPATH.$(bld_type))\
+	$(SDK_$(sdk)_LIBPATH))\
+	$(TOOL_$(tool)_LIBPATH.$(bld_trg_cpu))\
+	$(TOOL_$(tool)_LIBPATH.$(bld_trg_arch))\
+	$(TOOL_$(tool)_LIBPATH.$(bld_trg))\
+	$(TOOL_$(tool)_LIBPATH.$(bld_type))\
+	$(TOOL_$(tool)_LIBPATH)\
+)
+$(eval dirdep      := $(dir $(sys)).dir_created)
+## @todo fix dependencies
+$(eval deps        := $($(target)_DEPS))
+#
+$(eval custom_pre    := $(strip $(firstword
+	$($(target)_CUSTOM_PRE.$(bld_trg).$(bld_type))\
+	$($(target)_CUSTOM_PRE.$(bld_trg))\
+	$($(target)_CUSTOM_PRE.$(bld_type))\
+	$($(target)_CUSTOM_PRE)\
+	$(CUSTOM_PRE.$(bld_trg).$(bld_type))\
+	$(CUSTOM_PRE.$(bld_trg))\
+	$(CUSTOM_PRE.$(bld_type))\
+	$(CUSTOM_PRE)\
+)))
+$(eval custom_post    := $(strip $(firstword
+	$($(target)_CUSTOM_POST.$(bld_trg).$(bld_type))\
+	$($(target)_CUSTOM_POST.$(bld_trg))\
+	$($(target)_CUSTOM_POST.$(bld_type))\
+	$($(target)_CUSTOM_POST)\
+	$(CUSTOM_POST.$(bld_trg).$(bld_type))\
+	$(CUSTOM_POST.$(bld_trg))\
+	$(CUSTOM_POST.$(bld_type))\
+	$(CUSTOM_POST)\
+)))
+$(eval othersrc    := $(filter-out %.c %.cpp %.cxx %.cc %.s %.S %.asm,$($(target)_SOURCES) $($(target)_SOURCES.$(bld_trg)) $($(target)_SOURCES.$(bld_type))))
+
+ifndef TOOL_$(tool)_LINK_SYSMOD
+$$(warning kBuild: TOOL_$(tool)_LINK_SYSMOD is not defined. target=$(target) )
+$$(warning kBuild: tools: \
+	1 $($(target)_$(source)TOOL.$(bld_trg)) \
+	2 $($(target)_$(source)TOOL) \
+	3 $($(target)_TOOL.$(bld_trg)) \
+	4 $($(target)_TOOL) \
+	5 $($(source)TOOL) \
+	6 $($(source)TOOL.$(bld_trg)) \
+	7 $(TOOL.$(bld_trg)) \
+	8 $(TOOL) )
+endif
+
+$(eval $(TOOL_$(tool)_LINK_SYSMOD))
+
+# publish rule (still need work)
+ifndef $(target)_NOINST
+$(eval pubsys := $(PATH_BIN)/$(notdir $(sys)))
+$(pubsys): $(sys) $(dir $(pubsys)).dir_created
+	$(CP) $(sys) $(pubsys)
+
+$(eval _SYSMODS += $(pubsys))
+$(eval _OUT_FILES += $(sys) $(pubsys))
+else
+$(eval _SYSMODS += $(sys))
+$(eval _OUT_FILES += $(sys))
+endif
+_OBJS += $(_OBJS_$(target))
+endef
+
+# Process sysmods
+$(foreach target, $(SYSMODS) $(SYSMODS.$(BUILD_TARGET)), $(eval $(def_sysmod)))
+
+
+
+#
+# OTHERS
+#
+_OTHERS = $(OTHERS) $(OTHERS.$(BUILD_TARGET))
+
+
+
+#
+# DOCS
+#
+
+
+#
+# Directories.
+#
+_DIRFILES := $(sort $(addsuffix /.dir_created,$(_DIRS)) $(addsuffix .dir_created,$(sort $(dir $(_OUT_FILES) $(_OBJS)))))
+
+define def_createdir
+$(dirfile):
+	$(call MSG_L1,Creating directory $$(@D))
+	$(MKDIR) -p $$(@D)
+	@echo dir_created > $$@
+endef
+
+$(foreach dirfile,$(_DIRFILES),$(eval $(def_createdir)))
+
+
+#
+# Include dependency files.
+#
+$(foreach dep,$(wildcard $(_DEPFILES)),$(eval include $(dep)))
+
+
+#
+# PASSES (including directory and makefile walking)
+#
+# Do all the default passes if it's unspecified.
+
+#PASSES ?= bldprogs libraries binaries others publish
+PASSES ?= bldprogs libraries dlls binaries others
+
+## @todo figure out a generic way of configuring how pass works!
+
+## Proritized list of the default makefile when walking subdirectories.
+# The user can overload this list.
+DEFAULT_MAKEFILE ?= Makefile.kmk makefile.kmk Makefile makefile
+
+## Subdir
+# @param	$(pass)		Lowercase pass name.
+# @param	$(PASS)		Uppercase pass name.
+# @param	$(subdir)	Subdirectory
+# @param	$(tag)		tag to attach to the rule name.
+define def_pass_subdir
+pass_$(pass)$(tag):: $(dep)
+	+ $(QUIET)$$(MAKE) -C $(subdir) -f $$(notdir $$(firstword $$(wildcard $$(addprefix $(subdir)/,$$(DEFAULT_MAKEFILE))))) pass_$(pass)
+endef
+
+## Submakefile
+# @param	$(pass)		Lowercase pass name.
+# @param	$(PASS)		Uppercase pass name.
+# @param	$(makefile) Makefile.
+# @param	$(tag)		tag to attach to the rule name.
+define def_pass_makefile
+pass_$(pass)$(tag):: $(dep)
+	+ $(QUIET)$$(MAKE) -C $(patsubst %/,%,$(dir $(makefile))) -f $(notdir $(makefile)) pass_$(pass)
+endef
+
+
+## Execute a pass.
+# @param	$(pass)		Lowercase pass name.
+# @param	$(PASS)		Uppercase pass name.
+define def_pass
+$(eval SUBDIRS_$(PASS)          ?= $(SUBDIRS)          $(SUBDIRS.$(BUILD_TARGET)))
+$(eval SUBDIRS_AFTER_$(PASS)    ?= $(SUBDIRS_AFTER)    $(SUBDIRS_AFTER.$(BUILD_TARGET)))
+$(eval MAKEFILES_BEFORE_$(PASS) ?= $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)))
+$(eval MAKEFILES_AFTER_$(PASS)  ?= $(MAKEFILES_AFTER)  $(MAKEFILES_AFTER.$(BUILD_TARGET)))
+
+$(eval tag:=_before)
+$(eval dep:=)
+$(foreach subdir,$(SUBDIRS_$(PASS))            $(SUBDIRS_$(PASS).$(BUILD_TARGET))         ,$(eval $(def_pass_subdir)))
+$(foreach makefile,$(MAKEFILES_BEFORE_$(PASS)) $(MAKEFILES_BEFORE_$(PASS).$(BUILD_TARGET)),$(eval $(def_pass_makefile)))
+
+$(eval tag:=_after)
+$(eval dep:=pass_$(pass)_doit)
+$(foreach subdir,$(SUBDIRS_AFTER_$(PASS))      $(SUBDIRS_AFTER_$(PASS).$(BUILD_TARGET))   ,$(eval $(def_pass_subdir)))
+$(foreach makefile,$(MAKEFILES_AFTER_$(PASS))  $(MAKEFILES_AFTER_$(PASS).$(BUILD_TARGET)) ,$(eval $(def_pass_makefile)))
+
+.NOTPARALLEL: pass_$(pass)_before pass_$(pass)_after
+.PHONY: pass_$(pass) pass_$(pass)_before pass_$(pass)_doit pass_$(pass)_after
+pass_$(pass)_this:      pass_$(pass)_before 
+	+ $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)_doit
+pass_$(pass)_after::    pass_$(pass)_this
+pass_$(pass):           pass_$(pass)_after
+
+endef
+
+
+## PASS: bldprogs
+# This pass builds targets which are required for building the rest.
+pass_bldprogs_doit: $(_BLDPROGS)
+pass := bldprogs
+PASS := BLDPROGS
+$(eval $(def_pass))
+
+## PASS: libraries
+# This pass builds library targets.
+pass_libraries_doit: $(_LIBS) $(_IMPORT_LIBS) $(_OTHER_LIBRARIES)
+pass := libraries
+PASS := LIBRARIES
+$(eval $(def_pass))
+
+## PASS: binaries
+# This pass builds dll targets.
+pass_dlls_doit: $(_DLLS) $(_OTHER_DLLS)
+pass := dlls
+PASS := DLLS
+$(eval $(def_pass))
+
+## PASS: binaries
+# This pass builds binary targets, i.e. programs, system modules and stuff.
+pass_binaries_doit: $(_PROGRAMS) $(_SYSMODS) $(_OTHER_BINARIES)
+pass := binaries
+PASS := BINARIES
+$(eval $(def_pass))
+
+## PASS: others
+# This pass builds other targets.
+pass_others_doit: $(_OTHERS)
+pass := others
+PASS := OTHERS
+$(eval $(def_pass))
+
+## PASS: publish
+# This pass installs the built entities to a sandbox area.
+pass_publish_doit: publish
+publish::
+pass := publish
+PASS := PUBLISH
+# $(sort).. not nice.
+SUBDIRS_PUBLISH         ?= $(sort $(SUBDIRS)          $(SUBDIRS.$(BUILD_TARGET))          $(SUBDIRS_LIBRARIES)          $(SUBDIRS_LIBRARIES.$(BUILD_TARGET))          $(SUBDIRS_BINARIES)          $(SUBDIRS_BINARIES.$(BUILD_TARGET))          $(SUBDIRS_OTHERS)          $(SUBDIRS_OTHERS.$(BUILD_TARGET)))
+SUBDIRS_AFTER_PUBLISH   ?= $(sort $(SUBDIRS_AFTER)    $(SUBDIRS_AFTER.$(BUILD_TARGET))    $(SUBDIRS_AFTER_LIBRARIES)    $(SUBDIRS_AFTER_LIBRARIES.$(BUILD_TARGET))    $(SUBDIRS_AFTER_BINARIES)    $(SUBDIRS_AFTER_BINARIES.$(BUILD_TARGET))    $(SUBDIRS_AFTER_OTHERS)    $(SUBDIRS_AFTER_OTHERS.$(BUILD_TARGET)))
+MAKEFILES_BEFORE_PUBLISH?= $(sort $(MAKEFILES_BEFORE) $(MAKEFILES_BEFORE.$(BUILD_TARGET)) $(MAKEFILES_BEFORE_LIBRARIES) $(MAKEFILES_BEFORE_LIBRARIES.$(BUILD_TARGET)) $(MAKEFILES_BEFORE_BINARIES) $(MAKEFILES_BEFORE_BINARIES.$(BUILD_TARGET)) $(MAKEFILES_BEFORE_OTHERS) $(MAKEFILES_BEFORE_OTHERS.$(BUILD_TARGET)))
+MAKEFILES_AFTER_PUBLISH ?= $(sort $(MAKEFILES_AFTER)  $(MAKEFILES_AFTER.$(BUILD_TARGET))  $(MAKEFILES_AFTER_LIBRARIES)  $(MAKEFILES_AFTER_LIBRARIES.$(BUILD_TARGET))  $(MAKEFILES_AFTER_BINARIES)  $(MAKEFILES_AFTER_BINARIES.$(BUILD_TARGET))  $(MAKEFILES_AFTER_OTHERS)  $(MAKEFILES_AFTER_OTHERS.$(BUILD_TARGET)))
+$(eval $(def_pass))
+
+## PASS: packing
+# This pass processes custom packing rules.
+pass_packing_doit: packing
+packing::
+pass := packing
+PASS := PACKING
+$(eval $(def_pass))
+
+## PASS: clean
+# This pass removes all generated files.
+pass_clean_doit:
+	$(RM) -f $(_OUT_FILES) $(_OBJS) $(_DEPFILES) $(_DIRFILES) $(OTHER_CLEAN)
+pass := clean
+PASS := CLEAN
+$(eval $(def_pass))
+clean: pass_clean
+
+## PASS: nothing
+# This pass just walks the tree.
+pass_nothing_doit:
+	$(call MSG_L1,Did nothing in $(CURDIR))
+pass := nothing
+PASS := NOTHING
+$(eval $(def_pass))
+nothing: pass_nothing
+
+
+## Pass order
+# @param	$(pass)		Current pass name.
+# @param	$(prev_pass)	The previous pass name.
+define def_pass_order
+pass_$(pass)_order: $(pass_prev)
+	$(call MSG_L1,Pass $(pass))
+	+ $(QUIET)$$(MAKE) -f $$(MAKEFILE) pass_$(pass)
+.NOTPARALLEL: pass_$(pass)_order
+$(eval pass_prev := pass_$(pass)_order)
+endef
+
+## PASS: order
+# Use dependencies to ensure correct pass order.
+pass_prev :=
+$(foreach pass,$(PASSES),$(eval $(def_pass_order)))
+
+     
+#
+# THE MAIN RULES
+#
+all_recursive: $(pass_prev)
+
+rebuild: clean
+	+ $(MAKE) -f $(firstword $(MAKEFILE_LIST)) all_recursive
+
+
+# misc shortcuts.
+target:    bldprogs libraries binaries others
+objects:   $(_OBJS)
+bldprogs:  $(_BLDPROGS)
+libraries: $(_LIBS) $(_IMPORT_LIBS) $(_OTHER_LIBRARIES)
+dlls:      $(_DLLS)
+programs:  $(_PROGRAMS)
+sysmods:   $(_SYSMODS)
+
+
+# end-of-file-content
+__footer_kmk__ := target
+endif # __footer_kmk__
Index: /tags/InnoTek-old-step/kBuild/header.kmk
===================================================================
--- /tags/InnoTek-old-step/kBuild/header.kmk	(revision 497)
+++ /tags/InnoTek-old-step/kBuild/header.kmk	(revision 497)
@@ -0,0 +1,361 @@
+# $Id$
+## @file
+#
+# kBuild - File included at top of makefile.
+#
+# Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
+#
+#
+# This file is part of kBuild.
+#
+# kBuild is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# kBuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kBuild; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#
+
+ifndef __header_kmk__
+# start-of-file-content
+
+#
+# default rule
+#
+all: all_recursive
+
+#
+# Try avoid inference rules.
+#
+.SUFFIXES:
+SUFFIXES :=
+
+
+#
+# General purpose macros.
+#
+
+## get last word in a list.
+# @returns  last word in $1.
+# @param    $1	Word list.
+lastword = $(word $(words $(1)), $(1))
+
+
+#
+# Assert build type.
+#
+ifndef BUILD_TYPE
+ifndef BUILD_MODE
+$(error kBuild: You must define BUILD_TYPE!)
+endif
+BUILD_TYPE          := $(BUILD_MODE)
+endif
+ifeq ($(BUILD_TYPE),DEBUG)
+BUILD_TYPE          := debug
+endif
+ifeq ($(BUILD_TYPE),RELEASE)
+BUILD_TYPE          := release
+endif
+ifeq ($(BUILD_TYPE),PROFILE)
+BUILD_TYPE          := profile
+endif
+
+
+#
+# Assert build platform.
+#
+_BUILD_PLATFORM_OK  := 0
+# OS/2
+ifeq ($(BUILD_PLATFORM),OS2)
+$(error kBuild: BUILD_PLATFORM must be all lowercase!)
+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
+
+ifeq ($(_BUILD_PLATFORM_OK),0)
+$(error kBuild: BUILD_PLATFORM value '$(BUILD_PLATFORM)' was not recongized!)
+endif
+BUILD_PLATFORM_ARCH   := x86
+BUILD_PLATFORM_CPU    := i586
+
+
+#
+# Assert target platform.
+#
+ifndef BUILD_TARGET
+# not defined, set to the same as build platform
+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
+
+ifeq ($(_BUILD_TARGET_OK),0)
+$(error kBuild: BUILD_TARGET value '$(BUILD_TARGET)' was not recongized!)
+endif
+endif
+BUILD_TARGET_ARCH   := x86
+BUILD_TARGET_CPU    := i586
+
+
+#
+# Common definitions.
+#
+PATH_CURRENT        := $(CURDIR)
+# Get the real root path.
+PATH_ROOT           := $(PATH_CURRENT)
+ifneq ($(DEPTH),.)
+$(foreach d,$(subst /, ,$(DEPTH)), $(eval PATH_ROOT := $(patsubst %/,%,$(dir $(PATH_ROOT)))) )
+endif
+# Subdirectory relative to the root.
+CURSUBDIR           := $(patsubst $(PATH_ROOT)/%,%,$(CURDIR))
+# Output directories.
+ifndef PATH_OUT_BASE
+PATH_OUT_BASE       := $(PATH_ROOT)/out
+endif
+ifndef PATH_OUT
+PATH_OUT            := $(PATH_OUT_BASE)/$(BUILD_TARGET)/$(BUILD_TYPE)
+endif
+PATH_OBJ            := $(PATH_OUT)/obj
+PATH_BIN            := $(PATH_OUT)/bin
+PATH_LIB            := $(PATH_OUT)/lib
+PATH_DOC            := $(PATH_ROOT)/out/doc
+PATH_TARGET         := $(PATH_OBJ)/$(CURSUBDIR)
+
+# Usually kBuild is external to the source tree.
+ifndef PATH_KBUILD
+PATH_KBUILD         := $(PATH_ROOT)/kBuild
+endif
+# kBuild tools
+PATH_TOOLS_W32      := $(PATH_KBUILD)/bin/x86.win32
+PATH_TOOLS_LNX      := $(PATH_KBUILD)/bin/x86.linux
+PATH_TOOLS_OS2      := $(PATH_KBUILD)/bin/x86.os2
+# kBuild files which might be of interest.
+FILE_KBUILD_HEADER  := $(PATH_KBUILD)/header.kmk
+FILE_KBUILD_CONFIG  := $(PATH_KBUILD)/config.kmk
+FILE_KBUILD_FOOTER  := $(PATH_KBUILD)/footer.kmk
+
+SUFF_DEP            := .dep
+MAKEFILE            := $(firstword $(MAKEFILE_LIST))
+
+
+#
+# Get rid of the GNU Make default stuff
+#
+ifndef KMK_VERSION
+include $(PATH_KBUILD)/StampOutPredefines.kmk
+endif
+
+#
+# Build platform setup.
+#
+# OS/2
+ifeq ($(BUILD_PLATFORM),os2)
+PATH_TOOLS          := $(PATH_TOOLS_OS2)
+EXEC_X86_WIN32      := innopec.exe
+HOSTSUFF_EXE        := .exe
+endif
+
+# Linux
+ifeq ($(BUILD_PLATFORM),linux)
+PATH_TOOLS          := $(PATH_TOOLS_LNX)
+EXEC_X86_WIN32      := wine
+HOSTSUFF_EXE        :=
+endif
+
+# Win32
+ifeq ($(BUILD_PLATFORM),win32)
+PATH_TOOLS          := $(PATH_TOOLS_W32)
+EXEC_X86_WIN32      :=
+HOSTSUFF_EXE        := .exe
+endif
+
+
+#
+# Build target setup.
+#
+ifeq ($(BUILD_TARGET),os2)
+SUFF_OBJ            := .obj
+SUFF_LIB            := .lib
+SUFF_DLL            := .dll
+SUFF_EXE            := .exe
+SUFF_SYS            := .sys
+SUFF_RES            := .res
+endif
+ifeq ($(BUILD_TARGET),win32)
+SUFF_OBJ            := .obj
+SUFF_LIB            := .lib
+SUFF_DLL            := .dll
+SUFF_EXE            := .exe
+SUFF_SYS            := .sys
+SUFF_RES            := .res
+endif
+ifeq ($(BUILD_TARGET),linux)
+SUFF_OBJ            := .o
+SUFF_LIB            := .a
+SUFF_DLL            := .so
+SUFF_EXE            :=
+SUFF_SYS            := .a
+SUFF_RES            :=
+endif
+
+
+#
+# Standard kBuild tools.
+#
+DEP                 := $(PATH_TOOLS)/kDep$(HOSTSUFF_EXE)
+ifdef KBUILD_VCC70_DEPS
+DEP_CCXX            := $(PATH_TOOLS)/kDepCCxx$(HOSTSUFF_EXE)
+else
+DEP_CCXX            := echo $(PATH_TOOLS)/kDepCCxx$(HOSTSUFF_EXE)
+endif
+ifeq ($(MAKE),kmk)
+MAKE                := $(PATH_TOOLS)/kmk$(HOSTSUFF_EXE)
+endif
+
+# Standard Unix shell utils.
+ifdef KMK_BUILTIN
+ECHO                := kmk_builtin_echo
+MKDIR               := kmk_builtin_mkdir
+RM                  := kmk_builtin_rm
+CP                  := kmk_builtin_cp
+else
+ECHO                := echo
+MKDIR               := $(PATH_TOOLS)/mkdir$(HOSTSUFF_EXE)
+RM                  := $(PATH_TOOLS)/rm$(HOSTSUFF_EXE)
+CP                  := $(PATH_TOOLS)/cp$(HOSTSUFF_EXE)
+endif
+CP_EXT              := $(PATH_TOOLS)/cp$(HOSTSUFF_EXE)
+MV                  := $(PATH_TOOLS)/mv$(HOSTSUFF_EXE)
+SED                 := $(PATH_TOOLS)/sed$(HOSTSUFF_EXE)
+CAT                 := $(PATH_TOOLS)/cat$(HOSTSUFF_EXE)
+# Bourn shell clone.
+MAKESHELL           := $(PATH_TOOLS)/ash$(HOSTSUFF_EXE)
+SHELL               := $(MAKESHELL)
+export SHELL MAKESHELL
+
+
+#
+# Message macros.
+#
+
+ifndef BUILD_QUIET
+ifdef BUILD_DEBUG
+BUILD_VERBOSE := 9
+endif
+MSG_L1		= @$(ECHO) "kBuild: $1"
+ifdef BUILD_VERBOSE
+MSG_L2		= @$(ECHO) "kBuild: $1"
+QUIET		:=
+else
+QUIET		:= @
+MSG_L2		=
+endif
+ifdef BUILD_DEBUG
+MSG_L3      = @$(ECHO) "kBuild: $1"
+else
+MSG_L3      =
+endif
+else
+QUIET		:=
+MSG_L1		=
+MSG_L2      =
+MSG_L3      =
+endif
+
+## ABSPATH - make paths absolute.
+# This implementation is clumsy and doesn't resolve '..' and '.' components.
+#
+# @param	$1	The paths to make absolute.
+ABSPATH = $(foreach path,$(1)\
+            ,$(strip $(if $(subst <,,$(firstword $(subst /, ,<$(path)))),\
+                      $(if $(patsubst %:,,$(firstword $(subst :,: ,$(path)))),$(PATH_CURRENT)/$(path),$(path)),\
+                      $(path))))
+## DIRDEP - make create directory dependencies.
+#
+# @param	$1	The paths to the directories which must be created.
+DIRDEP = $(foreach path,$(1),$(path)/.dir_created)
+
+
+## Cygwin kludge.
+# This converts /cygdrive/x/% to x:%.
+#
+# @param	$1	The paths to make native.
+# @remark	This macro is pretty much obsolete since we don't use cygwin base make.
+ifneq ($(patsubst /cygdrive/%,%,$(CURDIR)),$(CURDIR))
+CYGPATHMIXED = $(foreach path,$(1)\
+   ,$(if $(patsubst /cygdrive/%,,$(path)),$(path),$(patsubst $(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path)))))/%,$(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path))))):/%,$(patsubst /cygdrive/%,%,$(path)))))
+else
+CYGPATHMIXED = $(1)
+endif
+
+#
+# This is how we find the closest config.kmk.
+# It's a little hacky but I think it works fine.
+#
+_CFGDIR     := .
+_CFGFILES   := ./Config.kmk ./config.kmk
+define def_include_config
+$(eval _CFGDIR := $(_CFGDIR)/$(dir))
+_CFGFILES   += $(_CFGDIR)/Config.kmk $(_CFGDIR)/config.kmk
+endef
+# walk down the _RELATIVE_ path specified by DEPTH.
+$(foreach dir,$(subst /, ,$(DEPTH)), $(eval $(def_include_config)) )
+# add the default config file.
+_CFGFILE    := $(firstword $(wildcard $(_CFGFILES) $(FILE_KBUILD_CONFIG)))
+_CFGFILES   :=
+_CFGDIR     :=
+
+# Include the config.kmk we found file (or the default one).
+include $(_CFGFILE)
+
+
+# end-of-file-content
+__header_kmk__ := 1
+endif # __header_kmk__
Index: /tags/InnoTek-old-step/kBuild/programs.kmk
===================================================================
--- /tags/InnoTek-old-step/kBuild/programs.kmk	(revision 497)
+++ /tags/InnoTek-old-step/kBuild/programs.kmk	(revision 497)
@@ -0,0 +1,144 @@
+# $Id$
+## @file
+# This file deals with TARGET_PROGRAMS.
+# It should only be included from rules.kMk.
+#
+# Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net>
+#
+#
+# This file is part of kBuild.
+#
+# kBuild is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# kBuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kBuild; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#
+
+# Assert correct context
+.ifndef __RULES_KMK__
+.error $(MAKEFILE) can only be included from rules.kMk.
+.endif
+
+
+## @page Makefile           Makefile
+#
+# A makefile defines a context. The context consists of a .CURDIR, .OBJDIR,
+# and stuff done by the config.kMk. Sources for instance is always relative
+# to .CURDIR, while objects and other output files are relative to .OBJDIR.
+#
+#
+# @todo move this page
+
+
+
+## @page TARGET_PROGRAMS    TARGET_PROGRAMS
+#
+# Programs to be made. On platforms which enforces extensions for programs
+# the default extension is added.
+# Modules listed in TARGET_PROGRAMS should NOT be listed TARGETS.
+#
+# Let's say TARGET_PROGRAMS = foo. Then you can configure the executable foo
+# using the following macros:
+#
+# foo_SOURCES   - The sources files which object files foo is linked to
+#                 together of.
+#
+# foo_TEMPLATE  - Compiler, linker, and more setup.
+#
+#
+# foo_DEFINES   - Defines used by all tools which support it. No -D should be
+#                 used as this is tool specific. Defines which have a value
+#                 must use '=' as assignment, foo_DEFINES=VER=1 for instance.
+#
+# foo_INCLUDES  - Include directories used by all tools which support it. No -I
+#                 or similar should be used as this is tool specific. Directories
+#                 are separated by ';'.
+#
+# foo_LIBS      - Libraries to link with.
+#
+#
+# C Compilers:
+# foo_CTOOL     - The C compiler tool to use.
+# foo_CDEFS     - C compiler defines.
+# foo_CINCS     - C compiler include directories.
+# foo_COPTS     - C compiler options. This is somewhat compiler independant.
+# foo_CFLAGS    - C compiler flags. Specifying compiler specific flags.
+#
+#
+# C++ Compilers:
+# foo_CXXTOOL   - The C++ compiler tool to use.
+# foo_CXXDEFS   - C++ compiler defines.
+# foo_CXXINCS   - C++ compiler include directories.
+# foo_CXXOPTS   - C++ compiler options. This is somewhat compiler independant.
+# foo_CXXFLAGS  - C++ compiler flags. Specifying compiler specific flags.
+#
+#
+# Assemblers:
+# foo_ASTOOL    - The assembler tool to use.
+# foo_ASDEFS    - Assembler defines.
+# foo_ASINCS    - Assembler include directories.
+# foo_ASOPTS    - Assembler options. This is somewhat assembler independant.
+# foo_ASFLAGS   - Assembler flags. Specifying compiler specific flags.
+#
+#
+# Resource Compilers:
+# foo_RCTOOL    - The Resource compiler tool to use.
+# foo_RCDEFS    - Resource compiler defines.
+# foo_RCINCS    - Resource compiler include directories.
+# foo_RCOPTS    - Resource compiler options. This is somewhat compiler independant.
+# foo_RCFLAGS   - Resource compiler flags. Specifying compiler specific flags.
+#
+#
+# Link Editors:
+# foo_LDTOOL    - The link editor tool to use.
+# foo_LDOPTS    - Link editor options. This is somewhat link editor independant.
+# foo_LDFLAGS   - Link editor flags. Specifying link editor specific flags.
+# foo_LDDEFFILE - Link editor definition file. (PC thingy)
+# foo_LDLIBS    - Link editor . (PC thingy)
+#
+#
+#
+
+
+#
+# Generate program rules.
+#
+.for trgt in ${TARGET_PROGRAMS}
+
+${trgt}_int_objects     :=
+TARGETS                 += ${trgt}${SFX_EXE}
+
+
+# rules for each of the C source files.
+.for src in ${${trgt}_SOURCES:M*.c}
+int_object              := ${src}
+${trgt}_int_objects     += ${int_object}
+
+.endfor
+
+#.for csrc in ${${trgt}_SOURCES:M${SFXS_C:S@^@*@}}
+.for csrc in ${${trgt}_SOURCES:M*.c}
+${trgt}__OBJECTS        += ${csrc:S@.${csrc:E}@${SFX_OBJ}@}
+${csrc:S@.${csrc:E}@${SFX_OBJ}@}: ${csrc}
+    echo "compiling ${.ALLSRC} -> $@"
+.endfor
+
+
+# linking rule
+${trgt}${SFX_EXE}: ${trgt}_int_objects
+    echo "$@"
+
+.endfor
+
+# clean up := variables we've used.
+
Index: /tags/InnoTek-old-step/kBuild/rules.kmk
===================================================================
--- /tags/InnoTek-old-step/kBuild/rules.kmk	(revision 497)
+++ /tags/InnoTek-old-step/kBuild/rules.kmk	(revision 497)
@@ -0,0 +1,37 @@
+# $Id$
+## @file
+#
+# kBuild - File included at top of makefile.
+#
+# Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
+#
+#
+# This file is part of kBuild.
+#
+# kBuild is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# kBuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kBuild; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#
+
+ifdef PATH_KBUILD
+# Usual location.
+include $(PATH_KBUILD)/header.kmk
+else
+# Default location.
+include $(DEPTH)/kBuild/header.kmk
+endif
+
+# PATH_KBUILD is defined now.
+include $(PATH_KBUILD)/footer.kmk
+
Index: /tags/InnoTek-old-step/kBuild/sdks/NT4DDK.kmk
===================================================================
--- /tags/InnoTek-old-step/kBuild/sdks/NT4DDK.kmk	(revision 497)
+++ /tags/InnoTek-old-step/kBuild/sdks/NT4DDK.kmk	(revision 497)
@@ -0,0 +1,41 @@
+# $Id$
+## @file
+#
+# kBuild SDK - NT4 DDK.
+#
+# Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
+#
+#
+# This file is part of kBuild.
+#
+# kBuild is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# kBuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kBuild; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#
+
+
+SDK_NT4DDK			:= MicroSoft NT 4 DDK
+PATH_SDK_NT4DDK     := $(PATH_DEV)/x86.win32/nt4ddk
+PATH_SDK_NT4DDK_INC := $(PATH_SDK_NT4DDK)/inc
+ifeq ($(BUILD_TARGET_ARCH),x86)
+PATH_SDK_NT4DDK_LIB := $(PATH_SDK_NT4DDK)/lib/i386/free
+SDK_NT4DDK_DEFS		:= _X86_
+else
+$(error NT4DDK only works targetting x86!)
+PATH_SDK_NT4DDK_LIB := $(PATH_SDK_NT4DDK)/lib/???/free
+SDK_NT4DDK_DEFS		:=
+endif
+SDK_NT4DDK_INCS		:= $(PATH_SDK_NT4DDK_INC)
+SDK_NT4DDK_LIBPATHS	:= $(PATH_SDK_NT4DDK_LIB)
+
Index: /tags/InnoTek-old-step/kBuild/sdks/W32API.kmk
===================================================================
--- /tags/InnoTek-old-step/kBuild/sdks/W32API.kmk	(revision 497)
+++ /tags/InnoTek-old-step/kBuild/sdks/W32API.kmk	(revision 497)
@@ -0,0 +1,35 @@
+# $Id$
+## @file
+#
+# kBuild SDK - MinGW Windows API.
+#
+# Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
+#
+#
+# This file is part of kBuild.
+#
+# kBuild is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# kBuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kBuild; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#
+
+
+SDK_W32API                  := MinGW Windows API
+PATH_SDK_W32API             ?= $(PATH_DEV)/x86.win32/w32api/v2.5
+PATH_SDK_W32API_INC         := $(PATH_SDK_W32API)/include
+PATH_SDK_W32API_LIB         := $(PATH_SDK_W32API)/lib
+
+SDK_W32API_INCS		        := $(PATH_SDK_W32API_INC)
+SDK_W32API_LIBPATH          := $(PATH_SDK_W32API_LIB)
+
Index: /tags/InnoTek-old-step/kBuild/testcase/Inheritance.kmk
===================================================================
--- /tags/InnoTek-old-step/kBuild/testcase/Inheritance.kmk	(revision 497)
+++ /tags/InnoTek-old-step/kBuild/testcase/Inheritance.kmk	(revision 497)
@@ -0,0 +1,44 @@
+# $Id$
+
+#
+# Interitance testcase.
+#
+
+# this shall be overrided by the template!							
+TOOL				= GCC3
+
+LIBRARIES           = libHello1 libHello2 libHello3 libHello4
+
+libHello1_SOURCES   = hello.c
+libHello1_TEMPLATE  = mylib
+
+libHello2_SOURCES   = hello.c
+libHello2_TOOL      = VCC70
+libHello2_TEMPLATE  = mylib
+
+libHello3_SOURCES   = hello.c
+
+libHello4_SOURCES   = hello.c
+libHello4_TOOL      = GCC
+
+DEPTH = ../..
+include $(DEPTH)/kBuild/rules.kmk
+
+ifneq ($(libHello1_TOOL),GCC)
+$(error	kBuild internal error-1: I'm not getting the right TOOL! Got '$(libHello1_TOOL)' expected 'GCC'.)
+endif
+
+ifneq ($(libHello2_TOOL),VCC70)
+$(error	kBuild internal error-2: I'm not getting the right TOOL! Got '$(libHello2_TOOL)' expected 'VCC70'.)
+endif
+
+ifneq ($(libHello3_TOOL),GCC3)
+$(error	kBuild internal error-3: I'm not getting the right TOOL! Got '$(libHello3_TOOL)' expected 'GCC3'.)
+endif
+
+ifneq ($(libHello4_TOOL),GCC)
+$(error	kBuild internal error-4: I'm not getting the right TOOL! Got '$(libHello4_TOOL)' expected 'GCC'.)
+endif
+							
+
+
Index: /tags/InnoTek-old-step/kBuild/testcase/config.kmk
===================================================================
--- /tags/InnoTek-old-step/kBuild/testcase/config.kmk	(revision 497)
+++ /tags/InnoTek-old-step/kBuild/testcase/config.kmk	(revision 497)
@@ -0,0 +1,21 @@
+# define template mylib
+TEMPLATE_mylib := Sample template for testing kBuild
+TEMPLATE_mylib_TOOL       := GCC
+TEMPLATE_mylib_DEFS       := MYLIB_DEFS
+TEMPLATE_mylib_INCS       := /mylib_incs
+
+TEMPLATE_mylib_CDEFS      := MYLIB_CDEFS
+TEMPLATE_mylib_CINCS      := /mylib_cincs
+TEMPLATE_mylib_CFLAGS     := -DMYLIB_CFLAGS=1
+TEMPLATE_mylib_COPTS      := Debug
+
+TEMPLATE_mylib_CXXDEFS    := MYLIB_CXXDEFS
+TEMPLATE_mylib_CXXINCS    := /mylib_cxxincs
+TEMPLATE_mylib_CXXFLAGS   := -DMYLIB_CXXFLAGS=1
+TEMPLATE_mylib_CXXOPTS    := Debug
+
+TEMPLATE_mylib_ASDEFS     := MYLIB_ASDEFS
+TEMPLATE_mylib_ASINCS     := /mylib_asincs
+TEMPLATE_mylib_ASFLAGS    := -DMYLIB_ASFLAGS=1
+TEMPLATE_mylib_ASOPTS     := Debug
+						
Index: /tags/InnoTek-old-step/kBuild/testcase/hello.c
===================================================================
--- /tags/InnoTek-old-step/kBuild/testcase/hello.c	(revision 497)
+++ /tags/InnoTek-old-step/kBuild/testcase/hello.c	(revision 497)
@@ -0,0 +1,6 @@
+#include <stdio.h>
+int main()
+{
+    printf("hello world\n");
+    return 0;
+}
Index: /tags/InnoTek-old-step/kBuild/tools/GCC.kmk
===================================================================
--- /tags/InnoTek-old-step/kBuild/tools/GCC.kmk	(revision 497)
+++ /tags/InnoTek-old-step/kBuild/tools/GCC.kmk	(revision 497)
@@ -0,0 +1,197 @@
+# $Id$
+## @file
+#
+# kBuild Tool Config - Generic GCC.
+#
+# Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
+#
+#
+# This file is part of kBuild.
+#
+# kBuild is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# kBuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kBuild; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#
+
+
+TOOL_GCC                    := Generic GCC
+
+TOOL_GCC_CC                 := gcc$(HOSTSUFF_EXE)
+TOOL_GCC_COBJSUFF           := .o
+TOOL_GCC_CFLAGS             := -g
+TOOL_GCC_CFLAGS.debug       := -O0
+TOOL_GCC_CFLAGS.release     := -O2
+TOOL_GCC_CFLAGS.profile     := -O2 #-pg
+TOOL_GCC_CINCS              :=
+TOOL_GCC_CDEFS              :=
+
+TOOL_GCC_CXX                := g++$(HOSTSUFF_EXE)
+TOOL_GCC_CXXOBJSUFF         := .o
+TOOL_GCC_CXXOBJSUFF         := .o
+TOOL_GCC_CXXFLAGS           := -g
+TOOL_GCC_CXXFLAGS.debug     := -O0
+TOOL_GCC_CXXFLAGS.release   := -O2
+TOOL_GCC_CXXFLAGS.profile   := -O2 #-pg
+TOOL_GCC_CXXINCS            :=
+TOOL_GCC_CXXDEFS            :=
+
+TOOL_GCC_AS                 := as$(HOSTSUFF_EXE)
+TOOL_GCC_ASOBJSUFF          := .o
+
+TOOL_GCC_AR                 := ar$(HOSTSUFF_EXE)
+TOOL_GCC_ARFLAGS            := cr
+TOOL_GCC_ARLIBSUFF          := .a
+
+TOOL_GCC_LD                 := g++$(HOSTSUFF_EXE)
+TOOL_GCC_LDFLAGS            :=
+TOOL_GCC_LDFLAGS.debug      := -g
+TOOL_GCC_LDFLAGS.release    := -s
+TOOL_GCC_LDFLAGS.dll.os2    := -Zdll
+ifndef TOOL_GCC_LDFLAGS.$(BUILD_TARGET)
+TOOL_GCC_LDFLAGS.dll        := -shared
+else
+TOOL_GCC_LDFLAGS.dll        := $(TOOL_GCC_LDFLAGS.$(BUILD_TARGET))
+endif
+
+
+## Compile C source.
+# @param    $(target)   Normalized main target name.
+# @param    $(source)   Source filename (relative).
+# @param    $(obj)      Object file name. This shall be (re)created by the compilation.
+# @param    $(dep)	    Dependcy file. This shall be (re)created by the compilation.
+# @param    $(flags)    Flags.
+# @param    $(defs)     Definitions. No -D or something.
+# @param    $(incs)     Includes. No -I or something.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)		Other dependencies.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+# @param    $(objsuff)  Object suffix.
+define TOOL_GCC_COMPILE_C
+#$ (warning dbg: TOOL_GCC_COMPILE_C: target=$(target) source=$(source) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff) deps=$(deps))
+$(obj): $(PATH_CURRENT)/$(source) $(deps) | $(dirdep)
+	$(call MSG_L2,Compiling $$@ using GCC)
+	$(TOOL_GCC_CC) -c\
+		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
+		-Wp,-MD,$(dep) -Wp,-MT,$$@ \
+		-o $$@\
+		$(call ABSPATH,$(source))
+
+endef
+
+
+## Compile C++ source.
+# @param    $(target)   Normalized main target name.
+# @param    $(source)   Source filename (relative).
+# @param    $(obj)      Object file name. This shall be (re)created by the compilation.
+# @param    $(dep)	    Dependcy file. This shall be (re)created by the compilation.
+# @param    $(flags)    Flags.
+# @param    $(defs)     Definitions. No -D or something.
+# @param    $(incs)     Includes. No -I or something.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)		Other dependencies.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+# @param    $(objsuff)  Object suffix.
+define TOOL_GCC_COMPILE_CXX
+#$ (warning dbg: TOOL_GCC_COMPILE_CXX: target=$(target) source=$(source) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff) deps=$(deps))
+$(obj): $(source) $(deps) | $(dirdep)
+	$(call MSG_L2,Compiling $$@ using GCC)
+	$(TOOL_GCC_CXX) -c\
+		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
+		-Wp,-MD,$(dep) -Wp,-MT,$$@ \
+		-o $$@\
+		$(call ABSPATH,$(source))
+
+endef
+
+
+## Link library
+# @param    $(target)   Normalized main target name.
+# @param    $(lib)		Library name.
+# @param    $(objs)     Object files to put in the library.
+# @param    $(flags)    Flags.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)		Other dependencies.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+define TOOL_GCC_LINK_LIBRARY
+#$ (warning dbg: TOOL_GCC_LINK_LIBRARY: target=$(target) lib=$(lib) objs=$(objs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) outbase=$(outbase))
+$(lib): $(objs) $(deps) | $(dirdep)
+	$(call MSG_L1,Creating Library $$@)
+	$(RM) -f $$@
+	$(TOOL_GCC_AR) $(flags) $$@ $(objs)
+
+endef
+
+
+## Link program
+# @param    $(target)   Normalized main target name.
+# @param    $(exe)		Program name.
+# @param    $(objs)     Object files to link together.
+# @param    $(libs)     Libraries to search.
+# @param    $(libpath)  Library search paths.
+# @param    $(flags)    Flags.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)		Other dependencies.
+# @param    $(othersrc) Unhandled sources.
+# @param    $(custom_pre)   Custom step invoked before linking.
+# @param    $(custom_post)  Custom step invoked after linking.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+define TOOL_GCC_LINK_PROGRAM
+#$ (warning dbg: TOOL_GCC_LINK_PROGRAM: target=$(target) exe=$(exe) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) deffile=$(deffile) outbase=$(outbase))
+$(exe): $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps) | $(dirdep)
+	$(call MSG_L1,Creating Program $$@)
+ifneq ($(custom_pre),)
+	$(eval $(custom_pre))
+endif
+	$(TOOL_GCC_LD) $(flags) -o $$@ $(objs) \
+	$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
+ifneq ($(custom_post),)
+	$(eval $(custom_post))
+endif
+
+endef
+
+
+## Link program
+# @param    $(target)   Normalized main target name.
+# @param    $(exe)		Program name.
+# @param    $(objs)     Object files to link together.
+# @param    $(libs)     Libraries to search.
+# @param    $(libpath)  Library search paths.
+# @param    $(flags)    Flags.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)		Other dependencies.
+# @param    $(othersrc) Unhandled sources.
+# @param    $(custom_pre)   Custom step invoked before linking.
+# @param    $(custom_post)  Custom step invoked after linking.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+define TOOL_GCC_LINK_DLL
+#$ (warning dbg: TOOL_GCC_LINK_DLL: target=$(target) exe=$(exe) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) deffile=$(deffile) outbase=$(outbase))
+$(exe): $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps) | $(dirdep)
+	$(call MSG_L1,Creating Program $$@)
+ifneq ($(custom_pre),)
+	$(eval $(custom_pre))
+endif
+	$(TOOL_GCC_LD) $(TOOL_GCC_LDFLAGS.dll) $(flags) -o $$@ $(objs) \
+	$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
+ifneq ($(custom_post),)
+	$(eval $(custom_post))
+endif
+
+endef
+
Index: /tags/InnoTek-old-step/kBuild/tools/GCC3.kmk
===================================================================
--- /tags/InnoTek-old-step/kBuild/tools/GCC3.kmk	(revision 497)
+++ /tags/InnoTek-old-step/kBuild/tools/GCC3.kmk	(revision 497)
@@ -0,0 +1,279 @@
+# $Id$
+## @file
+#
+# kBuild Tool Config - Generic GCC.
+#
+# Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
+#
+#
+# This file is part of kBuild.
+#
+# kBuild is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# kBuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kBuild; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#
+
+TOOL_GCC3                    := Generic GCC v3
+
+TOOL_GCC3_CC                 := gcc$(HOSTSUFF_EXE)
+TOOL_GCC3_COBJSUFF           := .o
+TOOL_GCC3_CFLAGS             := -g
+TOOL_GCC3_CFLAGS.debug       := -O0
+TOOL_GCC3_CFLAGS.release     := -O2
+TOOL_GCC3_CFLAGS.profile     := -O2 #-pg
+TOOL_GCC3_CINCS              :=
+TOOL_GCC3_CDEFS              :=
+
+TOOL_GCC3_CXX                := g++$(HOSTSUFF_EXE)
+TOOL_GCC3_CXXOBJSUFF         := .o
+TOOL_GCC3_CXXOBJSUFF         := .o
+TOOL_GCC3_CXXFLAGS           := -g
+TOOL_GCC3_CXXFLAGS.debug     := -O0
+TOOL_GCC3_CXXFLAGS.release   := -O2
+TOOL_GCC3_CXXFLAGS.profile   := -O2 #-pg
+TOOL_GCC3_CXXINCS            :=
+TOOL_GCC3_CXXDEFS            :=
+
+TOOL_GCC3_AS                 := as$(HOSTSUFF_EXE)
+TOOL_GCC3_ASOBJSUFF          := .o
+
+TOOL_GCC3_AR                 := ar$(HOSTSUFF_EXE)
+TOOL_GCC3_ARFLAGS            := cr
+TOOL_GCC3_ARLIBSUFF          := .a
+
+TOOL_GCC3_LD                 := g++$(HOSTSUFF_EXE)
+TOOL_GCC3_LD_SYSMOD          := ld$(HOSTSUFF_EXE)
+TOOL_GCC3_LDFLAGS            :=
+TOOL_GCC3_LDFLAGS.debug      := -g
+TOOL_GCC3_LDFLAGS.release    := -s
+ifndef TOOL_GCC3_LDFLAGS.$(BUILD_TARGET)
+TOOL_GCC3_LDFLAGS.dll        := -shared
+else
+TOOL_GCC3_LDFLAGS.dll        := $(TOOL_GCC3_LDFLAGS.$(BUILD_TARGET))
+endif
+TOOL_GCC3_LDFLAGS.sysmod     := -r
+TOOL_GCC3_LD_SONAME           = -Wl,-soname=$(firstword $($(1)_SONAME.$(BUILD_TARGET).$(BUILD_TYPE)) $($(1)_SONAME.$(BUILD_TARGET)) $($(1)_SONAME.$(BUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
+ifeq ($(BUILD_TARGET),os2)
+TOOL_GCC3_LD_MAP              = -Zmap $(1)
+else
+TOOL_GCC3_LD_MAP              = -Wl,-Map -Wl,$(1) -Wl,--cref
+endif
+ifeq ($(BUILD_TARGET),os2)
+TOOL_GCC3_LD_SYSMOD_MAP       = -Zmap $(1)
+else
+TOOL_GCC3_LD_SYSMOD_MAP       = -Map $(1) --cref
+endif
+ifdef SLKRUNS
+TOOL_GCC3_CC  += -fmessage-length=0
+TOOL_GCC3_CXX += -fmessage-length=0
+endif
+
+
+## Compile C source.
+# @param    $(target)   Normalized main target name.
+# @param    $(source)   Source filename (relative).
+# @param    $(obj)      Object file name. This shall be (re)created by the compilation.
+# @param    $(dep)	    Dependcy file. This shall be (re)created by the compilation.
+# @param    $(flags)    Flags.
+# @param    $(defs)     Definitions. No -D or something.
+# @param    $(incs)     Includes. No -I or something.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)		Other dependencies.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+# @param    $(objsuff)  Object suffix.
+define TOOL_GCC3_COMPILE_C
+#$ (warning dbg: TOOL_GCC3_COMPILE_C: target=$(target) source=$(source) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff))
+$(obj): $(source) $(deps) | $(dirdep)
+	$(call MSG_L2,Compiling $$@ using GCC3)
+	$(TOOL_GCC3_CC) -c\
+		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
+		-Wp,-MD,$(dep) -Wp,-MT,$$@ \
+		-o $$@\
+		$(call ABSPATH,$(source))
+
+endef
+
+
+## Compile C++ source.
+# @param    $(target)   Normalized main target name.
+# @param    $(source)   Source filename (relative).
+# @param    $(obj)      Object file name. This shall be (re)created by the compilation.
+# @param    $(dep)	    Dependcy file. This shall be (re)created by the compilation.
+# @param    $(flags)    Flags.
+# @param    $(defs)     Definitions. No -D or something.
+# @param    $(incs)     Includes. No -I or something.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)		Other dependencies.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+# @param    $(objsuff)  Object suffix.
+define TOOL_GCC3_COMPILE_CXX
+#$ (warning dbg: TOOL_GCC3_COMPILE_CXX: target=$(target) source=$(source) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff))
+$(obj): $(source) $(deps) | $(dirdep)
+	$(call MSG_L2,Compiling $$@ using GCC3)
+	$(TOOL_GCC3_CXX) -c\
+		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
+		-Wp,-MD,$(dep) -Wp,-MT,$$@ \
+		-o $$@\
+		$(call ABSPATH,$(source))
+
+endef
+
+
+## Link library
+# @param    $(target)   Normalized main target name.
+# @param    $(lib)		Library name.
+# @param    $(objs)     Object files to put in the library.
+# @param    $(flags)    Flags.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)		Other dependencies.
+# @param    $(othersrc) Unhandled sources.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+
+define TOOL_GCC3_LINK_LIBRARY_ADDMOD
+
+	echo "ADDMOD $(o)" >> $$@.ar-script
+endef
+
+define TOOL_GCC3_LINK_LIBRARY_EXPAND_LIB
+
+	$(MKDIR) -p $(dir $(outbase))ar.extract/$(notdir $(srclib))
+	cd $(dir $(outbase))ar.extract/$(notdir $(srclib)) && $(TOOL_GCC3_AR) x $(srclib)
+	for o in `$(TOOL_GCC3_AR) t $(srclib)`; do echo "ADDMOD $(dir $(outbase))ar.extract/$(notdir $(srclib))/$$$${o}" >> $$@.ar-script; done
+endef
+
+define TOOL_GCC3_LINK_LIBRARY
+#$ (warning dbg: TOOL_GCC3_LINK_LIBRARY: target=$(target) lib=$(lib) objs=$(objs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) othersrc=$(othersrc) outbase=$(outbase))
+$(lib): $(objs) $(deps) $(filter %.a %.lib,$(othersrc)) | $(dirdep)
+	$(call MSG_L1,Creating Library $$@)
+	$(RM) -f $$@
+ifneq ($(strip $(filter %.a %.lib,$(othersrc))),)
+	echo "CREATE $$@" > $$@.ar-script
+	$(foreach o, $(objs),$(TOOL_GCC3_LINK_LIBRARY_ADDMOD))
+	$(foreach srclib, $(filter %.a %.lib,$(othersrc)),$(TOOL_GCC3_LINK_LIBRARY_EXPAND_LIB))
+	echo "SAVE" >> $$@.ar-script
+	echo "END" >> $$@.ar-script
+	$(TOOL_GCC3_AR) -M < $$@.ar-script
+	$(RM) -Rf "$(dir $(outbase))ar.extract/"
+else
+	$(TOOL_GCC3_AR) $(flags) $$@ $(objs)
+endif
+
+endef
+
+
+## Link program
+# @param    $(target)   Normalized main target name.
+# @param    $(exe)		Program name.
+# @param    $(objs)     Object files to link together.
+# @param    $(libs)     Libraries to search.
+# @param    $(libpath)  Library search paths.
+# @param    $(flags)    Flags.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)		Other dependencies.
+# @param    $(othersrc) Unhandled sources.
+# @param    $(custom_pre)   Custom step invoked before linking.
+# @param    $(custom_post)  Custom step invoked after linking.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+define TOOL_GCC3_LINK_PROGRAM
+#$ (warning dbg: TOOL_GCC3_LINK_PROGRAM: target=$(target) exe=$(exe) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) deffile=$(deffile) outbase=$(outbase))
+$(exe): $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps) | $(dirdep)
+	$(call MSG_L1,Creating Program $$@)
+ifneq ($(custom_pre),)
+	$(eval $(custom_pre))
+endif
+	$(RM) -f $$@
+	$(TOOL_GCC3_LD) $(flags) -o $$@ $(objs) \
+		$(foreach p,$(libpath), -L$(p)) \
+		$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib))) \
+		$(call TOOL_GCC3_LD_MAP,$(outbase).map)
+ifneq ($(custom_post),)
+	$(eval $(custom_post))
+endif
+_OUT_FILES += $(outbase).map
+
+endef
+
+
+## Link DLL
+# @param    $(target)   Normalized main target name.
+# @param    $(dll)		Program name.
+# @param    $(objs)     Object files to link together.
+# @param    $(libs)     Libraries to search.
+# @param    $(libpath)  Library search paths.
+# @param    $(flags)    Flags.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)		Other dependencies.
+# @param    $(othersrc) Unhandled sources.
+# @param    $(custom_pre)   Custom step invoked before linking.
+# @param    $(custom_post)  Custom step invoked after linking.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+define TOOL_GCC3_LINK_DLL
+#$ (warning dbg: TOOL_GCC3_LINK_PROGRAM: target=$(target) dll=$(dll) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) deffile=$(deffile) outbase=$(outbase))
+$(dll): $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps) | $(dirdep)
+	$(call MSG_L1,Creating Program $$@)
+ifneq ($(custom_pre),)
+	$(eval $(custom_pre))
+endif
+	$(RM) -f $$@
+	$(TOOL_GCC3_LD) $(TOOL_GCC3_LDFLAGS.dll) $(flags) -o $$@ \
+		$(if $(filter linux, $(BUILD_TARGET)),$(call TOOL_GCC3_LD_SONAME,$(target),$(dll))) \
+		$(objs) \
+		$(foreach p,$(libpath), -L$(p)) \
+		$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib))) \
+		$(call TOOL_GCC3_LD_MAP,$(outbase).map)
+ifneq ($(custom_post),)
+	$(eval $(custom_post))
+endif
+_OUT_FILES += $(outbase).map
+
+endef
+
+## Link system module (windows aka driver, linux aka kernel module)
+# @param    $(target)   Normalized main target name.
+# @param    $(sys)		System module name.
+# @param    $(objs)     Object files to link together.
+# @param    $(libs)     Libraries to search.
+# @param    $(libpath)  Library search paths.
+# @param    $(flags)    Flags.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)		Other dependencies.
+# @param    $(othersrc) Unhandled sources.
+# @param    $(custom_pre)   Custom step invoked before linking.
+# @param    $(custom_post)  Custom step invoked after linking.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+define TOOL_GCC3_LINK_SYSMOD
+#$ (warning dbg: TOOL_GCC3_LINK_SYSMOD: target=$(target) sys=$(sys) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) othersrc=$(othersrc) outbase=$(outbase))
+$(sys): $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps) | $(dirdep)
+	$(call MSG_L1,Creating Program $$@)
+ifneq ($(custom_pre),)
+	$(eval $(custom_pre))
+endif
+	$(RM) -f $$@
+	$(TOOL_GCC3_LD_SYSMOD) $(TOOL_GCC3_LDFLAGS.sysmod) $(flags) -o $$@ $(objs) \
+		$(foreach p,$(libpath), -L$(p)) \
+		$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib))) \
+		$(call TOOL_GCC3_LD_SYSMOD_MAP,$(outbase).map)
+ifneq ($(custom_post),)
+	$(eval $(custom_post))
+endif
+_OUT_FILES += $(outbase).map
+
+endef
+
Index: /tags/InnoTek-old-step/kBuild/tools/GCC3OMF.kmk
===================================================================
--- /tags/InnoTek-old-step/kBuild/tools/GCC3OMF.kmk	(revision 497)
+++ /tags/InnoTek-old-step/kBuild/tools/GCC3OMF.kmk	(revision 497)
@@ -0,0 +1,238 @@
+# $Id$
+## @file
+#
+# kBuild Tool Config - OS/2 GCC v3 OMF.
+#
+# Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
+#
+#
+# This file is part of kBuild.
+#
+# kBuild is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# kBuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kBuild; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#
+
+TOOL_GCC3OMF                    := OS/2 GCC v3 OMF
+
+TOOL_GCC3OMF_CC                 := gcc$(HOSTSUFF_EXE)
+TOOL_GCC3OMF_COBJSUFF           := .o
+TOOL_GCC3OMF_CFLAGS             := -g -Zomf
+TOOL_GCC3OMF_CFLAGS.debug       := -O0
+TOOL_GCC3OMF_CFLAGS.release     := -O2
+TOOL_GCC3OMF_CFLAGS.profile     := -O2 #-pg
+TOOL_GCC3OMF_CINCS              :=
+TOOL_GCC3OMF_CDEFS              :=
+
+TOOL_GCC3OMF_CXX                := g++$(HOSTSUFF_EXE)
+TOOL_GCC3OMF_CXXOBJSUFF         := .o
+TOOL_GCC3OMF_CXXOBJSUFF         := .o
+TOOL_GCC3OMF_CXXFLAGS           := -g -Zomf
+TOOL_GCC3OMF_CXXFLAGS.debug     := -O0
+TOOL_GCC3OMF_CXXFLAGS.release   := -O2
+TOOL_GCC3OMF_CXXFLAGS.profile   := -O2 #-pg
+TOOL_GCC3OMF_CXXINCS            :=
+TOOL_GCC3OMF_CXXDEFS            :=
+
+TOOL_GCC3OMF_AS                 := emxomfas$(HOSTSUFF_EXE)
+TOOL_GCC3OMF_ASOBJSUFF          := .obj
+
+TOOL_GCC3OMF_AR                 := emxomfar$(HOSTSUFF_EXE)
+TOOL_GCC3OMF_ARFLAGS            := cr
+TOOL_GCC3OMF_ARLIBSUFF          := .lib
+
+TOOL_GCC3OMF_LD                 := g++$(HOSTSUFF_EXE)
+TOOL_GCC3OMF_LD_SYSMOD          := emxomfld$(HOSTSUFF_EXE)
+TOOL_GCC3OMF_LDFLAGS            := -Zomf
+TOOL_GCC3OMF_LDFLAGS.debug      := -g
+TOOL_GCC3OMF_LDFLAGS.release    := -s
+ifndef TOOL_GCC3OMF_LDFLAGS.$(BUILD_TARGET)
+TOOL_GCC3OMF_LDFLAGS.dll        := -shared -Zdll
+else
+TOOL_GCC3OMF_LDFLAGS.dll        := $(TOOL_GCC3OMF_LDFLAGS.$(BUILD_TARGET))
+endif
+TOOL_GCC3OMF_LDFLAGS.sysmod     := -r
+
+ifdef SLKRUNS
+TOOL_GCC3OMF_CC  += -fmessage-length=0
+TOOL_GCC3OMF_CXX += -fmessage-length=0
+endif
+
+
+## Compile C source.
+# @param    $(target)   Normalized main target name.
+# @param    $(source)   Source filename (relative).
+# @param    $(obj)      Object file name. This shall be (re)created by the compilation.
+# @param    $(dep)	    Dependcy file. This shall be (re)created by the compilation.
+# @param    $(flags)    Flags.
+# @param    $(defs)     Definitions. No -D or something.
+# @param    $(incs)     Includes. No -I or something.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)		Other dependencies.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+# @param    $(objsuff)  Object suffix.
+define TOOL_GCC3OMF_COMPILE_C
+#$ (warning dbg: TOOL_GCC3OMF_COMPILE_C: target=$(target) source=$(source) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff) deps=$(deps))
+$(obj): $(source) $(deps) | $(dirdep)
+	$(call MSG_L2,Compiling $$@ using GCC3)
+	$(TOOL_GCC3OMF_CC) -c\
+		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
+		-Wp,-MD,$(dep) -Wp,-MT,$$@ \
+		-o $$@\
+		$(call ABSPATH,$(source))
+
+endef
+
+
+## Compile C++ source.
+# @param    $(target)   Normalized main target name.
+# @param    $(source)   Source filename (relative).
+# @param    $(obj)      Object file name. This shall be (re)created by the compilation.
+# @param    $(dep)	    Dependcy file. This shall be (re)created by the compilation.
+# @param    $(flags)    Flags.
+# @param    $(defs)     Definitions. No -D or something.
+# @param    $(incs)     Includes. No -I or something.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)		Other dependencies.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+# @param    $(objsuff)  Object suffix.
+define TOOL_GCC3OMF_COMPILE_CXX
+#$ (warning dbg: TOOL_GCC3OMF_COMPILE_CXX: target=$(target) source=$(source) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff) deps=$(deps))
+$(obj): $(source) $(deps) | $(dirdep)
+	$(call MSG_L2,Compiling $$@ using GCC3)
+	$(TOOL_GCC3OMF_CXX) -c\
+		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
+		-Wp,-MD,$(dep) -Wp,-MT,$$@ \
+		-o $$@\
+		$(call ABSPATH,$(source))
+
+endef
+
+
+## Link library
+# @param    $(target)   Normalized main target name.
+# @param    $(lib)		Library name.
+# @param    $(objs)     Object files to put in the library.
+# @param    $(flags)    Flags.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)		Other dependencies.
+# @param    $(othersrc) Unhandled sources.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+define TOOL_GCC3OMF_LINK_LIBRARY
+#$ (warning dbg: TOOL_GCC3OMF_LINK_LIBRARY: target=$(target) lib=$(lib) objs=$(objs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) othersrc=$(othersrc) outbase=$(outbase))
+$(lib): $(objs) $(deps) $(filter %.a %.lib,$(othersrc)) | $(dirdep)
+	$(call MSG_L1,Creating Library $$@)
+	$(RM) -f $$@
+	$(TOOL_GCC3OMF_AR) $(flags) $$@ $(objs) $(filter %.a %.lib,$(othersrc))
+
+endef
+
+
+## Link program
+# @param    $(target)   Normalized main target name.
+# @param    $(exe)		Program name.
+# @param    $(objs)     Object files to link together.
+# @param    $(libs)     Libraries to search.
+# @param    $(libpath)  Library search paths.
+# @param    $(flags)    Flags.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)		Other dependencies.
+# @param    $(othersrc) Unhandled sources.
+# @param    $(custom_pre)   Custom step invoked before linking.
+# @param    $(custom_post)  Custom step invoked after linking.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+define TOOL_GCC3OMF_LINK_PROGRAM
+#$ (warning dbg: TOOL_GCC3OMF_LINK_PROGRAM: target=$(target) exe=$(exe) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) deffile=$(deffile) outbase=$(outbase))
+$(exe): $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps) $(filter %.def, $(othersrc)) | $(dirdep)
+	$(call MSG_L1,Creating Program $$@)
+ifneq ($(custom_pre),)
+	$(eval $(custom_pre))
+endif
+	$(TOOL_GCC3OMF_LD) $(flags) -o $$@ $(objs) \
+		$(filter %.def, $(othersrc)) \
+		$(foreach p,$(libpath), -L$(p)) \
+		$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
+ifneq ($(custom_post),)
+	$(eval $(custom_post))
+endif
+
+endef
+
+
+## Link DLL
+# @param    $(target)   Normalized main target name.
+# @param    $(dll)		Program name.
+# @param    $(objs)     Object files to link together.
+# @param    $(libs)     Libraries to search.
+# @param    $(libpath)  Library search paths.
+# @param    $(flags)    Flags.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)		Other dependencies.
+# @param    $(othersrc) Unhandled sources.
+# @param    $(custom_pre)   Custom step invoked before linking.
+# @param    $(custom_post)  Custom step invoked after linking.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+define TOOL_GCC3OMF_LINK_DLL
+#$ (warning dbg: TOOL_GCC3OMF_LINK_PROGRAM: target=$(target) dll=$(dll) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) deffile=$(deffile) outbase=$(outbase))
+$(dll): $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps) $(filter %.def, $(othersrc)) | $(dirdep)
+	$(call MSG_L1,Creating Program $$@)
+ifneq ($(custom_pre),)
+	$(eval $(custom_pre))
+endif
+	$(TOOL_GCC3OMF_LD) $(TOOL_GCC3OMF_LDFLAGS.dll) $(flags) -o $$@ $(objs) \
+	$(filter %.def, $(othersrc)) \
+	$(foreach p,$(libpath), -L$(p)) \
+	$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
+ifneq ($(custom_post),)
+	$(eval $(custom_post))
+endif
+
+endef
+
+## Link system module (windows aka driver, linux aka kernel module)
+# @param    $(target)   Normalized main target name.
+# @param    $(sys)		System module name.
+# @param    $(objs)     Object files to link together.
+# @param    $(libs)     Libraries to search.
+# @param    $(libpath)  Library search paths.
+# @param    $(flags)    Flags.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)		Other dependencies.
+# @param    $(othersrc) Unhandled sources.
+# @param    $(custom_pre)   Custom step invoked before linking.
+# @param    $(custom_post)  Custom step invoked after linking.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+define TOOL_GCC3OMF_LINK_SYSMOD
+#$ (warning dbg: TOOL_GCC3OMF_LINK_SYSMOD: target=$(target) sys=$(sys) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) othersrc=$(othersrc) outbase=$(outbase))
+$(sys): $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps) $(filter %.def, $(othersrc)) | $(dirdep)
+	$(call MSG_L1,Creating Program $$@)
+ifneq ($(custom_pre),)
+	$(eval $(custom_pre))
+endif
+	$(TOOL_GCC3OMF_LD_SYSMOD) $(TOOL_GCC3OMF_LDFLAGS.sysmod) $(flags) -o $$@ $(objs) \
+		$(filter %.def, $(othersrc)) \
+		$(foreach p,$(libpath), -L$(p)) \
+		$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
+ifneq ($(custom_post),)
+	$(eval $(custom_post))
+endif
+
+endef
+
Index: /tags/InnoTek-old-step/kBuild/tools/MINGW32.kmk
===================================================================
--- /tags/InnoTek-old-step/kBuild/tools/MINGW32.kmk	(revision 497)
+++ /tags/InnoTek-old-step/kBuild/tools/MINGW32.kmk	(revision 497)
@@ -0,0 +1,239 @@
+# $Id$
+## @file
+#
+# kBuild Tool Config - MINGW32 GCC.
+#
+# Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
+#
+#
+# This file is part of kBuild.
+#
+# kBuild is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# kBuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kBuild; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#
+
+TOOL_MINGW32                 := MinGW32 GCC v3.3+
+
+# find latest installed version
+ifndef PATH_TOOL_MINGW32
+PATH_TOOL_MINGW32            := $(sort $(wildcard $(PATH_DEV)/$(BUILD_PLATFORM_ARCH).$(BUILD_PLATFORM)/mingw32/v*.*))
+ifeq ($(PATH_TOOL_MINGW32),)
+PATH_TOOL_MINGW32            := $(sort $(wildcard $(PATH_DEV)/x86.win32/mingw32/v*.*))
+endif
+ifneq ($(PATH_TOOL_MINGW32),)
+PATH_TOOL_MINGW32            := $(call lastword,$(PATH_TOOL_MINGW32))
+endif
+endif
+
+# figure out if it's native or needs a win32 launcher
+_TOOL_MINGW32_PREFIX            :=
+ifneq ($(PATH_TOOL_MINGW32),)
+_TOOL_MINGW32_PREFIX            := $(PATH_TOOL_MINGW32)/bin/
+endif
+_TOOL_MINGW32_SUFF_EXE          := $(HOSTSUFF_EXE)
+ifneq ($(BUILD_PLATFORM),win32)
+# we're cross compiling either using wine/odin or a cross compiler.
+ifneq ($(PATH_TOOL_MINGW32),$(subst x86.win32,,$(PATH_TOOL_MINGW32)))
+_TOOL_MINGW32_PREFIX            := $(EXEC_X86_WIN32) $(_TOOL_MINGW32_PREFIX)
+_TOOL_MINGW32_SUFF_EXE          := .exe
+else
+_TOOL_MINGW32_PREFIX            := $(_TOOL_MINGW32_PREFIX)i386-mingw32msvc-
+_TOOL_MINGW32_SUFF_EXE          :=
+_TOOL_MINGW32_XCOMPILE          := 1
+endif
+endif
+
+TOOL_MINGW32_CC                 := $(_TOOL_MINGW32_PREFIX)gcc$(_TOOL_MINGW32_SUFF_EXE)
+TOOL_MINGW32_COBJSUFF           := .o
+TOOL_MINGW32_CFLAGS             := -g
+TOOL_MINGW32_CFLAGS.debug       := -O0
+TOOL_MINGW32_CFLAGS.release     := -O2
+TOOL_MINGW32_CFLAGS.profile     := -O2 #-pg
+TOOL_MINGW32_CINCS              :=
+TOOL_MINGW32_CDEFS              :=
+
+TOOL_MINGW32_CXX                := $(_TOOL_MINGW32_PREFIX)g++$(_TOOL_MINGW32_SUFF_EXE)
+TOOL_MINGW32_CXXOBJSUFF         := .o
+TOOL_MINGW32_CXXOBJSUFF         := .o
+TOOL_MINGW32_CXXFLAGS           := -g
+TOOL_MINGW32_CXXFLAGS.debug     := -O0
+TOOL_MINGW32_CXXFLAGS.release   := -O2
+TOOL_MINGW32_CXXFLAGS.profile   := -O2 #-pg
+TOOL_MINGW32_CXXINCS            :=
+TOOL_MINGW32_CXXDEFS            :=
+
+TOOL_MINGW32_AS                 := $(_TOOL_MINGW32_PREFIX)as$(_TOOL_MINGW32_SUFF_EXE)
+TOOL_MINGW32_ASOBJSUFF          := .o
+
+TOOL_MINGW32_AR                 := $(_TOOL_MINGW32_PREFIX)ar$(_TOOL_MINGW32_SUFF_EXE)
+TOOL_MINGW32_ARFLAGS            := cr
+TOOL_MINGW32_ARLIBSUFF          := .a
+
+# The linux cross compiler ebuild haven't got g++, this is a hack for that.
+ifndef _TOOL_MINGW32_XCOMPILE
+TOOL_MINGW32_LD                 := $(_TOOL_MINGW32_PREFIX)g++$(_TOOL_MINGW32_SUFF_EXE)
+else
+TOOL_MINGW32_LD                 := $(_TOOL_MINGW32_PREFIX)gcc$(_TOOL_MINGW32_SUFF_EXE)
+endif
+TOOL_MINGW32_LDFLAGS            :=
+TOOL_MINGW32_LDFLAGS.debug      := -g
+TOOL_MINGW32_LDFLAGS.release    := -s
+
+TOOL_MINGW32_DLLWRAP            := $(_TOOL_MINGW32_PREFIX)dllwrap$(_TOOL_MINGW32_SUFF_EXE)
+TOOL_MINGW32_DLLTOOL            := $(_TOOL_MINGW32_PREFIX)dlltool$(_TOOL_MINGW32_SUFF_EXE)
+
+
+## Compile C source.
+# @param    $(target)   Normalized main target name.
+# @param    $(source)   Source filename (relative).
+# @param    $(obj)      Object file name. This shall be (re)created by the compilation.
+# @param    $(dep)	    Dependcy file. This shall be (re)created by the compilation.
+# @param    $(flags)    Flags.
+# @param    $(defs)     Definitions. No -D or something.
+# @param    $(incs)     Includes. No -I or something.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)		Other dependencies.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+# @param    $(objsuff)  Object suffix.
+define TOOL_MINGW32_COMPILE_C
+#$ (warning dbg: TOOL_MINGW32_COMPILE_C: target=$(target) source=$(source) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff) deps=$(deps))
+$(obj): $(source) $(deps) | $(dirdep)
+	$(call MSG_L2,Compiling $$@ using MINGW32)
+	$(TOOL_MINGW32_CC) -c\
+		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
+		-Wp,-MD,$(dep) -Wp,-MT,$$@ \
+		-o $$@\
+		$(call ABSPATH,$(source))
+
+endef
+
+
+## Compile C++ source.
+# @param    $(target)   Normalized main target name.
+# @param    $(source)   Source filename (relative).
+# @param    $(obj)      Object file name. This shall be (re)created by the compilation.
+# @param    $(dep)      Dependcy file. This shall be (re)created by the compilation.
+# @param    $(flags)    Flags.
+# @param    $(defs)     Definitions. No -D or something.
+# @param    $(incs)     Includes. No -I or something.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)     Other dependencies.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+# @param    $(objsuff)  Object suffix.
+define TOOL_MINGW32_COMPILE_CXX
+#$ (warning dbg: TOOL_MINGW32_COMPILE_CXX: target=$(target) source=$(source) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff) deps=$(deps))
+$(obj): $(source) $(deps) | $(dirdep)
+	$(call MSG_L2,Compiling $$@ using MINGW32)
+	$(TOOL_MINGW32_CXX) -c\
+		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
+		-Wp,-MD,$(dep) -Wp,-MT,$$@ \
+		-o $$@\
+		$(call ABSPATH,$(source))
+
+endef
+
+
+## Link library
+# @param    $(target)   Normalized main target name.
+# @param    $(lib)		Library name.
+# @param    $(objs)     Object files to put in the library.
+# @param    $(flags)    Flags.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)		Other dependencies.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+define TOOL_MINGW32_LINK_LIBRARY
+#$ (warning dbg: TOOL_MINGW32_LINK_LIBRARY: target=$(target) lib=$(lib) objs=$(objs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) outbase=$(outbase))
+$(lib): $(objs) $(deps) | $(dirdep)
+	$(call MSG_L1,Creating Library $$@)
+	$(RM) -f $$@
+	$(TOOL_MINGW32_AR) $(flags) $$@ $(objs)
+
+endef
+
+
+## Link program
+# @param    $(target)   Normalized main target name.
+# @param    $(exe)		Program name.
+# @param    $(objs)     Object files to link together.
+# @param    $(libs)     Libraries to search.
+# @param    $(libpath)  Library search paths.
+# @param    $(flags)    Flags.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)		Other dependencies.
+# @param    $(othersrc) Unhandled sources.
+# @param    $(custom_pre)   Custom step invoked before linking.
+# @param    $(custom_post)  Custom step invoked after linking.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+define TOOL_MINGW32_LINK_PROGRAM
+#$ (warning dbg: TOOL_MINGW32_LINK_PROGRAM: target=$(target) exe=$(exe) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) deffile=$(deffile) outbase=$(outbase))
+$(exe): $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps) | $(dirdep)
+	$(call MSG_L1,Creating Program $$@)
+ifneq ($(custom_pre),)
+	$(eval $(custom_pre))
+endif
+	$(TOOL_MINGW32_LD) $(flags) -o $$@ $(objs) \
+	$(foreach p,$(libpath), -L$(p)) \
+	$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
+ifneq ($(custom_post),)
+	$(eval $(custom_post))
+endif
+
+endef
+
+
+## Link system module (windows aka driver, linux aka kernel module)
+# @param    $(target)   Normalized main target name.
+# @param    $(dll)		System module name.
+# @param    $(objs)     Object files to link together.
+# @param    $(libs)     Libraries to search.
+# @param    $(libpath)  Library search paths.
+# @param    $(flags)    Flags.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)		Other dependencies.
+# @param    $(othersrc) Unhandled sources.
+# @param    $(custom_pre)   Custom step invoked before linking.
+# @param    $(custom_post)  Custom step invoked after linking.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+define TOOL_MINGW32_LINK_DLL
+#$ (warning dbg: TOOL_MINGW32_LINK_DLL: target=$(target) dll=$(dll) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) othersrc=$(othersrc) outbase=$(outbase))
+$(dll): $(call DIRDEP,$(PATH_LIB)) $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps) | $(dirdep)
+	$(call MSG_L1,Creating Program $$@)
+ifneq ($(custom_pre),)
+	$(eval $(custom_pre))
+endif
+	$(TOOL_MINGW32_DLLWRAP) $(flags) \
+		--dllname=$(dll) \
+		--output-exp=$(outbase).exp \
+		--output-lib=$(outbase).a \
+		$(foreach def,$(filter %.def,$(othersrc)), --def $(def)) \
+		$(filter %.res,$(othersrc)) \
+		$(objs) \
+		$(foreach p,$(libpath), -L$(p)) \
+		$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
+ifeq ($(filter %.exp .def,$(othersrc)),)
+	$(CP) $(outbase).exp $(outbase).a $(PATH_LIB)/
+endif
+ifneq ($(custom_post),)
+	$(eval $(custom_post))
+endif
+_OUT_FILES += $(outbase).map $(outbase).a $(outbase).exp
+
+endef
+
Index: /tags/InnoTek-old-step/kBuild/tools/NASM.kmk
===================================================================
--- /tags/InnoTek-old-step/kBuild/tools/NASM.kmk	(revision 497)
+++ /tags/InnoTek-old-step/kBuild/tools/NASM.kmk	(revision 497)
@@ -0,0 +1,70 @@
+# $Id$
+## @file
+#
+# kBuild Tool Config - NASM	0.98 or later.
+#
+# Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
+#
+#
+# This file is part of kBuild.
+#
+# kBuild is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# kBuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kBuild; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#
+
+
+TOOL_NASM                     := Netwide Assembler 0.98+
+ifndef PATH_TOOL_NASM
+PATH_TOOL_NASM                := $(sort $(wildcard $(PATH_DEV)/$(BUILD_PLATFORM_ARCH).$(BUILD_PLATFORM)/nasm/v*.*))
+ifneq ($(PATH_TOOL_NASM),)
+PATH_TOOL_NASM                := $(call lastword,$(PATH_TOOL_NASM))
+endif
+endif
+
+ifneq ($(PATH_TOOL_NASM),)
+TOOL_NASM_AS                  := $(PATH_TOOL_NASM)/nasm$(HOSTSUFF_EXE)
+else
+TOOL_NASM_AS                  := nasm$(HOSTSUFF_EXE)
+endif
+TOOL_NASM_ASFLAGS             :=
+
+
+## Compile Assembly source.
+# @param    $(target)   Normalized main target name.
+# @param    $(source)   Source filename (relative).
+# @param    $(obj)      Object file name. This shall be (re)created by the compilation.
+# @param    $(dep)      Dependcy file. This shall be (re)created by the compilation.
+# @param    $(flags)    Flags.
+# @param    $(defs)     Definitions. No -D or something.
+# @param    $(incs)     Includes. No -I or something.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)     Other dependencies.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+# @param    $(objsuff)  Object suffix.
+define TOOL_NASM_COMPILE_AS
+#$ (warning dbg: TOOL_NASM_COMPILE_AS: target=$(target) source=$(source) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff) deps=$(deps))
+$(obj): $(source) $(deps) | $(dirdep)
+	$(call MSG_L2,Compiling $$@ using NASM)
+	$(TOOL_NASM_AS) \
+		$(flags) $(addsuffix /,$(addprefix -i, $(incs))) $(addprefix -D, $(defs))\
+		-l $(outbase).lst \
+		-o $(obj) \
+		$(call ABSPATH,$(source))
+_OUT_FILES += $(outbase).lst
+
+endef
+
+
Index: /tags/InnoTek-old-step/kBuild/tools/VCC70.kmk
===================================================================
--- /tags/InnoTek-old-step/kBuild/tools/VCC70.kmk	(revision 497)
+++ /tags/InnoTek-old-step/kBuild/tools/VCC70.kmk	(revision 497)
@@ -0,0 +1,268 @@
+# $Id$
+## @file
+#
+# kBuild Tool Config - Visual C++ 7.0 (aka Visual .NET)
+#
+# Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
+#
+#
+# This file is part of kBuild.
+#
+# kBuild is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# kBuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kBuild; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#
+
+
+TOOL_VCC70                    := Visual C++ 7.0
+PATH_TOOL_VCC70               ?= $(PATH_DEV)/x86.win32/vcc70
+PATH_TOOL_VCC70_LIB           ?= $(PATH_DEV)/x86.win32/vcc70/lib
+
+TOOL_VCC70_CC                 := $(EXEC_X86_WIN32) $(PATH_TOOL_VCC70)/bin/cl.exe
+TOOL_VCC70_COBJSUFF           := .obj
+TOOL_VCC70_CFLAGS             := -TC -c -nologo
+TOOL_VCC70_CFLAGS.debug       := -Od -Zi
+TOOL_VCC70_CFLAGS.release     := -O2
+TOOL_VCC70_CFLAGS.profile     := -O2
+TOOL_VCC70_CINCS              := $(PATH_TOOL_VCC70)/include
+TOOL_VCC70_CDEFS              :=
+
+TOOL_VCC70_CXX                := $(EXEC_X86_WIN32) $(PATH_TOOL_VCC70)/bin/cl.exe
+TOOL_VCC70_CXXOBJSUFF         := .obj
+TOOL_VCC70_CXXFLAGS           := -TP -c -nologo
+TOOL_VCC70_CXXFLAGS.debug     := -Od -Zi
+TOOL_VCC70_CXXFLAGS.release   := -O2
+TOOL_VCC70_CXXFLAGS.profile   := -O2
+TOOL_VCC70_CXXINCS            := $(PATH_TOOL_VCC70)/include
+TOOL_VCC70_CXXDEFS            :=
+
+TOOL_VCC70_AS                 := $(EXEC_X86_WIN32) $(PATH_TOOL_VCC70)/bin/ml.exe
+TOOL_VCC70_ASOBJSUFF          := .obj
+
+TOOL_VCC70_AR                 := $(EXEC_X86_WIN32) $(PATH_TOOL_VCC70)/bin/lib.exe
+TOOL_VCC70_ARFLAGS            := -nologo
+TOOL_VCC70_ARLIBSUFF          := .lib
+
+TOOL_VCC70_LD                 := $(EXEC_X86_WIN32) $(PATH_TOOL_VCC70)/bin/link.exe
+TOOL_VCC70_LDFLAGS            := -nologo
+TOOL_VCC70_LDFLAGS.debug      := -debug
+TOOL_VCC70_LDFLAGS.release    :=
+
+
+## Compile C source.
+# @param    $(target)   Normalized main target name.
+# @param    $(source)   Source filename (relative).
+# @param    $(obj)      Object file name. This shall be (re)created by the compilation.
+# @param    $(dep)      Dependcy file. This shall be (re)created by the compilation.
+# @param    $(flags)    Flags.
+# @param    $(defs)     Definitions. No -D or something.
+# @param    $(incs)     Includes. No -I or something.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)     Other dependencies.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+# @param    $(objsuff)  Object suffix.
+define TOOL_VCC70_COMPILE_C
+#$ (warning dbg: TOOL_VCC70_COMPILE_C: target=$(target) source=$(source) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff))
+$(obj): $(source) $(deps) | $(dirdep)
+	$(call MSG_L2,Compiling $$@ using VCC70)
+	$(TOOL_VCC70_CC) -c\
+		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
+		-Fd$(outbase).pdb \
+		-Fo$(obj)\
+		$(subst /,\\,$(call ABSPATH,$(source)))
+	$(DEP_CCXX) -q -f $(dep) -o $(obj) \
+		-D_M_IX86=500 -D_WIN32 -D_MSC_VER=1300 -D_MSC_EXTENSIONS=1 -D__COUNTER__=42 \
+		-D__DATE__=\"0000.00.00\" -D__FILE__=\"filename.c\" -D__LINE__=42 -D__TIME__=\"00.00.00\" -D__TIMESTAMP__=\"lotsofnumbers\" \
+		$(addprefix -D, $(defs)) $(addprefix -I, $(incs)) \
+		$(call ABSPATH,$(source))
+_OUT_FILES += $(outbase).pdb
+
+endef
+
+
+## Compile C++ source.
+# @param    $(target)   Normalized main target name.
+# @param    $(source)   Source filename (relative).
+# @param    $(obj)      Object file name. This shall be (re)created by the compilation.
+# @param    $(dep)      Dependcy file. This shall be (re)created by the compilation.
+# @param    $(flags)    Flags.
+# @param    $(defs)     Definitions. No -D or something.
+# @param    $(incs)     Includes. No -I or something.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)     Other dependencies.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+# @param    $(objsuff)  Object suffix.
+define TOOL_VCC70_COMPILE_CXX
+#$ (warning dbg: TOOL_VCC70_COMPILE_CXX: target=$(target) source=$(source) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff))
+$(obj): $(source) $(deps) | $(dirdep)
+	$(call MSG_L2,Compiling $$@ using VCC70)
+	$(TOOL_VCC70_CXX) -c\
+		$(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
+		-Fd$(outbase).pdb \
+		-Fo$(obj)\
+		$(subst /,\\,$(call ABSPATH,$(source)))
+	$(DEP_CCXX) -q -f $(dep) -o $(obj) \
+		-D__cplusplus \
+		-D_M_IX86=500 -D_WIN32 -D_MSC_VER=1300 -D_MSC_EXTENSIONS=1 -D__COUNTER__=42 \
+		-D__DATE__=\"0000.00.00\" -D__FILE__=\"filename.c\" -D__LINE__=42 -D__TIME__=\"00.00.00\" -D__TIMESTAMP__=\"lotsofnumbers\" \
+		$(addprefix -D, $(defs)) $(addprefix -I, $(incs)) \
+		$(call ABSPATH,$(source))
+_OUT_FILES += $(outbase).pdb
+
+endef
+
+
+## Link library
+# @param    $(target)   Normalized main target name.
+# @param    $(lib)		Library name.
+# @param    $(objs)     Object files to put in the library.
+# @param    $(flags)    Flags.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)		Other dependencies.
+# @param    $(othersrc) Unhandled sources.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+define TOOL_VCC70_LINK_LIBRARY
+#$ (warning dbg: TOOL_VCC70_LINK_LIBRARY: target=$(target) lib=$(lib) objs=$(objs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) outbase=$(outbase))
+$(lib): $(objs) $(deps) $(othersrc) | $(dirdep)
+	$(call MSG_L1,Creating Library $$@)
+	$(RM) -f $$@
+	$(TOOL_VCC70_AR) $(flags) /OUT:$(lib) $(subst /,\\,$(objs) $(filter %.a %.lib,$(othersrc))) \
+		$(foreach def,$(filter %.def,$(othersrc)), /DEF:$(def))
+_OUT_FILES += $(outbase).lst $(outbase).exp
+
+endef
+
+
+## Link program
+# @param    $(target)       Normalized main target name.
+# @param    $(exe)          Program name.
+# @param    $(objs)         Object files to link together.
+# @param    $(libs)         Libraries to search.
+# @param    $(libpath)      Library search paths.
+# @param    $(flags)        Flags.
+# @param    $(dirdep)       Directory creation dependency.
+# @param    $(deps)         Other dependencies.
+# @param    $(othersrc)     Unhandled sources.
+# @param    $(custom_pre)   Custom step invoked before linking.
+# @param    $(custom_post)  Custom step invoked after linking.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+define TOOL_VCC70_LINK_PROGRAM
+#$ (warning dbg: TOOL_VCC70_LINK_PROGRAM: target=$(target) exe=$(exe) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) othersrc=$(othersrc) outbase=$(outbase))
+$(exe): $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps) $(filter %.def,$(othersrc)) | $(dirdep)
+	$(call MSG_L1,Creating Program $$@)
+ifneq ($(custom_pre),)
+	$(eval $(custom_pre))
+endif
+	$(TOOL_VCC70_LD) $(flags) \
+		/OUT:$(exe) \
+		/MAPINFO:EXPORTS /MAPINFO:LINES \
+		/MAP:$(outbase).map \
+		$(foreach def,$(filter %.def,$(othersrc)), /DEF:$(def)) \
+		$(subst /,\\,$(filter %.exp %.res,$(othersrc))) \
+		$(foreach p,$(libpath), /LIBPATH:$(p)) \
+		$(subst /,\\,$(objs)) \
+		$(subst /,\\,$(libs))
+ifneq ($(custom_post),)
+	$(eval $(custom_post))
+endif
+_OUT_FILES += $(outbase).map $(outbase).lib $(outbase).exp $(outbase).pdb $(outbase).ilk
+
+endef
+
+
+## Link system module (windows aka driver, linux aka kernel module)
+# @param    $(target)       Normalized main target name.
+# @param    $(sys)          System module name.
+# @param    $(objs)         Object files to link together.
+# @param    $(libs)         Libraries to search.
+# @param    $(libpath)      Library search paths.
+# @param    $(flags)        Flags.
+# @param    $(dirdep)       Directory creation dependency.
+# @param    $(deps)         Other dependencies.
+# @param    $(othersrc)     Unhandled sources.
+# @param    $(custom_pre)   Custom step invoked before linking.
+# @param    $(custom_post)  Custom step invoked after linking.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+define TOOL_VCC70_LINK_SYSMOD
+#$ (warning dbg: TOOL_VCC70_LINK_SYSMOD: target=$(target) sys=$(sys) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) othersrc=$(othersrc) outbase=$(outbase))
+$(sys): $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps) $(filter %.def %.exp %.res,$(othersrc)) | $(dirdep)
+	$(call MSG_L1,Creating Program $$@)
+ifneq ($(custom_pre),)
+	$(eval $(custom_pre))
+endif
+	$(TOOL_VCC70_LD) $(flags) \
+		/OUT:$(sys) \
+		/MAPINFO:EXPORTS /MAPINFO:LINES \
+		/MAP:$(outbase).map \
+		$(foreach def,$(filter %.def,$(othersrc)), /DEF:$(def)) \
+		$(subst /,\\,$(filter %.exp %.res,$(othersrc))) \
+		$(foreach p,$(libpath), /LIBPATH:$(p)) \
+		$(subst /,\\,$(objs)) \
+		$(subst /,\\,$(libs))
+ifneq ($(custom_post),)
+	$(eval $(custom_post))
+endif
+_OUT_FILES += $(outbase).map $(outbase).lib $(outbase).exp $(outbase).pdb $(outbase).ilk
+
+endef
+
+
+## Link system module (windows aka driver, linux aka kernel module)
+# @param    $(target)   Normalized main target name.
+# @param    $(dll)		System module name.
+# @param    $(objs)     Object files to link together.
+# @param    $(libs)     Libraries to search.
+# @param    $(libpath)  Library search paths.
+# @param    $(flags)    Flags.
+# @param    $(dirdep)   Directory creation dependency.
+# @param    $(deps)		Other dependencies.
+# @param    $(othersrc) Unhandled sources.
+# @param    $(custom_pre)   Custom step invoked before linking.
+# @param    $(custom_post)  Custom step invoked after linking.
+#
+# @param    $(outbase)  Output basename (full). Use this for list files and such.
+define TOOL_VCC70_LINK_DLL
+#$ (warning dbg: TOOL_VCC70_LINK_DLL: target=$(target) dll=$(dll) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) othersrc=$(othersrc) outbase=$(outbase))
+$(dll): $(call DIRDEP,$(PATH_LIB)) $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps) $(filter %.def %.exp %.res,$(othersrc)) | $(dirdep)
+	$(call MSG_L1,Creating Program $$@)
+ifneq ($(custom_pre),)
+	$(eval $(custom_pre))
+endif
+	$(TOOL_VCC70_LD) $(flags) \
+		/OUT:$(dll) \
+		/IMPLIB:$(outbase).lib \
+		/MAPINFO:EXPORTS /MAPINFO:LINES \
+		/MAP:$(outbase).map \
+		/DLL \
+		$(foreach def,$(filter %.def,$(othersrc)), /DEF:$(def)) \
+		$(subst /,\\,$(filter %.exp %.res,$(othersrc))) \
+		$(foreach p,$(libpath), /LIBPATH:$(p)) \
+		$(subst /,\\,$(objs)) \
+		$(subst /,\\,$(libs))
+ifeq ($(filter %.exp .def,$(othersrc)),)
+	if test -f $(outbase).exp; then $(CP_EXT) $(outbase).exp $(PATH_LIB)/; fi
+	if test -f $(outbase).lib; then $(CP_EXT) $(outbase).lib $(PATH_LIB)/; fi
+endif
+ifneq ($(custom_post),)
+	$(eval $(custom_post))
+endif
+_OUT_FILES += $(outbase).map $(outbase).lib $(outbase).exp $(outbase).pdb $(outbase).ilk
+
+endef
+
Index: /tags/InnoTek-old-step/kBuild/up.kmk
===================================================================
--- /tags/InnoTek-old-step/kBuild/up.kmk	(revision 497)
+++ /tags/InnoTek-old-step/kBuild/up.kmk	(revision 497)
@@ -0,0 +1,60 @@
+# $Id$
+## @file
+#
+# kBuild - File included at top of a up forwarder makefile.
+#
+# Copyright (c) 2005 knut st. osmundsen <bird-srcspam@anduin.net>
+#
+#
+# This file is part of kBuild.
+#
+# kBuild is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version source of the License, or
+# (at your option) any later version.
+#
+# kBuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with kBuild; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite typetype0, Boston, MA  0sourcetargettargettarget-targettype07  USA
+#
+#
+
+# inlucde the header to get the right MAKE and to include config.kmk
+# files since these may contain global goals.
+include $(PATH_KBUILD)/header.kmk
+
+	
+# typical kbuild goals.		
+all_recursive \
+binaries \
+clean \
+dlls \
+libraries \
+needed \
+nothing \
+objects \
+others \
+packing \
+pass_binaries \
+pass_clean \
+pass_dlls \
+pass_needed \
+pass_nothing \
+pass_others \
+pass_packing \
+programs \
+rebuild \
+sysmods \
+target \
+	:
+	$(MAKE) -C .. $@
+
+# the syntax checkers.
+%.o %.obj:
+	$(MAKE) -C .. $@
+
