diff --git a/openwrt/include/host-build.mk b/openwrt/include/host-build.mk
new file mode 100644
index 0000000000000000000000000000000000000000..0d103e2a02b402a102c0aa962cdbe1f48fabb6b4
--- /dev/null
+++ b/openwrt/include/host-build.mk
@@ -0,0 +1,114 @@
+ifneq ($(strip $(PKG_CAT)),)
+  ifeq ($(PKG_CAT),unzip)
+    UNPACK=unzip -d $(PKG_BUILD_DIR) $(DL_DIR)/$(PKG_SOURCE)
+  else
+    UNPACK=$(PKG_CAT) $(DL_DIR)/$(PKG_SOURCE) | tar -C $(PKG_BUILD_DIR)/.. $(TAR_OPTIONS) -
+  endif
+  define Build/Prepare/Default
+  	$(UNPACK)
+	@if [ -d ./patches ]; then \
+		$(PATCH) $(PKG_BUILD_DIR) ./patches; \
+	fi
+  endef
+endif
+
+define Build/Prepare
+  $(call Build/Prepare/Default)
+endef
+
+define Build/Configure/Default
+	@(cd $(PKG_BUILD_DIR)/$(3); \
+	[ -x configure ] && \
+		$(2) \
+		CPPFLAGS="-I$(STAGING_DIR)/host/include" \
+		LDFLAGS="-L$(STAGING_DIR)/host/lib" \
+		./configure \
+		--target=$(GNU_TARGET_NAME) \
+		--host=$(GNU_TARGET_NAME) \
+		--build=$(GNU_HOST_NAME) \
+		--program-prefix="" \
+		--program-suffix="" \
+		--prefix=/usr \
+		--exec-prefix=/usr \
+		--bindir=/usr/bin \
+		--sbindir=/usr/sbin \
+		--libexecdir=/usr/lib \
+		--sysconfdir=/etc \
+		--datadir=/usr/share \
+		--localstatedir=/var \
+		--mandir=/usr/man \
+		--infodir=/usr/info \
+		$(DISABLE_NLS) \
+		$(1); \
+		true; \
+	)
+endef
+
+define Build/Configure
+  $(call Build/Configure/Default)
+endef
+
+define Build/Compile/Default
+	$(MAKE) -C $(PKG_BUILD_DIR) $(1)
+endef
+
+define Build/Compile
+  $(call Build/Compile/Default)
+endef
+
+		
+ifneq ($(strip $(PKG_SOURCE)),)
+  source: $(DL_DIR)/$(PKG_SOURCE)
+
+  $(DL_DIR)/$(PKG_SOURCE):
+	mkdir -p $(DL_DIR)
+	$(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL)
+
+  $(PKG_BUILD_DIR)/.prepared: $(DL_DIR)/$(PKG_SOURCE)
+endif
+
+define HostBuild
+  $(PKG_BUILD_DIR)/.prepared:
+	@-rm -rf $(PKG_BUILD_DIR)
+	@mkdir -p $(PKG_BUILD_DIR)
+	$(call Build/Prepare)
+	touch $$@
+
+  $(PKG_BUILD_DIR)/.configured: $(PKG_BUILD_DIR)/.prepared
+	$(call Build/Configure)
+	touch $$@
+
+  $(PKG_BUILD_DIR)/.built: $(PKG_BUILD_DIR)/.configured
+	$(call Build/Compile)
+	touch $$@
+
+  $(STAGING_DIR)/stampfiles/.host_$(PKG_NAME)-installed: $(PKG_BUILD_DIR)/.built
+	$(call Build/Install)
+	touch $$@
+	
+  ifdef Build/Install
+    install-targets: $(STAGING_DIR)/stampfiles/.host_$(PKG_NAME)-installed
+  endif
+
+  package-clean: FORCE
+	$(call Build/Clean)
+	$(call Build/Uninstall)
+	rm -f $(STAGING_DIR)/stampfiles/.host_$(PKG_NAME)-installed
+
+  source:
+  prepare: $(PKG_BUILD_DIR)/.prepared
+  configure: $(PKG_BUILD_DIR)/.configured
+
+  compile-targets: $(PKG_BUILD_DIR)/.built
+  compile: compile-targets
+
+  install-targets:
+  install: install-targets
+
+  clean-targets:
+  clean: FORCE
+	@$(MAKE) clean-targets
+	$(call Build/Clean)
+	rm -rf $(PKG_BUILD_DIR)
+
+endef
diff --git a/openwrt/include/package.mk b/openwrt/include/package.mk
index 82298b02498677b08c81a001b24f01f414e8d803..9b863074f91f232e1101119410849db505260a95 100644
--- a/openwrt/include/package.mk
+++ b/openwrt/include/package.mk
@@ -201,14 +201,15 @@ define BuildPackage
 endef
 
 ifneq ($(strip $(PKG_CAT)),)
+  ifeq ($(PKG_CAT),unzip)
+    UNPACK=unzip -d $(PKG_BUILD_DIR) $(DL_DIR)/$(PKG_SOURCE)
+  else
+    UNPACK=$(PKG_CAT) $(DL_DIR)/$(PKG_SOURCE) | tar -C $(PKG_BUILD_DIR)/.. $(TAR_OPTIONS) -
+  endif
   define Build/Prepare/Default
-	@if [ "$(PKG_CAT)" = "unzip" ]; then \
-		unzip -d $(PKG_BUILD_DIR) $(DL_DIR)/$(PKG_SOURCE) ; \
-	else \
-		$(PKG_CAT) $(DL_DIR)/$(PKG_SOURCE) | tar -C $(PKG_BUILD_DIR)/.. $(TAR_OPTIONS) - ; \
-	fi						  
+  	$(UNPACK)
 	@if [ -d ./patches ]; then \
-		$(PATCH) $(PKG_BUILD_DIR) ./patches ; \
+		$(PATCH) $(PKG_BUILD_DIR) ./patches; \
 	fi
   endef
 endif
diff --git a/openwrt/toolchain/Makefile b/openwrt/toolchain/Makefile
index f9fb3a54d6ef653119a9afa7d07fb2f092e55ff6..6481ed0d101e444333e2216baef871cefea4e261 100644
--- a/openwrt/toolchain/Makefile
+++ b/openwrt/toolchain/Makefile
@@ -1,6 +1,6 @@
 # Main makefile for the toolchain
 include $(TOPDIR)/rules.mk
-TARGETS-y:=sed kernel-headers utils binutils gcc uClibc ipkg-utils libnotimpl squashfs jffs2 lzma
+TARGETS-y:=sed kernel-headers sstrip binutils gcc uClibc ipkg-utils libnotimpl squashfs jffs2 lzma
 TARGETS-$(CONFIG_GDB) += gdb
 
 TARGETS_DOWNLOAD:=$(patsubst %,%-source,$(TARGETS-y))
@@ -12,12 +12,13 @@ download: $(TARGETS_DOWNLOAD)
 install: $(TARGETS_INSTALL)
 clean: $(TARGETS_CLEAN)
 
-uClibc-prepare: kernel-headers-prepare sed-install utils-install
+kernel-headers-prepare: sed-install
+uClibc-prepare: kernel-headers-prepare sstrip-install
 binutils-prepare: uClibc-prepare
 gcc-prepare: binutils-install
-uClibc-compile: gcc-prepare
-gcc-compile: uClibc-install
-squashfs-compile: lzma-compile
+uClibc-compile: gcc-compile
+gcc-install: uClibc-install
+squashfs-compile: lzma-install
 
 TOOLCHAIN_STAMP_DIR:=$(STAGING_DIR)/stampfiles
 
diff --git a/openwrt/toolchain/binutils/Makefile b/openwrt/toolchain/binutils/Makefile
index c161370e99aeb0d97e87e12287d915e3fa52c1a3..6d4f96f9143aa306b08c74ceff20f9c1226b4298 100644
--- a/openwrt/toolchain/binutils/Makefile
+++ b/openwrt/toolchain/binutils/Makefile
@@ -1,105 +1,59 @@
 include $(TOPDIR)/rules.mk
 
-#############################################################
-#
-# build binutils for use on the host system
-#
-#############################################################
-BINUTILS_VERSION:=$(strip $(subst ",, $(CONFIG_BINUTILS_VERSION)))#"))
+PKG_NAME:=binutils
+PKG_VERSION:=$(strip $(subst ",, $(CONFIG_BINUTILS_VERSION)))#"))
 
-BINUTILS_SITE:=http://www.fr.kernel.org/pub/linux/devel/binutils \
-	       http://www.fi.kernel.org/pub/linux/devel/binutils \
-	       http://ftp.kernel.org/pub/linux/devel/binutils \
-	       http://www.de.kernel.org/pub/linux/devel/binutils
-
-BINUTILS_STABLE_SITE:=http://ftp.gnu.org/gnu/binutils/ \
+STABLE_SITE:=http://ftp.gnu.org/gnu/binutils/ \
 	ftp://gatekeeper.dec.com/pub/GNU/ \
         ftp://ftp.uu.net/archive/systems/gnu/ \
         ftp://ftp.eu.uu.net/pub/gnu/ \
         ftp://ftp.funet.fi/pub/gnu/prep/ \
         ftp://ftp.leo.org/pub/comp/os/unix/gnu/ 
 
+DEVEL_SITE:=http://www.fr.kernel.org/pub/linux/devel/binutils \
+	       http://www.fi.kernel.org/pub/linux/devel/binutils \
+	       http://ftp.kernel.org/pub/linux/devel/binutils \
+	       http://www.de.kernel.org/pub/linux/devel/binutils
+
 ifeq ($(BINUTILS_VERSION),2.16.1)
-BINUTILS_SITE:=$(BINUTILS_STABLE_SITE)
+PKG_SOURCE_URL:=$(STABLE_SITE)
+else
+PKG_SOURCE_URL:=$(DEVEL_SITE)
 endif
 
-BINUTILS_SOURCE:=binutils-$(BINUTILS_VERSION).tar.bz2
-BINUTILS_DIR:=$(TOOL_BUILD_DIR)/binutils-$(BINUTILS_VERSION)
-BINUTILS_CAT:=bzcat
+PKG_SOURCE:=binutils-$(PKG_VERSION).tar.bz2
+PKG_MD5SUM:=unknown
+PKG_BUILD_DIR:=$(TOOL_BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_CAT:=bzcat
 
-BINUTILS_DIR1:=$(TOOL_BUILD_DIR)/binutils-$(BINUTILS_VERSION)-build
+include $(INCLUDE_DIR)/host-build.mk
 
-$(DL_DIR)/$(BINUTILS_SOURCE):
-	mkdir -p $(DL_DIR)
-	$(SCRIPT_DIR)/download.pl $(DL_DIR) $(BINUTILS_SOURCE) x $(BINUTILS_SITE)
 
-$(BINUTILS_DIR)/.unpacked: $(DL_DIR)/$(BINUTILS_SOURCE)
-	mkdir -p $(TOOL_BUILD_DIR)
-	$(BINUTILS_CAT) $(DL_DIR)/$(BINUTILS_SOURCE) | tar -C $(TOOL_BUILD_DIR) $(TAR_OPTIONS) -
-	touch $(BINUTILS_DIR)/.unpacked
+define Build/Prepare
+	$(call Build/Prepare/Default)
+	if [ -d ./patches/$(PKG_VERSION) ]; then \
+		$(SCRIPT_DIR)/patch-kernel.sh $(PKG_BUILD_DIR) ./patches/$(PKG_VERSION); \
+	fi
+endef
 
-$(BINUTILS_DIR)/.patched: $(BINUTILS_DIR)/.unpacked
-	# Apply appropriate binutils patches.
-	$(SCRIPT_DIR)/patch-kernel.sh $(BINUTILS_DIR) ./all \*.patch
-	$(SCRIPT_DIR)/patch-kernel.sh $(BINUTILS_DIR) ./$(BINUTILS_VERSION) \*.patch
-	touch $(BINUTILS_DIR)/.patched
-
-$(BINUTILS_DIR1)/.configured: $(BINUTILS_DIR)/.patched
-	mkdir -p $(BINUTILS_DIR1)
-	(cd $(BINUTILS_DIR1); \
-		$(BINUTILS_DIR)/configure \
+define Build/Configure
+	(cd $(PKG_BUILD_DIR); \
+		./configure \
 		--prefix=$(STAGING_DIR) \
 		--build=$(GNU_HOST_NAME) \
 		--host=$(GNU_HOST_NAME) \
 		--target=$(REAL_GNU_TARGET_NAME) \
 		--disable-werror \
-		$(DISABLE_NLS) \
-		$(MULTILIB) \
-		$(SOFT_FLOAT_CONFIG_OPTION) );
-	touch $(BINUTILS_DIR1)/.configured
-
-$(BINUTILS_DIR1)/binutils/objdump: $(BINUTILS_DIR1)/.configured
-	$(MAKE) -C $(BINUTILS_DIR1) -j $(CONFIG_JLEVEL) all
-
-# Make install will put gettext data in staging_dir/share/locale.
-# Unfortunatey, it isn't configureable.
-$(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-ld: $(BINUTILS_DIR1)/binutils/objdump
-	$(MAKE) -C $(BINUTILS_DIR1) -j $(CONFIG_JLEVEL) install
-
-
-#############################################################
-#
-# build binutils for use on the target system
-#
-#############################################################
-BINUTILS_DIR2:=$(BUILD_DIR)/binutils-$(BINUTILS_VERSION)-target
-$(BINUTILS_DIR2)/.configured: $(BINUTILS_DIR)/.patched
-	mkdir -p $(BINUTILS_DIR2)
-	(cd $(BINUTILS_DIR2); \
-		PATH=$(TARGET_PATH) \
-		CFLAGS="$(TARGET_CFLAGS)" \
-		CFLAGS_FOR_BUILD="-O2 -g" \
-		$(BINUTILS_DIR)/configure \
-		--prefix=/usr \
-		--exec-prefix=/usr \
-		--build=$(GNU_HOST_NAME) \
-		--host=$(REAL_GNU_TARGET_NAME) \
-		--target=$(REAL_GNU_TARGET_NAME) \
-		$(DISABLE_NLS) \
-		$(MULTILIB) \
-		$(SOFT_FLOAT_CONFIG_OPTION) );
-	touch $(BINUTILS_DIR2)/.configured
-
-$(BINUTILS_DIR2)/binutils/objdump: $(BINUTILS_DIR2)/.configured
-	PATH=$(TARGET_PATH) \
-	$(MAKE) -C $(BINUTILS_DIR2) -j $(CONFIG_JLEVEL) all
+		--disable-nls \
+	);
+endef
 
-source: $(DL_DIR)/$(BINUTILS_SOURCE)
-prepare: $(BINUTILS_DIR)/.patched
-compile: $(BINUTILS_DIR1)/binutils/objdump
-install: $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-ld
-clean: FORCE
-	rm -f $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)*
-	rm -rf $(BINUTILS_DIR) $(BINUTILS_DIR1)
+define Build/Compile
+	$(MAKE) -C $(PKG_BUILD_DIR) -j $(CONFIG_JLEVEL) all
+endef
 
+define Build/Install
+	$(MAKE) -C $(PKG_BUILD_DIR) -j $(CONFIG_JLEVEL) install
+endef
 
+$(eval $(call HostBuild))
diff --git a/openwrt/toolchain/binutils/2.15.94.0.2/100-uclibc-conf.patch b/openwrt/toolchain/binutils/patches/2.15.94.0.2/100-uclibc-conf.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.15.94.0.2/100-uclibc-conf.patch
rename to openwrt/toolchain/binutils/patches/2.15.94.0.2/100-uclibc-conf.patch
diff --git a/openwrt/toolchain/binutils/2.15.94.0.2/300-001_ld_makefile_patch.patch b/openwrt/toolchain/binutils/patches/2.15.94.0.2/300-001_ld_makefile_patch.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.15.94.0.2/300-001_ld_makefile_patch.patch
rename to openwrt/toolchain/binutils/patches/2.15.94.0.2/300-001_ld_makefile_patch.patch
diff --git a/openwrt/toolchain/binutils/2.15.94.0.2/300-006_better_file_error.patch b/openwrt/toolchain/binutils/patches/2.15.94.0.2/300-006_better_file_error.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.15.94.0.2/300-006_better_file_error.patch
rename to openwrt/toolchain/binutils/patches/2.15.94.0.2/300-006_better_file_error.patch
diff --git a/openwrt/toolchain/binutils/2.15.94.0.2/300-012_check_ldrunpath_length.patch b/openwrt/toolchain/binutils/patches/2.15.94.0.2/300-012_check_ldrunpath_length.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.15.94.0.2/300-012_check_ldrunpath_length.patch
rename to openwrt/toolchain/binutils/patches/2.15.94.0.2/300-012_check_ldrunpath_length.patch
diff --git a/openwrt/toolchain/binutils/2.15.94.0.2/300-120_mips_xgot_multigot_workaround.patch b/openwrt/toolchain/binutils/patches/2.15.94.0.2/300-120_mips_xgot_multigot_workaround.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.15.94.0.2/300-120_mips_xgot_multigot_workaround.patch
rename to openwrt/toolchain/binutils/patches/2.15.94.0.2/300-120_mips_xgot_multigot_workaround.patch
diff --git a/openwrt/toolchain/binutils/2.15.94.0.2/702-binutils-skip-comments.patch b/openwrt/toolchain/binutils/patches/2.15.94.0.2/702-binutils-skip-comments.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.15.94.0.2/702-binutils-skip-comments.patch
rename to openwrt/toolchain/binutils/patches/2.15.94.0.2/702-binutils-skip-comments.patch
diff --git a/openwrt/toolchain/binutils/2.16.1/100-uclibc-conf.patch b/openwrt/toolchain/binutils/patches/2.16.1/100-uclibc-conf.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.16.1/100-uclibc-conf.patch
rename to openwrt/toolchain/binutils/patches/2.16.1/100-uclibc-conf.patch
diff --git a/openwrt/toolchain/binutils/2.16.1/110-uclibc-libtool-conf.patch b/openwrt/toolchain/binutils/patches/2.16.1/110-uclibc-libtool-conf.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.16.1/110-uclibc-libtool-conf.patch
rename to openwrt/toolchain/binutils/patches/2.16.1/110-uclibc-libtool-conf.patch
diff --git a/openwrt/toolchain/binutils/2.16.1/300-001_ld_makefile_patch.patch b/openwrt/toolchain/binutils/patches/2.16.1/300-001_ld_makefile_patch.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.16.1/300-001_ld_makefile_patch.patch
rename to openwrt/toolchain/binutils/patches/2.16.1/300-001_ld_makefile_patch.patch
diff --git a/openwrt/toolchain/binutils/2.16.1/300-006_better_file_error.patch b/openwrt/toolchain/binutils/patches/2.16.1/300-006_better_file_error.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.16.1/300-006_better_file_error.patch
rename to openwrt/toolchain/binutils/patches/2.16.1/300-006_better_file_error.patch
diff --git a/openwrt/toolchain/binutils/2.16.1/300-012_check_ldrunpath_length.patch b/openwrt/toolchain/binutils/patches/2.16.1/300-012_check_ldrunpath_length.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.16.1/300-012_check_ldrunpath_length.patch
rename to openwrt/toolchain/binutils/patches/2.16.1/300-012_check_ldrunpath_length.patch
diff --git a/openwrt/toolchain/binutils/2.16.1/702-binutils-skip-comments.patch b/openwrt/toolchain/binutils/patches/2.16.1/702-binutils-skip-comments.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.16.1/702-binutils-skip-comments.patch
rename to openwrt/toolchain/binutils/patches/2.16.1/702-binutils-skip-comments.patch
diff --git a/openwrt/toolchain/binutils/2.16.90.0.3/100-uclibc-conf.patch b/openwrt/toolchain/binutils/patches/2.16.90.0.3/100-uclibc-conf.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.16.90.0.3/100-uclibc-conf.patch
rename to openwrt/toolchain/binutils/patches/2.16.90.0.3/100-uclibc-conf.patch
diff --git a/openwrt/toolchain/binutils/2.16.90.0.3/300-001_ld_makefile_patch.patch b/openwrt/toolchain/binutils/patches/2.16.90.0.3/300-001_ld_makefile_patch.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.16.90.0.3/300-001_ld_makefile_patch.patch
rename to openwrt/toolchain/binutils/patches/2.16.90.0.3/300-001_ld_makefile_patch.patch
diff --git a/openwrt/toolchain/binutils/2.16.90.0.3/300-006_better_file_error.patch b/openwrt/toolchain/binutils/patches/2.16.90.0.3/300-006_better_file_error.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.16.90.0.3/300-006_better_file_error.patch
rename to openwrt/toolchain/binutils/patches/2.16.90.0.3/300-006_better_file_error.patch
diff --git a/openwrt/toolchain/binutils/2.16.90.0.3/300-012_check_ldrunpath_length.patch b/openwrt/toolchain/binutils/patches/2.16.90.0.3/300-012_check_ldrunpath_length.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.16.90.0.3/300-012_check_ldrunpath_length.patch
rename to openwrt/toolchain/binutils/patches/2.16.90.0.3/300-012_check_ldrunpath_length.patch
diff --git a/openwrt/toolchain/binutils/2.16.90.0.3/702-binutils-skip-comments.patch b/openwrt/toolchain/binutils/patches/2.16.90.0.3/702-binutils-skip-comments.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.16.90.0.3/702-binutils-skip-comments.patch
rename to openwrt/toolchain/binutils/patches/2.16.90.0.3/702-binutils-skip-comments.patch
diff --git a/openwrt/toolchain/binutils/2.16.91.0.1/100-uclibc-conf.patch b/openwrt/toolchain/binutils/patches/2.16.91.0.1/100-uclibc-conf.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.16.91.0.1/100-uclibc-conf.patch
rename to openwrt/toolchain/binutils/patches/2.16.91.0.1/100-uclibc-conf.patch
diff --git a/openwrt/toolchain/binutils/2.16.91.0.1/300-001_ld_makefile_patch.patch b/openwrt/toolchain/binutils/patches/2.16.91.0.1/300-001_ld_makefile_patch.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.16.91.0.1/300-001_ld_makefile_patch.patch
rename to openwrt/toolchain/binutils/patches/2.16.91.0.1/300-001_ld_makefile_patch.patch
diff --git a/openwrt/toolchain/binutils/2.16.91.0.1/300-006_better_file_error.patch b/openwrt/toolchain/binutils/patches/2.16.91.0.1/300-006_better_file_error.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.16.91.0.1/300-006_better_file_error.patch
rename to openwrt/toolchain/binutils/patches/2.16.91.0.1/300-006_better_file_error.patch
diff --git a/openwrt/toolchain/binutils/2.16.91.0.1/300-012_check_ldrunpath_length.patch b/openwrt/toolchain/binutils/patches/2.16.91.0.1/300-012_check_ldrunpath_length.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.16.91.0.1/300-012_check_ldrunpath_length.patch
rename to openwrt/toolchain/binutils/patches/2.16.91.0.1/300-012_check_ldrunpath_length.patch
diff --git a/openwrt/toolchain/binutils/2.16.91.0.1/702-binutils-skip-comments.patch b/openwrt/toolchain/binutils/patches/2.16.91.0.1/702-binutils-skip-comments.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.16.91.0.1/702-binutils-skip-comments.patch
rename to openwrt/toolchain/binutils/patches/2.16.91.0.1/702-binutils-skip-comments.patch
diff --git a/openwrt/toolchain/binutils/2.16.91.0.2/100-uclibc-conf.patch b/openwrt/toolchain/binutils/patches/2.16.91.0.2/100-uclibc-conf.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.16.91.0.2/100-uclibc-conf.patch
rename to openwrt/toolchain/binutils/patches/2.16.91.0.2/100-uclibc-conf.patch
diff --git a/openwrt/toolchain/binutils/2.16.91.0.2/300-001_ld_makefile_patch.patch b/openwrt/toolchain/binutils/patches/2.16.91.0.2/300-001_ld_makefile_patch.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.16.91.0.2/300-001_ld_makefile_patch.patch
rename to openwrt/toolchain/binutils/patches/2.16.91.0.2/300-001_ld_makefile_patch.patch
diff --git a/openwrt/toolchain/binutils/2.16.91.0.2/300-006_better_file_error.patch b/openwrt/toolchain/binutils/patches/2.16.91.0.2/300-006_better_file_error.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.16.91.0.2/300-006_better_file_error.patch
rename to openwrt/toolchain/binutils/patches/2.16.91.0.2/300-006_better_file_error.patch
diff --git a/openwrt/toolchain/binutils/2.16.91.0.2/300-012_check_ldrunpath_length.patch b/openwrt/toolchain/binutils/patches/2.16.91.0.2/300-012_check_ldrunpath_length.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.16.91.0.2/300-012_check_ldrunpath_length.patch
rename to openwrt/toolchain/binutils/patches/2.16.91.0.2/300-012_check_ldrunpath_length.patch
diff --git a/openwrt/toolchain/binutils/2.16.91.0.2/702-binutils-skip-comments.patch b/openwrt/toolchain/binutils/patches/2.16.91.0.2/702-binutils-skip-comments.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.16.91.0.2/702-binutils-skip-comments.patch
rename to openwrt/toolchain/binutils/patches/2.16.91.0.2/702-binutils-skip-comments.patch
diff --git a/openwrt/toolchain/binutils/2.16.91.0.6/100-uclibc-conf.patch b/openwrt/toolchain/binutils/patches/2.16.91.0.6/100-uclibc-conf.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.16.91.0.6/100-uclibc-conf.patch
rename to openwrt/toolchain/binutils/patches/2.16.91.0.6/100-uclibc-conf.patch
diff --git a/openwrt/toolchain/binutils/2.16.91.0.6/300-001_ld_makefile_patch.patch b/openwrt/toolchain/binutils/patches/2.16.91.0.6/300-001_ld_makefile_patch.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.16.91.0.6/300-001_ld_makefile_patch.patch
rename to openwrt/toolchain/binutils/patches/2.16.91.0.6/300-001_ld_makefile_patch.patch
diff --git a/openwrt/toolchain/binutils/2.16.91.0.6/300-006_better_file_error.patch b/openwrt/toolchain/binutils/patches/2.16.91.0.6/300-006_better_file_error.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.16.91.0.6/300-006_better_file_error.patch
rename to openwrt/toolchain/binutils/patches/2.16.91.0.6/300-006_better_file_error.patch
diff --git a/openwrt/toolchain/binutils/2.16.91.0.6/300-012_check_ldrunpath_length.patch b/openwrt/toolchain/binutils/patches/2.16.91.0.6/300-012_check_ldrunpath_length.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.16.91.0.6/300-012_check_ldrunpath_length.patch
rename to openwrt/toolchain/binutils/patches/2.16.91.0.6/300-012_check_ldrunpath_length.patch
diff --git a/openwrt/toolchain/binutils/2.16.91.0.6/702-binutils-skip-comments.patch b/openwrt/toolchain/binutils/patches/2.16.91.0.6/702-binutils-skip-comments.patch
similarity index 100%
rename from openwrt/toolchain/binutils/2.16.91.0.6/702-binutils-skip-comments.patch
rename to openwrt/toolchain/binutils/patches/2.16.91.0.6/702-binutils-skip-comments.patch
diff --git a/openwrt/toolchain/binutils/all/400-mips-ELF_MAXPAGESIZE-4k.patch b/openwrt/toolchain/binutils/patches/400-mips-ELF_MAXPAGESIZE-4k.patch
similarity index 100%
rename from openwrt/toolchain/binutils/all/400-mips-ELF_MAXPAGESIZE-4k.patch
rename to openwrt/toolchain/binutils/patches/400-mips-ELF_MAXPAGESIZE-4k.patch
diff --git a/openwrt/toolchain/gcc/Makefile b/openwrt/toolchain/gcc/Makefile
index e76b60b0baced76afcdb954a8f901f7b25e829e6..a13ab2ebf76b72aef529b5024a0d809ce21330ee 100644
--- a/openwrt/toolchain/gcc/Makefile
+++ b/openwrt/toolchain/gcc/Makefile
@@ -2,7 +2,7 @@
 #
 # Copyright (C) 2002-2003 Erik Andersen <andersen@uclibc.org>
 # Copyright (C) 2004 Manuel Novoa III <mjn3@uclibc.org>
-# Copyright (C) 2005 Felix Fietkau <openwrt@nbd.name>
+# Copyright (C) 2005-2006 Felix Fietkau <nbd@openwrt.org>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -20,68 +20,36 @@
 
 include $(TOPDIR)/rules.mk
 
-GCC_VERSION:=$(strip $(subst ",, $(CONFIG_GCC_VERSION)))#"))
+PKG_NAME:=gcc
+PKG_VERSION:=$(strip $(subst ",, $(CONFIG_GCC_VERSION)))#"))
 
-#GCC_SITE:=ftp://ftp.gnu.org/gnu/gcc/releases/gcc-$(GCC_VERSION)
-GCC_SITE:=ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-$(GCC_VERSION) \
-	http://mirrors.rcn.net/pub/sourceware/gcc/releases/gcc-$(GCC_VERSION)
+PKG_SOURCE:=gcc-$(PKG_VERSION).tar.bz2
+PKG_MD5SUM:=unknown
+PKG_SOURCE_URL:=ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-$(PKG_VERSION) \
+	http://mirrors.rcn.net/pub/sourceware/gcc/releases/gcc-$(PKG_VERSION) \
+	ftp://ftp.gnu.org/gnu/gcc/releases/gcc-$(PKG_VERSION)
+PKG_CAT:=bzcat
 
-GCC_SOURCE:=gcc-$(GCC_VERSION).tar.bz2
-GCC_DIR:=$(TOOL_BUILD_DIR)/gcc-$(GCC_VERSION)
-GCC_CAT:=bzcat
+PKG_BUILD_DIR:=$(TOOL_BUILD_DIR)/gcc-$(PKG_VERSION)
 
-#############################################################
-#
-# Setup some initial stuff
-#
-#############################################################
-
-ifeq ($(CONFIG_INSTALL_LIBGCJ),y)
-TARGET_LANGUAGES:=c,c++,java
-else
-ifeq ($(CONFIG_INSTALL_LIBSTDCPP),y)
-TARGET_LANGUAGES:=c,c++
-else
 TARGET_LANGUAGES:=c
+ifeq ($(CONFIG_INSTALL_LIBSTDCPP),y)
+TARGET_LANGUAGES:=$(TARGET_LANGUAGES),c++
 endif
+ifeq ($(CONFIG_INSTALL_LIBGCJ),y)
+TARGET_LANGUAGES:=$(TARGET_LANGUAGES),java
 endif
 
-#############################################################
-#
-# build the first pass gcc compiler
-#
-#############################################################
-
-GCC_BUILD_DIR1:=$(TOOL_BUILD_DIR)/gcc-$(GCC_VERSION)-initial
-
-$(DL_DIR)/$(GCC_SOURCE):
-	mkdir -p $(DL_DIR)
-	$(SCRIPT_DIR)/download.pl $(DL_DIR) $(GCC_SOURCE) x $(GCC_SITE)
-
-$(GCC_DIR)/.unpacked: $(DL_DIR)/$(GCC_SOURCE)
-	mkdir -p $(TOOL_BUILD_DIR)
-	$(GCC_CAT) $(DL_DIR)/$(GCC_SOURCE) | tar -C $(TOOL_BUILD_DIR) $(TAR_OPTIONS) -
-	touch $(GCC_DIR)/.unpacked
-
-$(GCC_DIR)/.patched: $(GCC_DIR)/.unpacked
-	# Apply any files named gcc-*.patch from the source directory to gcc
-	$(SCRIPT_DIR)/patch-kernel.sh $(GCC_DIR) ./$(GCC_VERSION) \*.patch
-	# Note: The soft float situation has improved considerably with gcc 3.4.x.
-	# We can dispense with the custom spec files, as well as libfloat for the arm case.
-	# However, we still need a patch for arm.  There's a similar patch for gcc 3.3.x
-	# which needs to be integrated so we can kill of libfloat for good.
-	$(SED) 's,\(version_string.. = "[0-9\.]*\).*\(";\),\1 (OpenWrt-2.0)\2,' $(GCC_DIR)/gcc/version.c
-	$(SED) 's,\(bug_report_url.. = "\).*\(";\),\1<URL:https://dev.openwrt.org/>\2,' $(GCC_DIR)/gcc/version.c
-	touch $(GCC_DIR)/.patched
-
-# The --without-headers option stopped working with gcc 3.0 and has never been
-# # fixed, so we need to actually have working C library header files prior to
-# # the step or libgcc will not build...
-
-$(GCC_BUILD_DIR1)/.configured: $(GCC_DIR)/.patched
-	mkdir -p $(GCC_BUILD_DIR1)
-	(cd $(GCC_BUILD_DIR1); rm -f config.cache; PATH=$(TARGET_PATH) \
-		$(GCC_DIR)/configure \
+include $(INCLUDE_DIR)/host-build.mk
+
+BUILD_DIR1:=$(TOOL_BUILD_DIR)/gcc-$(PKG_VERSION)-initial
+BUILD_DIR2:=$(TOOL_BUILD_DIR)/gcc-$(PKG_VERSION)-final
+
+
+define Stage1/Configure
+	mkdir -p $(BUILD_DIR1)
+	(cd $(BUILD_DIR1); rm -f config.cache; PATH=$(TARGET_PATH) \
+		$(PKG_BUILD_DIR)/configure \
 		--prefix=$(STAGING_DIR) \
 		--build=$(GNU_HOST_NAME) \
 		--host=$(GNU_HOST_NAME) \
@@ -92,41 +60,25 @@ $(GCC_BUILD_DIR1)/.configured: $(GCC_DIR)/.patched
 		--disable-__cxa_atexit \
 		--enable-target-optspace \
 		--with-gnu-ld \
-		$(DISABLE_NLS) \
-		$(MULTILIB) \
+		--disable-nls \
 	);
-	touch $(GCC_BUILD_DIR1)/.configured
-
-$(GCC_BUILD_DIR1)/.compiled: $(GCC_BUILD_DIR1)/.configured
-	PATH=$(TARGET_PATH) $(MAKE) -C $(GCC_BUILD_DIR1) all-gcc
-	touch $(GCC_BUILD_DIR1)/.compiled
-
-$(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gcc: $(GCC_BUILD_DIR1)/.compiled
-	PATH=$(TARGET_PATH) $(MAKE) -C $(GCC_BUILD_DIR1) install-gcc
-
-#############################################################
-#
-# second pass compiler build.  Build the compiler targeting 
-# the newly built shared uClibc library.
-#
-#############################################################
-#
-# Sigh... I had to rework things because using --with-gxx-include-dir
-# causes issues with include dir search order for g++.  This seems to
-# have something to do with "path translations" and possibly doesn't
-# affect gcc-target.  However, I haven't tested gcc-target yet so no
-# guarantees.  mjn3
-
-GCC_BUILD_DIR2:=$(TOOL_BUILD_DIR)/gcc-$(GCC_VERSION)-final
-$(GCC_BUILD_DIR2)/.configured: $(GCC_DIR)/.patched $(STAGING_DIR)/lib/libc.a
-	mkdir -p $(GCC_BUILD_DIR2)
+endef
+define Stage1/Compile
+	PATH=$(TARGET_PATH) $(MAKE) -C $(BUILD_DIR1) all-gcc
+endef
+define Stage1/Install
+	PATH=$(TARGET_PATH) $(MAKE) -C $(BUILD_DIR1) install-gcc
+endef
+
+define Stage2/Configure
+	mkdir -p $(BUILD_DIR2)
 	# Important!  Required for limits.h to be fixed.
 	rm -rf $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
 	ln -sf ../include $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
 	rm -rf $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib
 	ln -sf ../lib $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib
-	(cd $(GCC_BUILD_DIR2); rm -f config.cache; PATH=$(TARGET_PATH) \
-		$(GCC_DIR)/configure \
+	(cd $(BUILD_DIR2); rm -f config.cache; PATH=$(TARGET_PATH) \
+		$(PKG_BUILD_DIR)/configure \
 		--prefix=$(STAGING_DIR) \
 		--build=$(GNU_HOST_NAME) \
 		--host=$(GNU_HOST_NAME) \
@@ -136,18 +88,15 @@ $(GCC_BUILD_DIR2)/.configured: $(GCC_DIR)/.patched $(STAGING_DIR)/lib/libc.a
 		--disable-__cxa_atexit \
 		--enable-target-optspace \
 		--with-gnu-ld \
-		$(DISABLE_NLS) \
-		$(MULTILIB) \
+		--disable-nls \
 	);
-	touch $(GCC_BUILD_DIR2)/.configured
-
-$(GCC_BUILD_DIR2)/.compiled: $(GCC_BUILD_DIR2)/.configured
-	PATH=$(TARGET_PATH) $(MAKE) -C $(GCC_BUILD_DIR2) all
-	touch $(GCC_BUILD_DIR2)/.compiled
-
-gcc-install: $(GCC_BUILD_DIR2)/.compiled FORCE
-	PATH=$(TARGET_PATH) $(MAKE) -C $(GCC_BUILD_DIR2) install
-	echo $(GCC_VERSION) > $(STAGING_DIR)/gcc_version
+endef
+define Stage2/Compile
+	PATH=$(TARGET_PATH) $(MAKE) -C $(BUILD_DIR2) all
+endef
+define Stage2/Install
+	PATH=$(TARGET_PATH) $(MAKE) -C $(BUILD_DIR2) install
+	echo $(PKG_VERSION) > $(STAGING_DIR)/gcc_version
 	# Set up the symlinks to enable lying about target name.
 	set -e; \
 	(cd $(STAGING_DIR); \
@@ -158,14 +107,36 @@ gcc-install: $(GCC_BUILD_DIR2)/.compiled FORCE
 		   	$(GNU_TARGET_NAME)$${app##$(REAL_GNU_TARGET_NAME)}; \
 		done; \
 	);
-
-source: $(DL_DIR)/$(GCC_SOURCE)
-prepare: $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gcc
-compile: gcc-install
-install:
-clean: gcc-clean
-	rm -rf $(GCC_DIR)
-	rm -rf $(GCC_BUILD_DIR1)
-	rm -rf $(GCC_BUILD_DIR2)
+endef
+
+define Build/Prepare
+	$(call Build/Prepare/Default)
+	$(SCRIPT_DIR)/patch-kernel.sh $(PKG_BUILD_DIR) ./patches/$(PKG_VERSION) \*.patch
+	$(SED) 's,\(version_string.. = "[0-9\.]*\).*\(";\),\1 (OpenWrt-2.0)\2,' $(PKG_BUILD_DIR)/gcc/version.c
+	$(SED) 's,\(bug_report_url.. = "\).*\(";\),\1<URL:https://dev.openwrt.org/>\2,' $(PKG_BUILD_DIR)/gcc/version.c
+endef
+
+define Build/Configure
+	$(call Stage1/Configure)
+endef
+
+define Build/Compile
+	$(call Stage1/Compile)
+	$(call Stage1/Install)
+endef
+
+define Build/Install
+	$(call Stage2/Configure)
+	$(call Stage2/Compile)
+	$(call Stage2/Install)
+endef
+
+define Build/Clean
+	rm -rf $(PKG_BUILD_DIR)
+	rm -rf $(BUILD_DIR1)
+	rm -rf $(BUILD_DIR2)
 	rm -f $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gc*
 	rm -f $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-c*
+endef
+
+$(eval $(call HostBuild))
diff --git a/openwrt/toolchain/gcc/3.4.4/100-uclibc-conf.patch b/openwrt/toolchain/gcc/patches/3.4.4/100-uclibc-conf.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.4/100-uclibc-conf.patch
rename to openwrt/toolchain/gcc/patches/3.4.4/100-uclibc-conf.patch
diff --git a/openwrt/toolchain/gcc/3.4.4/200-uclibc-locale.patch b/openwrt/toolchain/gcc/patches/3.4.4/200-uclibc-locale.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.4/200-uclibc-locale.patch
rename to openwrt/toolchain/gcc/patches/3.4.4/200-uclibc-locale.patch
diff --git a/openwrt/toolchain/gcc/3.4.4/300-libstdc++-pic.patch b/openwrt/toolchain/gcc/patches/3.4.4/300-libstdc++-pic.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.4/300-libstdc++-pic.patch
rename to openwrt/toolchain/gcc/patches/3.4.4/300-libstdc++-pic.patch
diff --git a/openwrt/toolchain/gcc/3.4.4/601-gcc34-arm-ldm.patch b/openwrt/toolchain/gcc/patches/3.4.4/601-gcc34-arm-ldm.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.4/601-gcc34-arm-ldm.patch
rename to openwrt/toolchain/gcc/patches/3.4.4/601-gcc34-arm-ldm.patch
diff --git a/openwrt/toolchain/gcc/3.4.4/602-sdk-libstdc++-includes.patch b/openwrt/toolchain/gcc/patches/3.4.4/602-sdk-libstdc++-includes.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.4/602-sdk-libstdc++-includes.patch
rename to openwrt/toolchain/gcc/patches/3.4.4/602-sdk-libstdc++-includes.patch
diff --git a/openwrt/toolchain/gcc/3.4.4/700-pr15068-fix.patch b/openwrt/toolchain/gcc/patches/3.4.4/700-pr15068-fix.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.4/700-pr15068-fix.patch
rename to openwrt/toolchain/gcc/patches/3.4.4/700-pr15068-fix.patch
diff --git a/openwrt/toolchain/gcc/3.4.4/800-arm-bigendian.patch b/openwrt/toolchain/gcc/patches/3.4.4/800-arm-bigendian.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.4/800-arm-bigendian.patch
rename to openwrt/toolchain/gcc/patches/3.4.4/800-arm-bigendian.patch
diff --git a/openwrt/toolchain/gcc/3.4.4/810-arm-bigendian-uclibc.patch b/openwrt/toolchain/gcc/patches/3.4.4/810-arm-bigendian-uclibc.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.4/810-arm-bigendian-uclibc.patch
rename to openwrt/toolchain/gcc/patches/3.4.4/810-arm-bigendian-uclibc.patch
diff --git a/openwrt/toolchain/gcc/3.4.4/830-gcc-bug-num-22167.patch b/openwrt/toolchain/gcc/patches/3.4.4/830-gcc-bug-num-22167.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.4/830-gcc-bug-num-22167.patch
rename to openwrt/toolchain/gcc/patches/3.4.4/830-gcc-bug-num-22167.patch
diff --git a/openwrt/toolchain/gcc/3.4.4/arm-softfloat.patch.conditional b/openwrt/toolchain/gcc/patches/3.4.4/arm-softfloat.patch.conditional
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.4/arm-softfloat.patch.conditional
rename to openwrt/toolchain/gcc/patches/3.4.4/arm-softfloat.patch.conditional
diff --git a/openwrt/toolchain/gcc/3.4.5/100-uclibc-conf.patch b/openwrt/toolchain/gcc/patches/3.4.5/100-uclibc-conf.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.5/100-uclibc-conf.patch
rename to openwrt/toolchain/gcc/patches/3.4.5/100-uclibc-conf.patch
diff --git a/openwrt/toolchain/gcc/3.4.5/200-uclibc-locale.patch b/openwrt/toolchain/gcc/patches/3.4.5/200-uclibc-locale.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.5/200-uclibc-locale.patch
rename to openwrt/toolchain/gcc/patches/3.4.5/200-uclibc-locale.patch
diff --git a/openwrt/toolchain/gcc/3.4.5/300-libstdc++-pic.patch b/openwrt/toolchain/gcc/patches/3.4.5/300-libstdc++-pic.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.5/300-libstdc++-pic.patch
rename to openwrt/toolchain/gcc/patches/3.4.5/300-libstdc++-pic.patch
diff --git a/openwrt/toolchain/gcc/3.4.5/600-gcc34-arm-ldm-peephole.patch b/openwrt/toolchain/gcc/patches/3.4.5/600-gcc34-arm-ldm-peephole.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.5/600-gcc34-arm-ldm-peephole.patch
rename to openwrt/toolchain/gcc/patches/3.4.5/600-gcc34-arm-ldm-peephole.patch
diff --git a/openwrt/toolchain/gcc/3.4.5/601-gcc34-arm-ldm-peephole2.patch b/openwrt/toolchain/gcc/patches/3.4.5/601-gcc34-arm-ldm-peephole2.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.5/601-gcc34-arm-ldm-peephole2.patch
rename to openwrt/toolchain/gcc/patches/3.4.5/601-gcc34-arm-ldm-peephole2.patch
diff --git a/openwrt/toolchain/gcc/3.4.5/601-gcc34-arm-ldm.patch b/openwrt/toolchain/gcc/patches/3.4.5/601-gcc34-arm-ldm.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.5/601-gcc34-arm-ldm.patch
rename to openwrt/toolchain/gcc/patches/3.4.5/601-gcc34-arm-ldm.patch
diff --git a/openwrt/toolchain/gcc/3.4.5/602-sdk-libstdc++-includes.patch b/openwrt/toolchain/gcc/patches/3.4.5/602-sdk-libstdc++-includes.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.5/602-sdk-libstdc++-includes.patch
rename to openwrt/toolchain/gcc/patches/3.4.5/602-sdk-libstdc++-includes.patch
diff --git a/openwrt/toolchain/gcc/3.4.5/700-pr15068-fix.patch b/openwrt/toolchain/gcc/patches/3.4.5/700-pr15068-fix.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.5/700-pr15068-fix.patch
rename to openwrt/toolchain/gcc/patches/3.4.5/700-pr15068-fix.patch
diff --git a/openwrt/toolchain/gcc/3.4.5/71_all_sh-pr16665-fix.patch b/openwrt/toolchain/gcc/patches/3.4.5/71_all_sh-pr16665-fix.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.5/71_all_sh-pr16665-fix.patch
rename to openwrt/toolchain/gcc/patches/3.4.5/71_all_sh-pr16665-fix.patch
diff --git a/openwrt/toolchain/gcc/3.4.5/72_all_sh-no-reorder-blocks.patch b/openwrt/toolchain/gcc/patches/3.4.5/72_all_sh-no-reorder-blocks.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.5/72_all_sh-no-reorder-blocks.patch
rename to openwrt/toolchain/gcc/patches/3.4.5/72_all_sh-no-reorder-blocks.patch
diff --git a/openwrt/toolchain/gcc/3.4.5/73_all_sh-pr20617.patch b/openwrt/toolchain/gcc/patches/3.4.5/73_all_sh-pr20617.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.5/73_all_sh-pr20617.patch
rename to openwrt/toolchain/gcc/patches/3.4.5/73_all_sh-pr20617.patch
diff --git a/openwrt/toolchain/gcc/3.4.5/800-arm-bigendian.patch b/openwrt/toolchain/gcc/patches/3.4.5/800-arm-bigendian.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.5/800-arm-bigendian.patch
rename to openwrt/toolchain/gcc/patches/3.4.5/800-arm-bigendian.patch
diff --git a/openwrt/toolchain/gcc/3.4.5/800-powerpc-libc_stack_end-uclibc.patch b/openwrt/toolchain/gcc/patches/3.4.5/800-powerpc-libc_stack_end-uclibc.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.5/800-powerpc-libc_stack_end-uclibc.patch
rename to openwrt/toolchain/gcc/patches/3.4.5/800-powerpc-libc_stack_end-uclibc.patch
diff --git a/openwrt/toolchain/gcc/3.4.6/100-uclibc-conf.patch b/openwrt/toolchain/gcc/patches/3.4.6/100-uclibc-conf.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.6/100-uclibc-conf.patch
rename to openwrt/toolchain/gcc/patches/3.4.6/100-uclibc-conf.patch
diff --git a/openwrt/toolchain/gcc/3.4.6/200-uclibc-locale.patch b/openwrt/toolchain/gcc/patches/3.4.6/200-uclibc-locale.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.6/200-uclibc-locale.patch
rename to openwrt/toolchain/gcc/patches/3.4.6/200-uclibc-locale.patch
diff --git a/openwrt/toolchain/gcc/3.4.6/300-libstdc++-pic.patch b/openwrt/toolchain/gcc/patches/3.4.6/300-libstdc++-pic.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.6/300-libstdc++-pic.patch
rename to openwrt/toolchain/gcc/patches/3.4.6/300-libstdc++-pic.patch
diff --git a/openwrt/toolchain/gcc/3.4.6/601-gcc34-arm-ldm.patch b/openwrt/toolchain/gcc/patches/3.4.6/601-gcc34-arm-ldm.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.6/601-gcc34-arm-ldm.patch
rename to openwrt/toolchain/gcc/patches/3.4.6/601-gcc34-arm-ldm.patch
diff --git a/openwrt/toolchain/gcc/3.4.6/602-sdk-libstdc++-includes.patch b/openwrt/toolchain/gcc/patches/3.4.6/602-sdk-libstdc++-includes.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.6/602-sdk-libstdc++-includes.patch
rename to openwrt/toolchain/gcc/patches/3.4.6/602-sdk-libstdc++-includes.patch
diff --git a/openwrt/toolchain/gcc/3.4.6/700-pr15068-fix.patch b/openwrt/toolchain/gcc/patches/3.4.6/700-pr15068-fix.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.6/700-pr15068-fix.patch
rename to openwrt/toolchain/gcc/patches/3.4.6/700-pr15068-fix.patch
diff --git a/openwrt/toolchain/gcc/3.4.6/800-arm-bigendian.patch b/openwrt/toolchain/gcc/patches/3.4.6/800-arm-bigendian.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.6/800-arm-bigendian.patch
rename to openwrt/toolchain/gcc/patches/3.4.6/800-arm-bigendian.patch
diff --git a/openwrt/toolchain/gcc/3.4.6/810-arm-bigendian-uclibc.patch b/openwrt/toolchain/gcc/patches/3.4.6/810-arm-bigendian-uclibc.patch
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.6/810-arm-bigendian-uclibc.patch
rename to openwrt/toolchain/gcc/patches/3.4.6/810-arm-bigendian-uclibc.patch
diff --git a/openwrt/toolchain/gcc/3.4.6/arm-softfloat.patch.conditional b/openwrt/toolchain/gcc/patches/3.4.6/arm-softfloat.patch.conditional
similarity index 100%
rename from openwrt/toolchain/gcc/3.4.6/arm-softfloat.patch.conditional
rename to openwrt/toolchain/gcc/patches/3.4.6/arm-softfloat.patch.conditional
diff --git a/openwrt/toolchain/gcc/4.0.2/100-uclibc-conf.patch b/openwrt/toolchain/gcc/patches/4.0.2/100-uclibc-conf.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.0.2/100-uclibc-conf.patch
rename to openwrt/toolchain/gcc/patches/4.0.2/100-uclibc-conf.patch
diff --git a/openwrt/toolchain/gcc/4.0.2/200-uclibc-locale.patch b/openwrt/toolchain/gcc/patches/4.0.2/200-uclibc-locale.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.0.2/200-uclibc-locale.patch
rename to openwrt/toolchain/gcc/patches/4.0.2/200-uclibc-locale.patch
diff --git a/openwrt/toolchain/gcc/4.0.3/100-uclibc-conf.patch b/openwrt/toolchain/gcc/patches/4.0.3/100-uclibc-conf.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.0.3/100-uclibc-conf.patch
rename to openwrt/toolchain/gcc/patches/4.0.3/100-uclibc-conf.patch
diff --git a/openwrt/toolchain/gcc/4.0.3/200-uclibc-locale.patch b/openwrt/toolchain/gcc/patches/4.0.3/200-uclibc-locale.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.0.3/200-uclibc-locale.patch
rename to openwrt/toolchain/gcc/patches/4.0.3/200-uclibc-locale.patch
diff --git a/openwrt/toolchain/gcc/4.0.3/300-libstdc++-pic.patch b/openwrt/toolchain/gcc/patches/4.0.3/300-libstdc++-pic.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.0.3/300-libstdc++-pic.patch
rename to openwrt/toolchain/gcc/patches/4.0.3/300-libstdc++-pic.patch
diff --git a/openwrt/toolchain/gcc/4.0.3/301-missing-execinfo_h.patch b/openwrt/toolchain/gcc/patches/4.0.3/301-missing-execinfo_h.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.0.3/301-missing-execinfo_h.patch
rename to openwrt/toolchain/gcc/patches/4.0.3/301-missing-execinfo_h.patch
diff --git a/openwrt/toolchain/gcc/4.0.3/302-c99-snprintf.patch b/openwrt/toolchain/gcc/patches/4.0.3/302-c99-snprintf.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.0.3/302-c99-snprintf.patch
rename to openwrt/toolchain/gcc/patches/4.0.3/302-c99-snprintf.patch
diff --git a/openwrt/toolchain/gcc/4.0.3/303-c99-complex-ugly-hack.patch b/openwrt/toolchain/gcc/patches/4.0.3/303-c99-complex-ugly-hack.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.0.3/303-c99-complex-ugly-hack.patch
rename to openwrt/toolchain/gcc/patches/4.0.3/303-c99-complex-ugly-hack.patch
diff --git a/openwrt/toolchain/gcc/4.0.3/602-sdk-libstdc++-includes.patch b/openwrt/toolchain/gcc/patches/4.0.3/602-sdk-libstdc++-includes.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.0.3/602-sdk-libstdc++-includes.patch
rename to openwrt/toolchain/gcc/patches/4.0.3/602-sdk-libstdc++-includes.patch
diff --git a/openwrt/toolchain/gcc/4.1.0/100-uclibc-conf.patch b/openwrt/toolchain/gcc/patches/4.1.0/100-uclibc-conf.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.1.0/100-uclibc-conf.patch
rename to openwrt/toolchain/gcc/patches/4.1.0/100-uclibc-conf.patch
diff --git a/openwrt/toolchain/gcc/4.1.0/110-arm-eabi.patch b/openwrt/toolchain/gcc/patches/4.1.0/110-arm-eabi.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.1.0/110-arm-eabi.patch
rename to openwrt/toolchain/gcc/patches/4.1.0/110-arm-eabi.patch
diff --git a/openwrt/toolchain/gcc/4.1.0/200-uclibc-locale.patch b/openwrt/toolchain/gcc/patches/4.1.0/200-uclibc-locale.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.1.0/200-uclibc-locale.patch
rename to openwrt/toolchain/gcc/patches/4.1.0/200-uclibc-locale.patch
diff --git a/openwrt/toolchain/gcc/4.1.0/300-libstdc++-pic.patch b/openwrt/toolchain/gcc/patches/4.1.0/300-libstdc++-pic.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.1.0/300-libstdc++-pic.patch
rename to openwrt/toolchain/gcc/patches/4.1.0/300-libstdc++-pic.patch
diff --git a/openwrt/toolchain/gcc/4.1.0/301-missing-execinfo_h.patch b/openwrt/toolchain/gcc/patches/4.1.0/301-missing-execinfo_h.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.1.0/301-missing-execinfo_h.patch
rename to openwrt/toolchain/gcc/patches/4.1.0/301-missing-execinfo_h.patch
diff --git a/openwrt/toolchain/gcc/4.1.0/302-c99-snprintf.patch b/openwrt/toolchain/gcc/patches/4.1.0/302-c99-snprintf.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.1.0/302-c99-snprintf.patch
rename to openwrt/toolchain/gcc/patches/4.1.0/302-c99-snprintf.patch
diff --git a/openwrt/toolchain/gcc/4.1.0/303-c99-complex-ugly-hack.patch b/openwrt/toolchain/gcc/patches/4.1.0/303-c99-complex-ugly-hack.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.1.0/303-c99-complex-ugly-hack.patch
rename to openwrt/toolchain/gcc/patches/4.1.0/303-c99-complex-ugly-hack.patch
diff --git a/openwrt/toolchain/gcc/4.1.0/602-sdk-libstdc++-includes.patch b/openwrt/toolchain/gcc/patches/4.1.0/602-sdk-libstdc++-includes.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.1.0/602-sdk-libstdc++-includes.patch
rename to openwrt/toolchain/gcc/patches/4.1.0/602-sdk-libstdc++-includes.patch
diff --git a/openwrt/toolchain/gcc/4.1.0/740-sh-pr24836.patch b/openwrt/toolchain/gcc/patches/4.1.0/740-sh-pr24836.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.1.0/740-sh-pr24836.patch
rename to openwrt/toolchain/gcc/patches/4.1.0/740-sh-pr24836.patch
diff --git a/openwrt/toolchain/gcc/4.1.0/800-arm-bigendian.patch b/openwrt/toolchain/gcc/patches/4.1.0/800-arm-bigendian.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.1.0/800-arm-bigendian.patch
rename to openwrt/toolchain/gcc/patches/4.1.0/800-arm-bigendian.patch
diff --git a/openwrt/toolchain/gcc/4.1.1/100-uclibc-conf.patch b/openwrt/toolchain/gcc/patches/4.1.1/100-uclibc-conf.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.1.1/100-uclibc-conf.patch
rename to openwrt/toolchain/gcc/patches/4.1.1/100-uclibc-conf.patch
diff --git a/openwrt/toolchain/gcc/4.1.1/110-arm-eabi.patch b/openwrt/toolchain/gcc/patches/4.1.1/110-arm-eabi.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.1.1/110-arm-eabi.patch
rename to openwrt/toolchain/gcc/patches/4.1.1/110-arm-eabi.patch
diff --git a/openwrt/toolchain/gcc/4.1.1/200-uclibc-locale.patch b/openwrt/toolchain/gcc/patches/4.1.1/200-uclibc-locale.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.1.1/200-uclibc-locale.patch
rename to openwrt/toolchain/gcc/patches/4.1.1/200-uclibc-locale.patch
diff --git a/openwrt/toolchain/gcc/4.1.1/300-libstdc++-pic.patch b/openwrt/toolchain/gcc/patches/4.1.1/300-libstdc++-pic.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.1.1/300-libstdc++-pic.patch
rename to openwrt/toolchain/gcc/patches/4.1.1/300-libstdc++-pic.patch
diff --git a/openwrt/toolchain/gcc/4.1.1/301-missing-execinfo_h.patch b/openwrt/toolchain/gcc/patches/4.1.1/301-missing-execinfo_h.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.1.1/301-missing-execinfo_h.patch
rename to openwrt/toolchain/gcc/patches/4.1.1/301-missing-execinfo_h.patch
diff --git a/openwrt/toolchain/gcc/4.1.1/302-c99-snprintf.patch b/openwrt/toolchain/gcc/patches/4.1.1/302-c99-snprintf.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.1.1/302-c99-snprintf.patch
rename to openwrt/toolchain/gcc/patches/4.1.1/302-c99-snprintf.patch
diff --git a/openwrt/toolchain/gcc/4.1.1/303-c99-complex-ugly-hack.patch b/openwrt/toolchain/gcc/patches/4.1.1/303-c99-complex-ugly-hack.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.1.1/303-c99-complex-ugly-hack.patch
rename to openwrt/toolchain/gcc/patches/4.1.1/303-c99-complex-ugly-hack.patch
diff --git a/openwrt/toolchain/gcc/4.1.1/304-index_macro.patch b/openwrt/toolchain/gcc/patches/4.1.1/304-index_macro.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.1.1/304-index_macro.patch
rename to openwrt/toolchain/gcc/patches/4.1.1/304-index_macro.patch
diff --git a/openwrt/toolchain/gcc/4.1.1/602-sdk-libstdc++-includes.patch b/openwrt/toolchain/gcc/patches/4.1.1/602-sdk-libstdc++-includes.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.1.1/602-sdk-libstdc++-includes.patch
rename to openwrt/toolchain/gcc/patches/4.1.1/602-sdk-libstdc++-includes.patch
diff --git a/openwrt/toolchain/gcc/4.1.1/740-sh-pr24836.patch b/openwrt/toolchain/gcc/patches/4.1.1/740-sh-pr24836.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.1.1/740-sh-pr24836.patch
rename to openwrt/toolchain/gcc/patches/4.1.1/740-sh-pr24836.patch
diff --git a/openwrt/toolchain/gcc/4.1.1/800-arm-bigendian.patch b/openwrt/toolchain/gcc/patches/4.1.1/800-arm-bigendian.patch
similarity index 100%
rename from openwrt/toolchain/gcc/4.1.1/800-arm-bigendian.patch
rename to openwrt/toolchain/gcc/patches/4.1.1/800-arm-bigendian.patch
diff --git a/openwrt/toolchain/gdb/Makefile b/openwrt/toolchain/gdb/Makefile
index f122881a741c6f416ba428aeddd5fe67083e5da3..538ef512072195705cc26d1bd644e4c58c4ad0ca 100644
--- a/openwrt/toolchain/gdb/Makefile
+++ b/openwrt/toolchain/gdb/Makefile
@@ -1,35 +1,21 @@
-# $Id$
-
 include $(TOPDIR)/rules.mk
 
-GDB_NAME:=gdb
-GDB_SITE:=http://ftp.gnu.org/gnu/gdb
-GDB_VERSION:=6.3
-GDB_SOURCE:=$(GDB_NAME)-$(GDB_VERSION).tar.bz2
-GDB_CAT:=bzcat
-
-GDB_DIR:=$(TOOL_BUILD_DIR)/$(GDB_NAME)-$(GDB_VERSION)
+PKG_NAME:=gdb
+PKG_VERSION:=6.3
 
-$(DL_DIR)/$(GDB_SOURCE):
-	$(WGET) -P $(DL_DIR) $(GDB_SITE)/$(GDB_SOURCE)
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_MD5SUM:=05b928f41fa5b482e49ca2c24762a0ae
+PKG_SOURCE_URL:=http://ftp.gnu.org/gnu/gdb
+PKG_CAT:=bzcat
 
-$(GDB_DIR)/.patched: $(DL_DIR)/$(GDB_SOURCE)
-	$(GDB_CAT) $(DL_DIR)/$(GDB_SOURCE) | tar -C $(TOOL_BUILD_DIR) $(TAR_OPTIONS) -
-	$(PATCH) $(GDB_DIR) ./patches
-	# Copy a config.sub from gcc.  This is only necessary until
-	# gdb's config.sub supports <arch>-linux-uclibc tuples.
-	# Should probably integrate this into the patch.
-	touch  $(GDB_DIR)/.patched
+PKG_BUILD_DIR:=$(TOOL_BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
 
-# gdb client
+include $(INCLUDE_DIR)/host-build.mk
 
-GDB_CLIENT_DIR:=$(TOOL_BUILD_DIR)/gdbclient-$(GDB_VERSION)
-
-$(GDB_CLIENT_DIR)/.configured: $(GDB_DIR)/.patched
-	mkdir -p $(GDB_CLIENT_DIR)
-	(cd $(GDB_CLIENT_DIR); \
+define Build/Configure
+	(cd $(PKG_BUILD_DIR); \
 		gdb_cv_func_sigsetjmp=yes \
-		$(GDB_DIR)/configure \
+		$(PKG_BUILD_DIR)/configure \
 		--prefix=$(STAGING_DIR) \
 		--build=$(GNU_HOST_NAME) \
 		--host=$(GNU_HOST_NAME) \
@@ -40,20 +26,17 @@ $(GDB_CLIENT_DIR)/.configured: $(GDB_DIR)/.patched
 		--without-included-gettext \
 		--enable-threads \
 	);
-	touch  $(GDB_CLIENT_DIR)/.configured
+endef
 
-$(GDB_CLIENT_DIR)/gdb/gdb: $(GDB_CLIENT_DIR)/.configured
-	$(MAKE) -C $(GDB_CLIENT_DIR)
-	strip $(GDB_CLIENT_DIR)/gdb/gdb
+define Build/Compile
+	$(MAKE) -C $(PKG_BUILD_DIR)
+	strip $(PKG_BUILD_DIR)/gdb/gdb
+endef
 
-$(TARGET_CROSS)gdb: $(GDB_CLIENT_DIR)/gdb/gdb
-	install -c $(GDB_CLIENT_DIR)/gdb/gdb $(TARGET_CROSS)gdb
+define Build/Install
+	install -c $(PKG_BUILD_DIR)/gdb/gdb $(TARGET_CROSS)gdb
 	cd $(STAGING_DIR)/bin && \
-	ln -fs $(TARGET_CROSS)gdb $(GNU_TARGET_NAME)-gdb
-
-source: $(DL_DIR)/$(GDB_SOURCE)
-prepare: $(GDB_DIR)/.patched
-compile: 
-install: $(TARGET_CROSS)gdb
-clean: FORCE
-	rm -rf $(GDB_CLIENT_DIR) $(GDB_DIR)
+		ln -fs $(TARGET_CROSS)gdb $(GNU_TARGET_NAME)-gdb
+endef
+
+$(eval $(call HostBuild))
diff --git a/openwrt/toolchain/ipkg-utils/Makefile b/openwrt/toolchain/ipkg-utils/Makefile
index 0183257b3d1ec7cae2cd912ed59bd572b846a9b1..5d324f728aa7a59dcebf8e6d251c25d8fd3c83c7 100644
--- a/openwrt/toolchain/ipkg-utils/Makefile
+++ b/openwrt/toolchain/ipkg-utils/Makefile
@@ -1,35 +1,18 @@
-# ipkg-utils
-#
-# http://handhelds.org/packages/ipkg-utils
-#
+include $(TOPDIR)/rules.mk
 
 PKG_NAME := ipkg-utils
 PKG_VERSION := 1.7
 
-PKG_SOURCE_SITE := http://handhelds.org/packages/ipkg-utils/
-PKG_SOURCE_FILE := $(PKG_NAME)-$(PKG_VERSION).tar.gz
-PKG_SOURCE_CAT := zcat
-PKG_SOURCE_DIR := $(PKG_NAME)-$(PKG_VERSION)
-
-include $(TOPDIR)/rules.mk
-
-PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_SOURCE_DIR)
+PKG_SOURCE := $(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_MD5SUM := da3e3ef772973d7370a6ac95f0fef9b8
+PKG_SOURCE_URL := http://handhelds.org/packages/ipkg-utils/
+PKG_CAT := zcat
 
+PKG_BUILD_DIR := $(TOOL_BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
 
-$(DL_DIR)/$(PKG_SOURCE_FILE):
-	mkdir -p $(DL_DIR)
-	$(SCRIPT_DIR)/download.pl $(DL_DIR) $(PKG_SOURCE_FILE) x $(PKG_SOURCE_SITE)
+include $(INCLUDE_DIR)/host-build.mk
 
-$(PKG_BUILD_DIR)/.unpacked: $(DL_DIR)/$(PKG_SOURCE_FILE)
-	mkdir -p $(BUILD_DIR)
-	$(PKG_SOURCE_CAT) $(DL_DIR)/$(PKG_SOURCE_FILE) | tar -C $(BUILD_DIR) $(TAR_OPTIONS) -
-	touch $(PKG_BUILD_DIR)/.unpacked
-
-$(PKG_BUILD_DIR)/.patched: $(PKG_BUILD_DIR)/.unpacked
-	$(PATCH) $(PKG_BUILD_DIR) $(PKG_VERSION)/ \*.patch
-	touch $(PKG_BUILD_DIR)/.patched
-
-$(STAGING_DIR)/usr/bin/ipkg-build: $(PKG_BUILD_DIR)/.patched
+define Build/Install
 	mkdir -p $(STAGING_DIR)/etc
 	echo "dest root /" > $(STAGING_DIR)/etc/ipkg.conf
 	echo "option offline_root $(TARGET_DIR)" >> $(STAGING_DIR)/etc/ipkg.conf
@@ -38,15 +21,12 @@ $(STAGING_DIR)/usr/bin/ipkg-build: $(PKG_BUILD_DIR)/.patched
 	install -m0755 $(PKG_BUILD_DIR)/ipkg-buildpackage $(STAGING_DIR)/usr/bin
 	install -m0755 $(PKG_BUILD_DIR)/ipkg-make-index $(STAGING_DIR)/usr/bin
 	install -m0755 $(PKG_BUILD_DIR)/ipkg.py $(STAGING_DIR)/usr/bin
+endef
 
-source: $(DL_DIR)/$(PKG_SOURCE_FILE)
-prepare: $(PKG_BUILD_DIR)/.patched
-compile:
-install: $(STAGING_DIR)/usr/bin/ipkg-build
-
-clean: FORCE
+define Build/Clean
 	rm -f $(STAGING_DIR)/etc/ipkg.conf
 	rm -f $(STAGING_DIR)/usr/bin/ipkg*
 	rm -rf $(PKG_BUILD_DIR)
+endef
 
-
+$(eval $(call HostBuild))
diff --git a/openwrt/toolchain/ipkg-utils/1.7/ipkg-utils-1.7-ipkg_build_clean.patch b/openwrt/toolchain/ipkg-utils/patches/100-build_clean.patch
similarity index 100%
rename from openwrt/toolchain/ipkg-utils/1.7/ipkg-utils-1.7-ipkg_build_clean.patch
rename to openwrt/toolchain/ipkg-utils/patches/100-build_clean.patch
diff --git a/openwrt/toolchain/ipkg-utils/1.7/ipkg-utils-1.7-ipkg_buildpackage.patch b/openwrt/toolchain/ipkg-utils/patches/110-buildpackage.patch
similarity index 100%
rename from openwrt/toolchain/ipkg-utils/1.7/ipkg-utils-1.7-ipkg_buildpackage.patch
rename to openwrt/toolchain/ipkg-utils/patches/110-buildpackage.patch
diff --git a/openwrt/toolchain/ipkg-utils/1.7/ipkg-utils-1.7-ipkg_build_tar.patch b/openwrt/toolchain/ipkg-utils/patches/120-build_tar.patch
similarity index 100%
rename from openwrt/toolchain/ipkg-utils/1.7/ipkg-utils-1.7-ipkg_build_tar.patch
rename to openwrt/toolchain/ipkg-utils/patches/120-build_tar.patch
diff --git a/openwrt/toolchain/jffs2/Makefile b/openwrt/toolchain/jffs2/Makefile
index b673c438a6cd768f1d5addde18ba83b42be12a3c..02364020a4af8df7f9944eca43ba3fb97c6d8199 100644
--- a/openwrt/toolchain/jffs2/Makefile
+++ b/openwrt/toolchain/jffs2/Makefile
@@ -1,29 +1,23 @@
 include $(TOPDIR)/rules.mk
 
-MTD_DIR:=$(BUILD_DIR)/mtd-20050122.orig
-MTD_SOURCE=mtd_20050122.orig.tar.gz
-MTD_SITE=http://ftp.debian.org/debian/pool/main/m/mtd
-MTD_MD5SUM:=1f42c2cae08eb9e7b52d0c188f8d6338
-MKFS_JFFS2=$(MTD_DIR)/util/mkfs.jffs2
+PKG_NAME:=mtd
+PKG_VERSION:=20050122
 
-$(DL_DIR)/$(MTD_SOURCE):
-	$(SCRIPT_DIR)/download.pl $(DL_DIR) $(MTD_SOURCE) $(MTD_MD5SUM) $(MTD_SITE)
+PKG_SOURCE=$(PKG_NAME)_$(PKG_VERSION).orig.tar.gz
+PKG_MD5SUM:=1f42c2cae08eb9e7b52d0c188f8d6338
+PKG_SOURCE_URL=http://ftp.debian.org/debian/pool/main/m/mtd
+PKG_CAT:=zcat
 
-$(MTD_DIR)/.unpacked: $(DL_DIR)/$(MTD_SOURCE)
-	zcat $(DL_DIR)/$(MTD_SOURCE) | tar -C $(BUILD_DIR) -xvf -
-	$(PATCH) $(MTD_DIR) ./patches
-	touch $(MTD_DIR)/.unpacked
+PKG_BUILD_DIR:=$(TOOL_BUILD_DIR)/mtd-20050122.orig
 
-$(MTD_DIR)/util/mkfs.jffs2: $(MTD_DIR)/.unpacked
-	$(MAKE) LINUXDIR=$(LINUX_DIR) -C $(MTD_DIR)/util
+include $(INCLUDE_DIR)/host-build.mk
 
-$(STAGING_DIR)/bin/mkfs.jffs2: $(MTD_DIR)/util/mkfs.jffs2
-	$(CP) $< $@
+define Build/Compile
+	$(MAKE) LINUXDIR=$(LINUX_HEADERS_DIR) -C $(PKG_BUILD_DIR)/util
+endef
 
-source: $(DL_DIR)/$(MTD_SOURCE)
-prepare: $(MTD_DIR)/.unpacked
-compile: $(MTD_DIR)/util/mkfs.jffs2 $(STAGING_DIR)/bin/mkfs.jffs2
-install: 
-clean: FORCE
-	rm -rf $(MTD_DIR) $(STAGING_DIR)/bin/mkfs.jffs2
+define Build/Install
+	$(CP) $(PKG_BUILD_DIR)/util/mkfs.jffs2 $(STAGING_DIR)/bin/
+endef
 
+$(eval $(call HostBuild))
diff --git a/openwrt/toolchain/kernel-headers/Makefile b/openwrt/toolchain/kernel-headers/Makefile
index 027c3e722c6eea3c2f0f49229888693aac6ba4a9..9d2f32e8633178ccafee2798dd86217c99665b14 100644
--- a/openwrt/toolchain/kernel-headers/Makefile
+++ b/openwrt/toolchain/kernel-headers/Makefile
@@ -1,52 +1,53 @@
 include $(TOPDIR)/rules.mk
 
-# linux kernel headers for toolchain
+PKG_NAME=kernel-headers
+PKG_VERSION=2.4.32
 
-LINUX_HEADERS_VERSION=2.4.32
-LINUX_KERNEL_MD5SUM:=38f4d0830e95a20f4bfed17622d5557c
-LINUX_HEADERS_SITE= \
+PKG_SOURCE=linux-$(PKG_VERSION).tar.bz2
+PKG_MD5SUM:=38f4d0830e95a20f4bfed17622d5557c
+PKG_SOURCE_URL= \
 		http://www.de.kernel.org/pub/linux/kernel/v2.4 \
 		http://www.fi.kernel.org/pub/linux/kernel/v2.4 \
 		http://www.fr.kernel.org/pub/linux/kernel/v2.4 \
-		http://www.kernel.org/pub/linux/kernel/v2.4 \
+		http://www.kernel.org/pub/linux/kernel/v2.4
 
-LINUX_HEADERS_SOURCE=linux-$(LINUX_HEADERS_VERSION).tar.bz2
-LINUX_HEADERS_ARCH:=$(shell echo $(ARCH) | sed -e 's/i[3-9]86/i386/' \
-	-e 's/mipseb/mips/' \
+PKG_BUILD_DIR:=$(TOOL_BUILD_DIR)/linux-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/host-build.mk
+
+LINUX_KARCH:=$(shell echo $(ARCH) | sed -e 's/i[3-9]86/i386/' \
 	-e 's/mipsel/mips/' \
+	-e 's/mipseb/mips/' \
 	-e 's/powerpc/ppc/' \
 	-e 's/sh[234]/sh/' \
-	)
-
-$(DL_DIR)/$(LINUX_HEADERS_SOURCE):
-	-mkdir -p $(DL_DIR)
-	$(SCRIPT_DIR)/download.pl $(DL_DIR) $(LINUX_HEADERS_SOURCE) $(LINUX_KERNEL_MD5SUM) $(LINUX_HEADERS_SITE)
+	-e 's/armeb/arm/' \
+)
 
-$(LINUX_HEADERS_DIR)/.unpacked: $(DL_DIR)/$(LINUX_HEADERS_SOURCE)
+define Build/Prepare
 	mkdir -p $(TOOL_BUILD_DIR)
-	bzcat $(DL_DIR)/$(LINUX_HEADERS_SOURCE) | tar -C $(TOOL_BUILD_DIR) $(TAR_OPTIONS) - \
-		linux-$(LINUX_HEADERS_VERSION)/include \
-		linux-$(LINUX_HEADERS_VERSION)/Makefile \
-		linux-$(LINUX_HEADERS_VERSION)/Rules.make \
-		linux-$(LINUX_HEADERS_VERSION)/arch/$(LINUX_HEADERS_ARCH)/Makefile \
-		linux-$(LINUX_HEADERS_VERSION)/scripts \
-		linux-$(LINUX_HEADERS_VERSION)/arch/$(LINUX_HEADERS_ARCH)/config*.in \
-		linux-$(LINUX_HEADERS_VERSION)/*/*/Config.in \
-		linux-$(LINUX_HEADERS_VERSION)/*/Config.in
-	(cd $(LINUX_HEADERS_DIR)-$(LINUX_HEADERS_VERSION) ; patch -p1 < $(TOPDIR)/toolchain/kernel-headers/patches/include.patch)
-	ln -sf $(LINUX_HEADERS_DIR)-$(LINUX_HEADERS_VERSION) $(LINUX_HEADERS_DIR)
-	$(SED) 's/@expr length/@-expr length/' $(LINUX_HEADERS_DIR)/Makefile 
-	touch $(LINUX_HEADERS_DIR)/.unpacked
-
-$(LINUX_HEADERS_DIR)/.configured: $(LINUX_HEADERS_DIR)/.unpacked
-	-$(CP) ./files/config.$(LINUX_HEADERS_ARCH) $(LINUX_HEADERS_DIR)/.config
-	$(MAKE) -C $(LINUX_HEADERS_DIR) ARCH=$(LINUX_HEADERS_ARCH) oldconfig include/linux/version.h
-	touch $(LINUX_HEADERS_DIR)/.configured
-
-source: $(DL_DIR)/$(LINUX_HEADERS_SOURCE)
-prepare: $(LINUX_HEADERS_DIR)/.configured
-compile:
-install:
-clean:
-	rm -rf $(LINUX_HEADERS_DIR)
-
+	bzcat $(DL_DIR)/$(PKG_SOURCE) | tar -C $(TOOL_BUILD_DIR) $(TAR_OPTIONS) - \
+		linux-$(PKG_VERSION)/include \
+		linux-$(PKG_VERSION)/Makefile \
+		linux-$(PKG_VERSION)/Rules.make \
+		linux-$(PKG_VERSION)/arch/$(LINUX_KARCH)/Makefile \
+		linux-$(PKG_VERSION)/scripts \
+		linux-$(PKG_VERSION)/arch/$(LINUX_KARCH)/config*.in \
+		linux-$(PKG_VERSION)/*/*/Config.in \
+		linux-$(PKG_VERSION)/*/Config.in
+	$(PATCH) $(PKG_BUILD_DIR) ./patches
+	$(SED) 's/@expr length/@-expr length/' $(PKG_BUILD_DIR)/Makefile 
+	ln -sf $(PKG_BUILD_DIR) $(LINUX_HEADERS_DIR)
+endef
+
+define Build/Configure
+	-$(CP) ./files/config.$(LINUX_KARCH) $(PKG_BUILD_DIR)/.config
+	$(MAKE) -C $(PKG_BUILD_DIR) ARCH=$(LINUX_KARCH) oldconfig include/linux/version.h
+endef
+
+define Build/Compile
+endef
+
+define Build/Install
+endef
+
+$(eval $(call HostBuild))
diff --git a/openwrt/toolchain/kernel-headers/config.mips b/openwrt/toolchain/kernel-headers/config.mips
deleted file mode 100644
index d6412028b4d7d2460b4ca28d5dc3d0d305f07515..0000000000000000000000000000000000000000
--- a/openwrt/toolchain/kernel-headers/config.mips
+++ /dev/null
@@ -1,1045 +0,0 @@
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_MIPS=y
-CONFIG_MIPS32=y
-# CONFIG_MIPS64 is not set
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-# CONFIG_MODVERSIONS is not set
-# CONFIG_KMOD is not set
-
-#
-# Machine selection
-#
-# CONFIG_ACER_PICA_61 is not set
-# CONFIG_MIPS_BOSPORUS is not set
-# CONFIG_MIPS_MIRAGE is not set
-# CONFIG_MIPS_DB1000 is not set
-# CONFIG_MIPS_DB1100 is not set
-# CONFIG_MIPS_DB1500 is not set
-# CONFIG_MIPS_DB1550 is not set
-# CONFIG_MIPS_PB1000 is not set
-# CONFIG_MIPS_PB1100 is not set
-# CONFIG_MIPS_PB1500 is not set
-# CONFIG_MIPS_HYDROGEN3 is not set
-# CONFIG_MIPS_PB1550 is not set
-# CONFIG_MIPS_XXS1500 is not set
-# CONFIG_MIPS_MTX1 is not set
-# CONFIG_COGENT_CSB250 is not set
-# CONFIG_BAGET_MIPS is not set
-# CONFIG_CASIO_E55 is not set
-# CONFIG_MIPS_COBALT is not set
-# CONFIG_DECSTATION is not set
-# CONFIG_MIPS_EV64120 is not set
-# CONFIG_MIPS_EV96100 is not set
-# CONFIG_MIPS_IVR is not set
-# CONFIG_HP_LASERJET is not set
-# CONFIG_IBM_WORKPAD is not set
-# CONFIG_LASAT is not set
-# CONFIG_MIPS_ITE8172 is not set
-# CONFIG_MIPS_ATLAS is not set
-# CONFIG_MIPS_MAGNUM_4000 is not set
-# CONFIG_MIPS_MALTA is not set
-# CONFIG_MIPS_SEAD is not set
-# CONFIG_MOMENCO_OCELOT is not set
-# CONFIG_MOMENCO_OCELOT_G is not set
-# CONFIG_MOMENCO_OCELOT_C is not set
-# CONFIG_MOMENCO_JAGUAR_ATX is not set
-# CONFIG_PMC_BIG_SUR is not set
-# CONFIG_PMC_STRETCH is not set
-# CONFIG_PMC_YOSEMITE is not set
-# CONFIG_DDB5074 is not set
-# CONFIG_DDB5476 is not set
-# CONFIG_DDB5477 is not set
-# CONFIG_NEC_OSPREY is not set
-# CONFIG_NEC_EAGLE is not set
-# CONFIG_OLIVETTI_M700 is not set
-# CONFIG_NINO is not set
-# CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP27 is not set
-# CONFIG_SIBYTE_SB1xxx_SOC is not set
-# CONFIG_SNI_RM200_PCI is not set
-# CONFIG_TANBAC_TB0226 is not set
-# CONFIG_TANBAC_TB0229 is not set
-# CONFIG_TOSHIBA_JMR3927 is not set
-# CONFIG_TOSHIBA_RBTX4927 is not set
-# CONFIG_VICTOR_MPC30X is not set
-# CONFIG_ZAO_CAPCELLA is not set
-# CONFIG_HIGHMEM is not set
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
-# CONFIG_MIPS_AU1000 is not set
-
-#
-# CPU selection
-#
-CONFIG_CPU_MIPS32=y
-# CONFIG_CPU_MIPS64 is not set
-# CONFIG_CPU_R3000 is not set
-# CONFIG_CPU_TX39XX is not set
-# CONFIG_CPU_VR41XX is not set
-# CONFIG_CPU_R4300 is not set
-# CONFIG_CPU_R4X00 is not set
-# CONFIG_CPU_TX49XX is not set
-# CONFIG_CPU_R5000 is not set
-# CONFIG_CPU_R5432 is not set
-# CONFIG_CPU_R6000 is not set
-# CONFIG_CPU_NEVADA is not set
-# CONFIG_CPU_R8000 is not set
-# CONFIG_CPU_R10000 is not set
-# CONFIG_CPU_RM7000 is not set
-# CONFIG_CPU_RM9000 is not set
-# CONFIG_CPU_SB1 is not set
-CONFIG_PAGE_SIZE_4KB=y
-# CONFIG_PAGE_SIZE_16KB is not set
-# CONFIG_PAGE_SIZE_64KB is not set
-CONFIG_CPU_HAS_PREFETCH=y
-# CONFIG_VTAG_ICACHE is not set
-# CONFIG_64BIT_PHYS_ADDR is not set
-# CONFIG_CPU_ADVANCED is not set
-CONFIG_CPU_HAS_LLSC=y
-# CONFIG_CPU_HAS_LLDSCD is not set
-# CONFIG_CPU_HAS_WB is not set
-CONFIG_CPU_HAS_SYNC=y
-
-#
-# General setup
-#
-CONFIG_CPU_LITTLE_ENDIAN=y
-# CONFIG_BUILD_ELF64 is not set
-CONFIG_NET=y
-CONFIG_PCI=y
-# CONFIG_PCI_NEW is not set
-CONFIG_PCI_AUTO=y
-# CONFIG_PCI_NAMES is not set
-# CONFIG_ISA is not set
-# CONFIG_TC is not set
-# CONFIG_MCA is not set
-# CONFIG_SBUS is not set
-# CONFIG_HOTPLUG is not set
-# CONFIG_PCMCIA is not set
-# CONFIG_HOTPLUG_PCI is not set
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-CONFIG_KCORE_ELF=y
-# CONFIG_KCORE_AOUT is not set
-# CONFIG_BINFMT_AOUT is not set
-CONFIG_BINFMT_ELF=y
-# CONFIG_MIPS32_COMPAT is not set
-# CONFIG_MIPS32_O32 is not set
-# CONFIG_MIPS32_N32 is not set
-# CONFIG_BINFMT_ELF32 is not set
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_OOM_KILLER is not set
-# CONFIG_CMDLINE_BOOL is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DEBUG is not set
-CONFIG_MTD_PARTITIONS=y
-# CONFIG_MTD_CONCAT is not set
-# CONFIG_MTD_REDBOOT_PARTS is not set
-# CONFIG_MTD_CMDLINE_PARTS is not set
-
-#
-# User Modules And Translation Layers
-#
-CONFIG_MTD_CHAR=y
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-
-#
-# RAM/ROM/Flash chip drivers
-#
-CONFIG_MTD_CFI=y
-# CONFIG_MTD_JEDECPROBE is not set
-CONFIG_MTD_GEN_PROBE=y
-CONFIG_MTD_CFI_ADV_OPTIONS=y
-CONFIG_MTD_CFI_NOSWAP=y
-# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set
-# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
-CONFIG_MTD_CFI_GEOMETRY=y
-# CONFIG_MTD_CFI_B1 is not set
-CONFIG_MTD_CFI_B2=y
-# CONFIG_MTD_CFI_B4 is not set
-# CONFIG_MTD_CFI_B8 is not set
-CONFIG_MTD_CFI_I1=y
-# CONFIG_MTD_CFI_I2 is not set
-# CONFIG_MTD_CFI_I4 is not set
-# CONFIG_MTD_CFI_I8 is not set
-CONFIG_MTD_CFI_INTELEXT=y
-CONFIG_MTD_CFI_AMDSTD=y
-# CONFIG_MTD_CFI_STAA is not set
-# CONFIG_MTD_RAM is not set
-# CONFIG_MTD_ROM is not set
-# CONFIG_MTD_ABSENT is not set
-# CONFIG_MTD_OBSOLETE_CHIPS is not set
-# CONFIG_MTD_AMDSTD is not set
-# CONFIG_MTD_SHARP is not set
-# CONFIG_MTD_JEDEC is not set
-
-#
-# Mapping drivers for chip access
-#
-# CONFIG_MTD_PHYSMAP is not set
-# CONFIG_MTD_PB1000 is not set
-# CONFIG_MTD_PB1500 is not set
-# CONFIG_MTD_PB1100 is not set
-# CONFIG_MTD_CSTM_MIPS_IXX is not set
-# CONFIG_MTD_OCELOT is not set
-# CONFIG_MTD_LASAT is not set
-# CONFIG_MTD_PCI is not set
-# CONFIG_MTD_PCMCIA is not set
-
-#
-# Self-contained MTD device drivers
-#
-# CONFIG_MTD_PMC551 is not set
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_MTDRAM is not set
-# CONFIG_MTD_BLKMTD is not set
-
-#
-# Disk-On-Chip Device Drivers
-#
-# CONFIG_MTD_DOC1000 is not set
-# CONFIG_MTD_DOC2000 is not set
-# CONFIG_MTD_DOC2001 is not set
-# CONFIG_MTD_DOCPROBE is not set
-
-#
-# NAND Flash Device Drivers
-#
-# CONFIG_MTD_NAND is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Plug and Play configuration
-#
-# CONFIG_PNP is not set
-# CONFIG_ISAPNP is not set
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-# CONFIG_BLK_DEV_XD is not set
-# CONFIG_PARIDE is not set
-# CONFIG_BLK_CPQ_DA is not set
-# CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_CISS_SCSI_TAPE is not set
-# CONFIG_CISS_MONITOR_THREAD is not set
-# CONFIG_BLK_DEV_DAC960 is not set
-# CONFIG_BLK_DEV_UMEM is not set
-# CONFIG_BLK_DEV_SX8 is not set
-CONFIG_BLK_DEV_LOOP=y
-CONFIG_BLK_DEV_NBD=m
-# CONFIG_BLK_DEV_RAM is not set
-# CONFIG_BLK_DEV_INITRD is not set
-# CONFIG_BLK_STATS is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-# CONFIG_BLK_DEV_MD is not set
-# CONFIG_MD_LINEAR is not set
-# CONFIG_MD_RAID0 is not set
-# CONFIG_MD_RAID1 is not set
-# CONFIG_MD_RAID5 is not set
-# CONFIG_MD_MULTIPATH is not set
-# CONFIG_BLK_DEV_LVM is not set
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-CONFIG_PACKET_MMAP=y
-CONFIG_NETLINK_DEV=m
-CONFIG_NETFILTER=y
-# CONFIG_NETFILTER_DEBUG is not set
-# CONFIG_FILTER is not set
-CONFIG_UNIX=y
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-CONFIG_IP_ADVANCED_ROUTER=y
-CONFIG_IP_MULTIPLE_TABLES=y
-CONFIG_IP_ROUTE_FWMARK=y
-CONFIG_IP_ROUTE_NAT=y
-CONFIG_IP_ROUTE_MULTIPATH=y
-CONFIG_IP_ROUTE_TOS=y
-# CONFIG_IP_ROUTE_VERBOSE is not set
-# CONFIG_IP_PNP is not set
-CONFIG_NET_IPIP=m
-CONFIG_NET_IPGRE=m
-# CONFIG_ARPD is not set
-# CONFIG_INET_ECN is not set
-# CONFIG_SYN_COOKIES is not set
-
-#
-#   IP: Netfilter Configuration
-#
-CONFIG_IP_NF_CONNTRACK=y
-CONFIG_IP_NF_FTP=y
-# CONFIG_IP_NF_AMANDA is not set
-CONFIG_IP_NF_TFTP=y
-CONFIG_IP_NF_IRC=y
-CONFIG_IP_NF_QUEUE=m
-CONFIG_IP_NF_IPTABLES=y
-CONFIG_IP_NF_MATCH_LIMIT=m
-CONFIG_IP_NF_MATCH_MAC=m
-CONFIG_IP_NF_MATCH_PKTTYPE=m
-CONFIG_IP_NF_MATCH_MARK=y
-CONFIG_IP_NF_MATCH_MULTIPORT=y
-CONFIG_IP_NF_MATCH_TOS=m
-# CONFIG_IP_NF_MATCH_RECENT is not set
-CONFIG_IP_NF_MATCH_ECN=m
-CONFIG_IP_NF_MATCH_DSCP=m
-CONFIG_IP_NF_MATCH_AH_ESP=m
-CONFIG_IP_NF_MATCH_LENGTH=m
-CONFIG_IP_NF_MATCH_TTL=m
-CONFIG_IP_NF_MATCH_TCPMSS=y
-CONFIG_IP_NF_MATCH_HELPER=m
-CONFIG_IP_NF_MATCH_STATE=y
-CONFIG_IP_NF_MATCH_CONNTRACK=m
-CONFIG_IP_NF_MATCH_UNCLEAN=m
-# CONFIG_IP_NF_MATCH_OWNER is not set
-CONFIG_IP_NF_FILTER=y
-CONFIG_IP_NF_TARGET_REJECT=y
-CONFIG_IP_NF_TARGET_MIRROR=m
-CONFIG_IP_NF_NAT=y
-CONFIG_IP_NF_NAT_NEEDED=y
-CONFIG_IP_NF_TARGET_MASQUERADE=y
-CONFIG_IP_NF_TARGET_REDIRECT=y
-CONFIG_IP_NF_NAT_SNMP_BASIC=m
-CONFIG_IP_NF_NAT_IRC=y
-CONFIG_IP_NF_NAT_FTP=y
-CONFIG_IP_NF_NAT_TFTP=y
-CONFIG_IP_NF_MANGLE=y
-CONFIG_IP_NF_TARGET_TOS=m
-CONFIG_IP_NF_TARGET_ECN=m
-CONFIG_IP_NF_TARGET_DSCP=m
-CONFIG_IP_NF_TARGET_MARK=y
-CONFIG_IP_NF_TARGET_LOG=y
-CONFIG_IP_NF_TARGET_ULOG=m
-CONFIG_IP_NF_TARGET_TCPMSS=y
-CONFIG_IP_NF_ARPTABLES=m
-CONFIG_IP_NF_ARPFILTER=m
-# CONFIG_IP_NF_ARP_MANGLE is not set
-
-#
-#   IP: Virtual Server Configuration
-#
-# CONFIG_IP_VS is not set
-CONFIG_IPV6=m
-
-#
-#   IPv6: Netfilter Configuration
-#
-CONFIG_IP6_NF_QUEUE=m
-CONFIG_IP6_NF_IPTABLES=m
-CONFIG_IP6_NF_MATCH_LIMIT=m
-CONFIG_IP6_NF_MATCH_MAC=m
-# CONFIG_IP6_NF_MATCH_RT is not set
-# CONFIG_IP6_NF_MATCH_OPTS is not set
-# CONFIG_IP6_NF_MATCH_FRAG is not set
-# CONFIG_IP6_NF_MATCH_HL is not set
-CONFIG_IP6_NF_MATCH_MULTIPORT=m
-CONFIG_IP6_NF_MATCH_OWNER=m
-CONFIG_IP6_NF_MATCH_MARK=m
-# CONFIG_IP6_NF_MATCH_IPV6HEADER is not set
-# CONFIG_IP6_NF_MATCH_AHESP is not set
-CONFIG_IP6_NF_MATCH_LENGTH=m
-CONFIG_IP6_NF_MATCH_EUI64=m
-CONFIG_IP6_NF_FILTER=m
-CONFIG_IP6_NF_TARGET_LOG=m
-CONFIG_IP6_NF_MANGLE=m
-CONFIG_IP6_NF_TARGET_MARK=m
-# CONFIG_KHTTPD is not set
-
-#
-#    SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-CONFIG_VLAN_8021Q=y
-
-#
-#  
-#
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_DECNET is not set
-CONFIG_BRIDGE=y
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_LLC is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_FASTROUTE is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-CONFIG_NET_SCHED=y
-CONFIG_NET_SCH_CBQ=m
-CONFIG_NET_SCH_HTB=m
-CONFIG_NET_SCH_CSZ=m
-# CONFIG_NET_SCH_HFSC is not set
-CONFIG_NET_SCH_PRIO=m
-CONFIG_NET_SCH_RED=m
-CONFIG_NET_SCH_SFQ=m
-CONFIG_NET_SCH_TEQL=m
-CONFIG_NET_SCH_TBF=m
-CONFIG_NET_SCH_GRED=m
-# CONFIG_NET_SCH_NETEM is not set
-CONFIG_NET_SCH_DSMARK=m
-CONFIG_NET_SCH_INGRESS=m
-CONFIG_NET_QOS=y
-CONFIG_NET_ESTIMATOR=y
-CONFIG_NET_CLS=y
-CONFIG_NET_CLS_TCINDEX=m
-CONFIG_NET_CLS_ROUTE4=m
-CONFIG_NET_CLS_ROUTE=y
-CONFIG_NET_CLS_FW=m
-CONFIG_NET_CLS_U32=m
-CONFIG_NET_CLS_RSVP=m
-CONFIG_NET_CLS_RSVP6=m
-CONFIG_NET_CLS_POLICE=y
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-
-#
-# Telephony Support
-#
-# CONFIG_PHONE is not set
-# CONFIG_PHONE_IXJ is not set
-# CONFIG_PHONE_IXJ_PCMCIA is not set
-
-#
-# ATA/IDE/MFM/RLL support
-#
-# CONFIG_IDE is not set
-# CONFIG_BLK_DEV_HD is not set
-
-#
-# SCSI support
-#
-CONFIG_SCSI=m
-
-#
-# SCSI support type (disk, tape, CD-ROM)
-#
-CONFIG_BLK_DEV_SD=m
-CONFIG_SD_EXTRA_DEVS=5
-# CONFIG_CHR_DEV_ST is not set
-# CONFIG_CHR_DEV_OSST is not set
-# CONFIG_BLK_DEV_SR is not set
-CONFIG_CHR_DEV_SG=m
-
-#
-# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
-#
-# CONFIG_SCSI_DEBUG_QUEUES is not set
-# CONFIG_SCSI_MULTI_LUN is not set
-# CONFIG_SCSI_CONSTANTS is not set
-# CONFIG_SCSI_LOGGING is not set
-
-#
-# SCSI low-level drivers
-#
-# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
-# CONFIG_SCSI_7000FASST is not set
-# CONFIG_SCSI_ACARD is not set
-# CONFIG_SCSI_AHA152X is not set
-# CONFIG_SCSI_AHA1542 is not set
-# CONFIG_SCSI_AHA1740 is not set
-# CONFIG_SCSI_AACRAID is not set
-# CONFIG_SCSI_AIC7XXX is not set
-# CONFIG_SCSI_AIC79XX is not set
-# CONFIG_SCSI_AIC7XXX_OLD is not set
-# CONFIG_SCSI_DPT_I2O is not set
-# CONFIG_SCSI_ADVANSYS is not set
-# CONFIG_SCSI_IN2000 is not set
-# CONFIG_SCSI_AM53C974 is not set
-# CONFIG_SCSI_MEGARAID is not set
-# CONFIG_SCSI_MEGARAID2 is not set
-# CONFIG_SCSI_SATA is not set
-# CONFIG_SCSI_SATA_AHCI is not set
-# CONFIG_SCSI_SATA_SVW is not set
-# CONFIG_SCSI_ATA_PIIX is not set
-# CONFIG_SCSI_SATA_NV is not set
-# CONFIG_SCSI_SATA_PROMISE is not set
-# CONFIG_SCSI_SATA_SX4 is not set
-# CONFIG_SCSI_SATA_SIL is not set
-# CONFIG_SCSI_SATA_SIS is not set
-# CONFIG_SCSI_SATA_ULI is not set
-# CONFIG_SCSI_SATA_VIA is not set
-# CONFIG_SCSI_SATA_VITESSE is not set
-# CONFIG_SCSI_BUSLOGIC is not set
-# CONFIG_SCSI_CPQFCTS is not set
-# CONFIG_SCSI_DMX3191D is not set
-# CONFIG_SCSI_DTC3280 is not set
-# CONFIG_SCSI_EATA is not set
-# CONFIG_SCSI_EATA_DMA is not set
-# CONFIG_SCSI_EATA_PIO is not set
-# CONFIG_SCSI_FUTURE_DOMAIN is not set
-# CONFIG_SCSI_GDTH is not set
-# CONFIG_SCSI_GENERIC_NCR5380 is not set
-# CONFIG_SCSI_INITIO is not set
-# CONFIG_SCSI_INIA100 is not set
-# CONFIG_SCSI_NCR53C406A is not set
-# CONFIG_SCSI_NCR53C7xx is not set
-# CONFIG_SCSI_SYM53C8XX_2 is not set
-# CONFIG_SCSI_NCR53C8XX is not set
-# CONFIG_SCSI_SYM53C8XX is not set
-# CONFIG_SCSI_PAS16 is not set
-# CONFIG_SCSI_PCI2000 is not set
-# CONFIG_SCSI_PCI2220I is not set
-# CONFIG_SCSI_PSI240I is not set
-# CONFIG_SCSI_QLOGIC_FAS is not set
-# CONFIG_SCSI_QLOGIC_ISP is not set
-# CONFIG_SCSI_QLOGIC_FC is not set
-# CONFIG_SCSI_QLOGIC_1280 is not set
-# CONFIG_SCSI_SIM710 is not set
-# CONFIG_SCSI_SYM53C416 is not set
-# CONFIG_SCSI_DC390T is not set
-# CONFIG_SCSI_T128 is not set
-# CONFIG_SCSI_U14_34F is not set
-# CONFIG_SCSI_NSP32 is not set
-# CONFIG_SCSI_DEBUG is not set
-
-#
-# Fusion MPT device support
-#
-# CONFIG_FUSION is not set
-# CONFIG_FUSION_BOOT is not set
-# CONFIG_FUSION_ISENSE is not set
-# CONFIG_FUSION_CTL is not set
-# CONFIG_FUSION_LAN is not set
-
-#
-# IEEE 1394 (FireWire) support (EXPERIMENTAL)
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-# CONFIG_I2O is not set
-# CONFIG_I2O_PCI is not set
-# CONFIG_I2O_BLOCK is not set
-# CONFIG_I2O_LAN is not set
-# CONFIG_I2O_SCSI is not set
-# CONFIG_I2O_PROC is not set
-
-#
-# Network device support
-#
-CONFIG_NETDEVICES=y
-
-#
-# ARCnet devices
-#
-# CONFIG_ARCNET is not set
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-CONFIG_TUN=m
-# CONFIG_ETHERTAP is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-# CONFIG_SUNLANCE is not set
-# CONFIG_HAPPYMEAL is not set
-# CONFIG_SUNBMAC is not set
-# CONFIG_SUNQE is not set
-# CONFIG_SUNGEM is not set
-# CONFIG_NET_VENDOR_3COM is not set
-# CONFIG_LANCE is not set
-# CONFIG_NET_VENDOR_SMC is not set
-# CONFIG_NET_VENDOR_RACAL is not set
-# CONFIG_HP100 is not set
-# CONFIG_NET_ISA is not set
-# CONFIG_NET_PCI is not set
-# CONFIG_NET_POCKET is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-# CONFIG_ACENIC is not set
-# CONFIG_DL2K is not set
-# CONFIG_E1000 is not set
-# CONFIG_MYRI_SBUS is not set
-# CONFIG_NS83820 is not set
-# CONFIG_HAMACHI is not set
-# CONFIG_YELLOWFIN is not set
-# CONFIG_R8169 is not set
-# CONFIG_SK98LIN is not set
-# CONFIG_TIGON3 is not set
-# CONFIG_FDDI is not set
-# CONFIG_HIPPI is not set
-# CONFIG_PLIP is not set
-CONFIG_PPP=y
-# CONFIG_PPP_MULTILINK is not set
-# CONFIG_PPP_FILTER is not set
-CONFIG_PPP_ASYNC=m
-# CONFIG_PPP_SYNC_TTY is not set
-CONFIG_PPP_DEFLATE=m
-CONFIG_PPP_BSDCOMP=m
-CONFIG_PPPOE=m
-# CONFIG_SLIP is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Token Ring devices
-#
-# CONFIG_TR is not set
-# CONFIG_NET_FC is not set
-# CONFIG_RCPCI is not set
-CONFIG_SHAPER=m
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-# CONFIG_IRDA is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Input core support
-#
-# CONFIG_INPUT is not set
-# CONFIG_INPUT_KEYBDEV is not set
-# CONFIG_INPUT_MOUSEDEV is not set
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-# CONFIG_INPUT_UINPUT is not set
-
-#
-# Character devices
-#
-# CONFIG_VT is not set
-CONFIG_SERIAL=y
-CONFIG_SERIAL_CONSOLE=y
-# CONFIG_SERIAL_EXTENDED is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=128
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# Mice
-#
-# CONFIG_BUSMOUSE is not set
-# CONFIG_MOUSE is not set
-
-#
-# Joysticks
-#
-# CONFIG_INPUT_GAMEPORT is not set
-
-#
-# Input core support is needed for gameports
-#
-
-#
-# Input core support is needed for joysticks
-#
-# CONFIG_QIC02_TAPE is not set
-# CONFIG_IPMI_HANDLER is not set
-# CONFIG_IPMI_PANIC_EVENT is not set
-# CONFIG_IPMI_DEVICE_INTERFACE is not set
-# CONFIG_IPMI_KCS is not set
-# CONFIG_IPMI_WATCHDOG is not set
-
-#
-# Watchdog Cards
-#
-CONFIG_WATCHDOG=y
-CONFIG_WATCHDOG_NOWAYOUT=y
-# CONFIG_ACQUIRE_WDT is not set
-# CONFIG_ADVANTECH_WDT is not set
-# CONFIG_ALIM1535_WDT is not set
-# CONFIG_ALIM7101_WDT is not set
-# CONFIG_SC520_WDT is not set
-# CONFIG_PCWATCHDOG is not set
-# CONFIG_EUROTECH_WDT is not set
-# CONFIG_IB700_WDT is not set
-# CONFIG_WAFER_WDT is not set
-# CONFIG_I810_TCO is not set
-# CONFIG_MIXCOMWD is not set
-# CONFIG_60XX_WDT is not set
-# CONFIG_SC1200_WDT is not set
-# CONFIG_SCx200_WDT is not set
-CONFIG_SOFT_WATCHDOG=y
-# CONFIG_W83877F_WDT is not set
-# CONFIG_WDT is not set
-# CONFIG_WDTPCI is not set
-# CONFIG_MACHZ_WDT is not set
-# CONFIG_SCx200 is not set
-# CONFIG_SCx200_GPIO is not set
-# CONFIG_AMD_PM768 is not set
-# CONFIG_NVRAM is not set
-# CONFIG_RTC is not set
-# CONFIG_MIPS_RTC is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-
-#
-# Direct Rendering Manager (XFree86 DRI support)
-#
-# CONFIG_DRM is not set
-
-#
-# File systems
-#
-# CONFIG_QUOTA is not set
-# CONFIG_QFMT_V2 is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-# CONFIG_REISERFS_FS is not set
-# CONFIG_REISERFS_CHECK is not set
-# CONFIG_REISERFS_PROC_INFO is not set
-# CONFIG_ADFS_FS is not set
-# CONFIG_ADFS_FS_RW is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_HFSPLUS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BEFS_DEBUG is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
-# CONFIG_JBD_DEBUG is not set
-CONFIG_FAT_FS=m
-CONFIG_MSDOS_FS=m
-# CONFIG_UMSDOS_FS is not set
-CONFIG_VFAT_FS=m
-# CONFIG_EFS_FS is not set
-# CONFIG_JFFS_FS is not set
-CONFIG_JFFS2_FS=y
-CONFIG_JFFS2_FS_DEBUG=0
-CONFIG_CRAMFS=y
-# CONFIG_TMPFS is not set
-CONFIG_RAMFS=y
-# CONFIG_ISO9660_FS is not set
-# CONFIG_JOLIET is not set
-# CONFIG_ZISOFS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_JFS_DEBUG is not set
-# CONFIG_JFS_STATISTICS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_NTFS_FS is not set
-# CONFIG_NTFS_RW is not set
-# CONFIG_HPFS_FS is not set
-CONFIG_PROC_FS=y
-CONFIG_DEVFS_FS=y
-CONFIG_DEVFS_MOUNT=y
-# CONFIG_DEVFS_DEBUG is not set
-# CONFIG_DEVPTS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_QNX4FS_RW is not set
-# CONFIG_ROMFS_FS is not set
-CONFIG_EXT2_FS=m
-# CONFIG_SYSV_FS is not set
-# CONFIG_UDF_FS is not set
-# CONFIG_UDF_RW is not set
-# CONFIG_UFS_FS is not set
-# CONFIG_UFS_FS_WRITE is not set
-# CONFIG_XFS_FS is not set
-# CONFIG_XFS_QUOTA is not set
-# CONFIG_XFS_RT is not set
-# CONFIG_XFS_TRACE is not set
-# CONFIG_XFS_DEBUG is not set
-
-#
-# Network File Systems
-#
-# CONFIG_CODA_FS is not set
-# CONFIG_INTERMEZZO_FS is not set
-CONFIG_NFS_FS=m
-CONFIG_NFS_V3=y
-# CONFIG_NFS_DIRECTIO is not set
-# CONFIG_ROOT_NFS is not set
-# CONFIG_NFSD is not set
-# CONFIG_NFSD_V3 is not set
-# CONFIG_NFSD_TCP is not set
-CONFIG_SUNRPC=m
-CONFIG_LOCKD=m
-CONFIG_LOCKD_V4=y
-# CONFIG_SMB_FS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_NCPFS_PACKET_SIGNING is not set
-# CONFIG_NCPFS_IOCTL_LOCKING is not set
-# CONFIG_NCPFS_STRONG is not set
-# CONFIG_NCPFS_NFS_NS is not set
-# CONFIG_NCPFS_OS2_NS is not set
-# CONFIG_NCPFS_SMALLDOS is not set
-# CONFIG_NCPFS_NLS is not set
-# CONFIG_NCPFS_EXTRAS is not set
-# CONFIG_ZISOFS_FS is not set
-
-#
-# Partition Types
-#
-CONFIG_PARTITION_ADVANCED=y
-# CONFIG_ACORN_PARTITION is not set
-# CONFIG_OSF_PARTITION is not set
-# CONFIG_AMIGA_PARTITION is not set
-# CONFIG_ATARI_PARTITION is not set
-# CONFIG_MAC_PARTITION is not set
-CONFIG_MSDOS_PARTITION=y
-# CONFIG_BSD_DISKLABEL is not set
-# CONFIG_MINIX_SUBPARTITION is not set
-# CONFIG_SOLARIS_X86_PARTITION is not set
-# CONFIG_UNIXWARE_DISKLABEL is not set
-# CONFIG_LDM_PARTITION is not set
-# CONFIG_SGI_PARTITION is not set
-# CONFIG_ULTRIX_PARTITION is not set
-# CONFIG_SUN_PARTITION is not set
-# CONFIG_EFI_PARTITION is not set
-# CONFIG_SMB_NLS is not set
-CONFIG_NLS=y
-
-#
-# Native Language Support
-#
-CONFIG_NLS_DEFAULT="iso8859-1"
-# CONFIG_NLS_CODEPAGE_437 is not set
-# CONFIG_NLS_CODEPAGE_737 is not set
-# CONFIG_NLS_CODEPAGE_775 is not set
-# CONFIG_NLS_CODEPAGE_850 is not set
-# CONFIG_NLS_CODEPAGE_852 is not set
-# CONFIG_NLS_CODEPAGE_855 is not set
-# CONFIG_NLS_CODEPAGE_857 is not set
-# CONFIG_NLS_CODEPAGE_860 is not set
-# CONFIG_NLS_CODEPAGE_861 is not set
-# CONFIG_NLS_CODEPAGE_862 is not set
-# CONFIG_NLS_CODEPAGE_863 is not set
-# CONFIG_NLS_CODEPAGE_864 is not set
-# CONFIG_NLS_CODEPAGE_865 is not set
-# CONFIG_NLS_CODEPAGE_866 is not set
-# CONFIG_NLS_CODEPAGE_869 is not set
-# CONFIG_NLS_CODEPAGE_936 is not set
-# CONFIG_NLS_CODEPAGE_950 is not set
-# CONFIG_NLS_CODEPAGE_932 is not set
-# CONFIG_NLS_CODEPAGE_949 is not set
-# CONFIG_NLS_CODEPAGE_874 is not set
-# CONFIG_NLS_ISO8859_8 is not set
-# CONFIG_NLS_CODEPAGE_1250 is not set
-# CONFIG_NLS_CODEPAGE_1251 is not set
-# CONFIG_NLS_ISO8859_1 is not set
-# CONFIG_NLS_ISO8859_2 is not set
-# CONFIG_NLS_ISO8859_3 is not set
-# CONFIG_NLS_ISO8859_4 is not set
-# CONFIG_NLS_ISO8859_5 is not set
-# CONFIG_NLS_ISO8859_6 is not set
-# CONFIG_NLS_ISO8859_7 is not set
-# CONFIG_NLS_ISO8859_9 is not set
-# CONFIG_NLS_ISO8859_13 is not set
-# CONFIG_NLS_ISO8859_14 is not set
-# CONFIG_NLS_ISO8859_15 is not set
-# CONFIG_NLS_KOI8_R is not set
-# CONFIG_NLS_KOI8_U is not set
-# CONFIG_NLS_UTF8 is not set
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-CONFIG_USB=m
-# CONFIG_USB_DEBUG is not set
-
-#
-# Miscellaneous USB options
-#
-CONFIG_USB_DEVICEFS=y
-# CONFIG_USB_BANDWIDTH is not set
-
-#
-# USB Host Controller Drivers
-#
-# CONFIG_USB_EHCI_HCD is not set
-# CONFIG_USB_UHCI is not set
-# CONFIG_USB_UHCI_ALT is not set
-CONFIG_USB_OHCI=m
-
-#
-# USB Device Class drivers
-#
-# CONFIG_USB_AUDIO is not set
-# CONFIG_USB_EMI26 is not set
-# CONFIG_USB_BLUETOOTH is not set
-# CONFIG_USB_MIDI is not set
-CONFIG_USB_STORAGE=m
-# CONFIG_USB_STORAGE_DEBUG is not set
-CONFIG_USB_STORAGE_DATAFAB=y
-CONFIG_USB_STORAGE_FREECOM=y
-# CONFIG_USB_STORAGE_ISD200 is not set
-CONFIG_USB_STORAGE_DPCM=y
-CONFIG_USB_STORAGE_HP8200e=y
-CONFIG_USB_STORAGE_SDDR09=y
-CONFIG_USB_STORAGE_SDDR55=y
-CONFIG_USB_STORAGE_JUMPSHOT=y
-# CONFIG_USB_ACM is not set
-CONFIG_USB_PRINTER=m
-
-#
-# USB Human Interface Devices (HID)
-#
-# CONFIG_USB_HID is not set
-
-#
-#     Input core support is needed for USB HID input layer or HIDBP support
-#
-# CONFIG_USB_HIDINPUT is not set
-# CONFIG_USB_HIDDEV is not set
-# CONFIG_USB_KBD is not set
-# CONFIG_USB_MOUSE is not set
-# CONFIG_USB_AIPTEK is not set
-# CONFIG_USB_WACOM is not set
-# CONFIG_USB_KBTAB is not set
-# CONFIG_USB_POWERMATE is not set
-
-#
-# USB Imaging devices
-#
-# CONFIG_USB_DC2XX is not set
-# CONFIG_USB_MDC800 is not set
-# CONFIG_USB_SCANNER is not set
-# CONFIG_USB_MICROTEK is not set
-# CONFIG_USB_HPUSBSCSI is not set
-
-#
-# USB Multimedia devices
-#
-
-#
-#   Video4Linux support is needed for USB Multimedia device support
-#
-
-#
-# USB Network adaptors
-#
-# CONFIG_USB_PEGASUS is not set
-# CONFIG_USB_RTL8150 is not set
-# CONFIG_USB_KAWETH is not set
-# CONFIG_USB_CATC is not set
-# CONFIG_USB_CDCETHER is not set
-# CONFIG_USB_USBNET is not set
-
-#
-# USB port drivers
-#
-# CONFIG_USB_USS720 is not set
-
-#
-# USB Serial Converter support
-#
-# CONFIG_USB_SERIAL is not set
-
-#
-# USB Miscellaneous drivers
-#
-# CONFIG_USB_RIO500 is not set
-# CONFIG_USB_AUERSWALD is not set
-# CONFIG_USB_TIGL is not set
-# CONFIG_USB_BRLVGER is not set
-# CONFIG_USB_LCD is not set
-
-#
-# Support for USB gadgets
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# Bluetooth support
-#
-# CONFIG_BLUEZ is not set
-
-#
-# Kernel hacking
-#
-CONFIG_CROSSCOMPILE=y
-# CONFIG_RUNTIME_DEBUG is not set
-# CONFIG_KGDB is not set
-# CONFIG_GDB_CONSOLE is not set
-# CONFIG_DEBUG_INFO is not set
-# CONFIG_MAGIC_SYSRQ is not set
-# CONFIG_MIPS_UNCACHED is not set
-CONFIG_LOG_BUF_SHIFT=0
-
-#
-# Cryptographic options
-#
-# CONFIG_CRYPTO is not set
-
-#
-# Library routines
-#
-# CONFIG_CRC32 is not set
-CONFIG_ZLIB_INFLATE=y
-CONFIG_ZLIB_DEFLATE=y
diff --git a/openwrt/toolchain/libnotimpl/Makefile b/openwrt/toolchain/libnotimpl/Makefile
index 86ab927c1244e7a1c3a62836425636f70557498a..aae7aef34a3bb9d5dc35032410f13348564c0d52 100644
--- a/openwrt/toolchain/libnotimpl/Makefile
+++ b/openwrt/toolchain/libnotimpl/Makefile
@@ -1,30 +1,34 @@
 include $(TOPDIR)/rules.mk
 
-LIBNOTIMPL_DIR:=$(TOOL_BUILD_DIR)/libnotimpl
+PKG_NAME := libnotimpl
+PKG_BUILD_DIR := $(TOOL_BUILD_DIR)/libnotimpl
 
-LIBNOTIMPL_SRCS+=./files/math.c
-LIBNOTIMPL_OBJS:=$(patsubst ./files/%.c,$(LIBNOTIMPL_DIR)/%.o,$(LIBNOTIMPL_SRCS))
+include $(INCLUDE_DIR)/host-build.mk
 
-$(LIBNOTIMPL_DIR)/.prepared:
-	mkdir -p $(LIBNOTIMPL_DIR)
-	touch $@
+define cc
+	$(TARGET_CC) $(TARGET_CFLAGS) -c src/$(1).c -o $(PKG_BUILD_DIR)/$(1).o
+endef
 
-$(LIBNOTIMPL_OBJS): $(LIBNOTIMPL_DIR)/%.o : ./files/%.c
-	$(TARGET_CC) $(TARGET_CFLAGS) -c $< -o $@
+define Build/Prepare
+	rm -rf $(PKG_BUILD_DIR)
+	mkdir -p $(PKG_BUILD_DIR)
+endef
 
-$(LIBNOTIMPL_DIR)/libnotimpl.a: $(LIBNOTIMPL_OBJS)
-	$(TARGET_CROSS)ar rc $(LIBNOTIMPL_DIR)/libnotimpl.a $(LIBNOTIMPL_OBJS)
+define Build/Compile
+	$(call cc,math)
+	$(TARGET_CROSS)ar rc $(PKG_BUILD_DIR)/libnotimpl.a $(PKG_BUILD_DIR)/*.o
+endef
 
-$(STAGING_DIR)/usr/lib/libnotimpl.a: $(LIBNOTIMPL_DIR)/libnotimpl.a
+define Build/Install
 	mkdir -p $(STAGING_DIR)/usr/lib
-	$(CP) $< $@
-	touch -c $@
-
-source:
-prepare: $(LIBNOTIMPL_DIR)/.prepared
-compile: $(LIBNOTIMPL_DIR)/libnotimpl.a
-install: $(STAGING_DIR)/usr/lib/libnotimpl.a
-clean:  FORCE
+	$(CP) $(PKG_BUILD_DIR)/libnotimpl.a $(STAGING_DIR)/usr/lib/
+endef
+
+define Build/Clean
 	rm -rf \
 		$(STAGING_DIR)/usr/lib/libnotimpl.a \
-		$(LIBNOTIMPL_DIR) \
+		$(PKG_BUILD_DIR)
+endef
+
+$(eval $(call HostBuild))
+
diff --git a/openwrt/toolchain/libnotimpl/files/math.c b/openwrt/toolchain/libnotimpl/src/math.c
similarity index 100%
rename from openwrt/toolchain/libnotimpl/files/math.c
rename to openwrt/toolchain/libnotimpl/src/math.c
diff --git a/openwrt/toolchain/lzma/Makefile b/openwrt/toolchain/lzma/Makefile
index cace2a4e2b33d8fb9ab55ecbb337ce54b5166d61..6488a06280387fdb304c83a97610f1353328a23b 100644
--- a/openwrt/toolchain/lzma/Makefile
+++ b/openwrt/toolchain/lzma/Makefile
@@ -1,53 +1,37 @@
-#############################################################
-#
-# lzma target 
-# 
-#############################################################
-
 include $(TOPDIR)/rules.mk
 
-LZMA_DIR=$(BUILD_DIR)/lzma
-LZMA_SOURCE=lzma432.tar.bz2
-LZMA_SITE=@SF/sevenzip
-LZMA_MD5=155c1ebce5bc6710ae7ecc926226d9d7
-
-LZMA_LIB_DIR=$(LZMA_DIR)/C/7zip/Compress/LZMA_Lib
-LZMA_ALONE_DIR=$(LZMA_DIR)/C/7zip/Compress/LZMA_Alone
+PKG_NAME := lzma
+PKG_VERSION := 432
 
-TARGETS=$(LZMA_LIB_DIR)/liblzma.a $(LZMA_ALONE_DIR)/lzma
+PKG_SOURCE := $(PKG_NAME)$(PKG_VERSION).tar.bz2
+PKG_MD5SUM := 155c1ebce5bc6710ae7ecc926226d9d7
+PKG_SOURCE_URL := @SF/sevenzip
 
-$(DL_DIR)/$(LZMA_SOURCE):
-	$(SCRIPT_DIR)/download.pl $(DL_DIR) $(LZMA_SOURCE) $(LZMA_MD5) $(LZMA_SITE)
+PKG_BUILD_DIR=$(TOOL_BUILD_DIR)/lzma-$(PKG_VERSION)/lzma
 
-$(LZMA_DIR)/.unpacked: $(DL_DIR)/$(LZMA_SOURCE) 
-	@rm -rf $(LZMA_DIR) && mkdir -p $(LZMA_DIR)
-	tar xjf $^ -C $(LZMA_DIR)
-	$(PATCH) $(LZMA_DIR) ./patches
-	touch $(LZMA_DIR)/.unpacked
-	
-$(LZMA_ALONE_DIR)/lzma $(LZMA_LIB_DIR)/liblzma.a: $(LZMA_DIR)/.built
-$(LZMA_DIR)/.built: $(LZMA_DIR)/.unpacked
-	$(MAKE) -C $(LZMA_LIB_DIR)
-	$(MAKE) -f makefile.gcc -C $(LZMA_ALONE_DIR)
-	touch $@
+include $(INCLUDE_DIR)/host-build.mk
 
-lzma: $(TARGETS)
-	$(CP) $^ $(LZMA_DIR)
+LIB_DIR=$(PKG_BUILD_DIR)/C/7zip/Compress/LZMA_Lib
+ALONE_DIR=$(PKG_BUILD_DIR)/C/7zip/Compress/LZMA_Alone
 
+define Build/Prepare
+	bzcat $(DL_DIR)/$(PKG_SOURCE) | tar -C $(PKG_BUILD_DIR)/ $(TAR_OPTIONS) -
+	$(PATCH) $(PKG_BUILD_DIR) ./patches
+endef
 
-lzma-clean: FORCE
-	-$(MAKE) -C $(LZMA_LIB_DIR) clean
-	-$(MAKE) -C $(LZMA_ALONE_DIR) clean
-	rm -f $(LZMA_DIR)/liblzma.a $(LZMA_DIR)/lzma
+define Build/Compile
+	$(MAKE) -C $(LIB_DIR)
+	$(MAKE) -f makefile.gcc -C $(ALONE_DIR)
+endef
 
-lzma-dirclean: FORCE
-	rm -rf $(LZMA_DIR)
+define Build/Install
+	mkdir -p $(STAGING_DIR)/host/lib
+	$(CP) $(LIB_DIR)/liblzma.a $(STAGING_DIR)/host/lib/
+	$(CP) $(ALONE_DIR)/lzma $(STAGING_DIR)/bin/
+endef
 
-#############################################################
+define Build/Clean
+	rm -f $(PKG_BUILD_DIR)/liblzma.a $(PKG_BUILD_DIR)/lzma
+endef
 
-source: $(DL_DIR)/$(LZMA_SOURCE)
-prepare: $(LZMA_DIR)/.unpacked
-compile: lzma
-install: lzma FORCE
-	$(CP) $(LZMA_DIR)/lzma $(STAGING_DIR)/bin/
-clean: lzma-dirclean
+$(eval $(call HostBuild))
diff --git a/openwrt/toolchain/sed/Makefile b/openwrt/toolchain/sed/Makefile
index bbf85028af5a86310cb810289f1db7b660ad0601..0832ede2804d9bb6e65b244a7e627ff82bda9034 100644
--- a/openwrt/toolchain/sed/Makefile
+++ b/openwrt/toolchain/sed/Makefile
@@ -1,79 +1,56 @@
 include $(TOPDIR)/rules.mk
 
-#############################################################
-#
-# sed
-#
-#############################################################
-SED_VER:=4.1.2
-SED_SOURCE:=sed-$(SED_VER).tar.gz
-SED_SITE:=ftp://ftp.gnu.org/gnu/sed
-SED_CAT:=zcat
-SED_DIR1:=$(TOOL_BUILD_DIR)/sed-$(SED_VER)
-SED_DIR2:=$(BUILD_DIR)/sed-$(SED_VER)
-SED_BINARY:=sed/sed
-SED_TARGET_BINARY:=bin/sed
-SED_MD5SUM:=928f0e06422f414091917401f1a834d0
-ifeq ($(strip $(BUILD_WITH_LARGEFILE)),true)
-SED_CPPFLAGS=-D_FILE_OFFSET_BITS=64
-endif
-HOST_SED_TARGET=$(shell ./sedcheck.sh)
-DOWNLOAD_TARGET=$(shell ./sedcheck.sh)
+PKG_NAME := sed
+PKG_VERSION := 4.1.2
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=ftp://ftp.gnu.org/gnu/$(PKG_NAME)
+PKG_MD5SUM:=928f0e06422f414091917401f1a834d0
+PKG_CAT:=zcat
+
+PKG_BUILD_DIR:=$(TOOL_BUILD_DIR)/sed-$(PKG_VERSION)
 
-$(DL_DIR)/$(SED_SOURCE):
-	mkdir -p $(DL_DIR)
-	$(SCRIPT_DIR)/download.pl $(DL_DIR) $(SED_SOURCE) $(SED_MD5SUM) $(SED_SITE)
+HOST_SED_TARGET=$(strip $(shell ./sedcheck.sh))
 
-#############################################################
-#
-# build sed for use on the host system
-#
-#############################################################
+ifneq ($(HOST_SED_TARGET),build-sed-host-binary)
+  PKG_SOURCE:=
+  PKG_CAT:=
+endif
 
-$(SED_DIR1)/.unpacked: $(DL_DIR)/$(SED_SOURCE)
-	mkdir -p $(TOOL_BUILD_DIR)
-	mkdir -p $(STAGING_DIR)/bin;
-	$(SED_CAT) $(DL_DIR)/$(SED_SOURCE) | tar -C $(TOOL_BUILD_DIR) $(TAR_OPTIONS) -
-	touch $(SED_DIR1)/.unpacked
+include $(INCLUDE_DIR)/host-build.mk
 
-$(SED_DIR1)/.configured: $(SED_DIR1)/.unpacked
-	(cd $(SED_DIR1); rm -rf config.cache; \
+ifeq ($(HOST_SED_TARGET),build-sed-host-binary)
+  define Build/Configure
+	(cd $(PKG_BUILD_DIR); rm -rf config.cache; \
 		./configure \
 		--prefix=$(STAGING_DIR) \
 		--prefix=/usr \
 	);
-	touch  $(SED_DIR1)/.configured
+  endef
 
-$(SED_DIR1)/$(SED_BINARY): $(SED_DIR1)/.configured
-	$(MAKE) -C $(SED_DIR1)
+  define Build/Compile
+	$(MAKE) -C $(PKG_BUILD_DIR)
+  endef
 
-# This stuff is needed to work around GNU make deficiencies
-build-sed-host-binary: $(SED_DIR1)/$(SED_BINARY) FORCE
-	@if [ -L $(STAGING_DIR)/$(SED_TARGET_BINARY) ] ; then \
-		rm -f $(STAGING_DIR)/$(SED_TARGET_BINARY); fi;
-	@if [ ! -f $(STAGING_DIR)/$(SED_TARGET_BINARY) -o $(STAGING_DIR)/$(SED_TARGET_BINARY) \
-	-ot $(SED_DIR1)/$(SED_BINARY) ] ; then \
+  define Build/Install
+	@if [ -L $(STAGING_DIR)/bin/sed ] ; then \
+		rm -f $(STAGING_DIR)/bin/sed; fi;
+	@if [ ! -f $(STAGING_DIR)/bin/sed -o $(STAGING_DIR)/bin/sed -ot $(PKG_BUILD_DIR)/sed/sed ]; then \
 	    set -x; \
 	    mkdir -p $(STAGING_DIR)/bin; \
-	    $(MAKE) DESTDIR=$(STAGING_DIR) -C $(SED_DIR1) install; \
+	    $(MAKE) DESTDIR=$(STAGING_DIR) -C $(PKG_BUILD_DIR) install; \
 	    mv $(STAGING_DIR)/usr/bin/sed $(STAGING_DIR)/bin/; \
 	    rm -rf $(STAGING_DIR)/share/locale $(STAGING_DIR)/usr/info \
-		    $(STAGING_DIR)/usr/man $(STAGING_DIR)/usr/share/doc; fi
-
-use-sed-host-binary: FORCE
-	@if [ -x /usr/bin/sed ]; then SED="/usr/bin/sed"; else \
-	    if [ -x /bin/sed ]; then SED="/bin/sed"; fi; fi; \
-	    mkdir -p $(STAGING_DIR)/bin; \
-	    rm -f $(STAGING_DIR)/$(SED_TARGET_BINARY); \
-	    ln -s $$SED $(STAGING_DIR)/$(SED_TARGET_BINARY)
-
-download-sed-binary: sed-$(SED_VER).tar.gz
-
-source: $(DOWNLOAD_TARGET)
-prepare: 
-compile: 
-install: $(HOST_SED_TARGET)
-clean: FORCE
-	rm -rf $(SED_DIR1)
-	rm -f $(STAGING_DIR)/$(SED_TARGET_BINARY)
+		    $(STAGING_DIR)/usr/man $(STAGING_DIR)/usr/share/doc; \
+	fi
+  endef
+else
+  define Build/Compile
+  endef
+  define Build/Install
+    rm -rf $(STAGING_DIR)/bin/sed
+	mkdir -p $(STAGING_DIR)/bin
+	ln -s `which sed` $(STAGING_DIR)/bin/sed
+  endef
+endif
 
+$(eval $(call HostBuild))
diff --git a/openwrt/toolchain/sed/sedcheck.sh b/openwrt/toolchain/sed/sedcheck.sh
index 5af1d886bd21b582118d1a79683d78c7cc298bd4..de15ac2f1988069f2537fa370c4edd3368c10a74 100755
--- a/openwrt/toolchain/sed/sedcheck.sh
+++ b/openwrt/toolchain/sed/sedcheck.sh
@@ -12,11 +12,6 @@ echo "HELLO" > .sedtest
 $SED -i -e "s/HELLO/GOODBYE/" .sedtest >/dev/null 2>&1
 
 case "$1" in
-	download)
-		if [ $? != 0 ] ; then
-			echo download-sed-binary
-		fi;
-	;;
 	*)
 		if [ $? != 0 ] ; then
 			echo build-sed-host-binary
diff --git a/openwrt/toolchain/squashfs/Makefile b/openwrt/toolchain/squashfs/Makefile
index a2b367187640f6e679c74c623398b141cdff03c7..7b3eed5d6093eb2898c2130836420b0f08fd6b2c 100644
--- a/openwrt/toolchain/squashfs/Makefile
+++ b/openwrt/toolchain/squashfs/Makefile
@@ -1,27 +1,23 @@
 include $(TOPDIR)/rules.mk
 
-SQUASHFSLZMA_DIR=$(BUILD_DIR)/squashfs3.0
-SQUASHFSLZMA_SOURCE=squashfs3.0.tar.gz
-SQUASHFSLZMA_SITE=@SF/squashfs
-SQUASHFSLZMA_MD5SUM=9fd05d0bfbb712f5fb95edafea5bc733
+PKG_NAME := squashfs
+PKG_VERSION := 3.0
 
-$(DL_DIR)/$(SQUASHFSLZMA_SOURCE):
-	$(SCRIPT_DIR)/download.pl $(DL_DIR) $(SQUASHFSLZMA_SOURCE) $(SQUASHFSLZMA_MD5SUM) $(SQUASHFSLZMA_SITE)
+PKG_SOURCE := $(PKG_NAME)$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL := @SF/squashfs
+PKG_MD5SUM := 9fd05d0bfbb712f5fb95edafea5bc733
+PKG_CAT := zcat
 
-$(SQUASHFSLZMA_DIR)/.unpacked: $(DL_DIR)/$(SQUASHFSLZMA_SOURCE) 
-	zcat $(DL_DIR)/$(SQUASHFSLZMA_SOURCE) | tar -C $(BUILD_DIR) -xvf -
-	$(PATCH) $(SQUASHFSLZMA_DIR) ./patches
-	touch $(SQUASHFSLZMA_DIR)/.unpacked
+PKG_BUILD_DIR := $(TOOL_BUILD_DIR)/squashfs$(PKG_VERSION)
 
-$(SQUASHFSLZMA_DIR)/squashfs-tools/mksquashfs-lzma: $(SQUASHFSLZMA_DIR)/.unpacked
-	$(MAKE) -C $(SQUASHFSLZMA_DIR)/squashfs-tools mksquashfs-lzma LZMAPATH=$(BUILD_DIR)/lzma
+include $(INCLUDE_DIR)/host-build.mk
 
-$(STAGING_DIR)/bin/mksquashfs-lzma: $(SQUASHFSLZMA_DIR)/squashfs-tools/mksquashfs-lzma
-	$(CP) $< $@
+define Build/Compile
+	$(MAKE) -C $(PKG_BUILD_DIR)/squashfs-tools mksquashfs-lzma LZMAPATH=$(STAGING_DIR)/host/lib
+endef
 
-source: $(DL_DIR)/$(SQUASHFSLZMA_SOURCE)
-prepare: $(SQUASHFSLZMA_DIR)/.unpacked
-compile: $(SQUASHFSLZMA_DIR)/squashfs-tools/mksquashfs-lzma $(STAGING_DIR)/bin/mksquashfs-lzma
-install:
-clean: FORCE
-	rm -rf $(SQUASHFSLZMA_DIR)
+define Build/Install
+	$(CP) $(PKG_BUILD_DIR)/squashfs-tools/mksquashfs-lzma $(STAGING_DIR)/bin/
+endef
+
+$(eval $(call HostBuild))
diff --git a/openwrt/toolchain/sstrip/Makefile b/openwrt/toolchain/sstrip/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..aa18e21c5fed8caf081fdd0ef870bafba53d9b11
--- /dev/null
+++ b/openwrt/toolchain/sstrip/Makefile
@@ -0,0 +1,23 @@
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/host-build.mk
+
+PKG_BUILD_DIR := $(TOOL_BUILD_DIR)/sstrip
+
+OS:=$(shell uname)
+ifeq ($(OS),Darwin)
+CFLAGS += -I./include
+endif
+
+define Build/Compile
+	$(CC) $(CFLAGS) -o $(PKG_BUILD_DIR)/sstrip src/sstrip.c
+endef
+
+define Build/Install
+	$(CP) $(PKG_BUILD_DIR)/sstrip $(STAGING_DIR)/bin
+endef
+
+define Build/Clean
+	rm -f $(STAGING_DIR)/bin/sstrip
+endef
+
+$(eval $(call HostBuild))
diff --git a/openwrt/toolchain/utils/include/elf.h b/openwrt/toolchain/sstrip/include/elf.h
similarity index 100%
rename from openwrt/toolchain/utils/include/elf.h
rename to openwrt/toolchain/sstrip/include/elf.h
diff --git a/openwrt/toolchain/utils/src/sstrip.c b/openwrt/toolchain/sstrip/src/sstrip.c
similarity index 100%
rename from openwrt/toolchain/utils/src/sstrip.c
rename to openwrt/toolchain/sstrip/src/sstrip.c
diff --git a/openwrt/toolchain/uClibc/Makefile b/openwrt/toolchain/uClibc/Makefile
index f7691e4f1b0ffdb4bbe75753327a73f168344771..22c5913457393c0633ee79c2fc830c83541cb1c1 100644
--- a/openwrt/toolchain/uClibc/Makefile
+++ b/openwrt/toolchain/uClibc/Makefile
@@ -1,25 +1,16 @@
 include $(TOPDIR)/rules.mk
 
-#############################################################
-#
-# uClibc (the C library)
-#
-#############################################################
+PKG_NAME:=uClibc
+PKG_VERSION:=0.9.28
 
-ifeq ($(CONFIG_UCLIBC_VERSION_SNAPSHOT),y)
-# Be aware that this changes daily....
-UCLIBC_DIR:=$(TOOL_BUILD_DIR)/uClibc
-UCLIBC_SOURCE:=uClibc-$(strip $(subst ",, $(CONFIG_USE_UCLIBC_SNAPSHOT))).tar.bz2#"))
-UCLIBC_SITE:=http://www.uclibc.org/downloads/snapshots
-UCLIBC_VER:=PKG_VERSION:=0.${shell date +"%G%m%d"}
-UCLIBC_MD5SUM:=x
-else
-UCLIBC_VER:=0.9.28
-UCLIBC_DIR:=$(TOOL_BUILD_DIR)/uClibc-$(UCLIBC_VER)
-UCLIBC_SOURCE:=uClibc-$(UCLIBC_VER).tar.bz2
-UCLIBC_SITE:=http://www.uclibc.org/downloads
-UCLIBC_MD5SUM:=1ada58d919a82561061e4741fb6abd29
-endif
+PKG_SOURCE:=uClibc-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://www.uclibc.org/downloads
+PKG_MD5SUM:=1ada58d919a82561061e4741fb6abd29
+PKG_CAT:=bzcat
+
+PKG_BUILD_DIR:=$(TOOL_BUILD_DIR)/uClibc-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/host-build.mk
 
 UCLIBC_TARGET_ARCH:=$(shell echo $(ARCH) | sed -e s'/-.*//' \
 		-e 's/i.86/i386/' \
@@ -35,70 +26,62 @@ UCLIBC_TARGET_ARCH:=$(shell echo $(ARCH) | sed -e s'/-.*//' \
 		-e 's/cris.*/cris/' \
 )
 
-
-$(DL_DIR)/$(UCLIBC_SOURCE):
-	mkdir -p $(DL_DIR)
-	$(SCRIPT_DIR)/download.pl $(DL_DIR) $(UCLIBC_SOURCE) $(UCLIBC_MD5SUM) $(UCLIBC_SITE)
-
-$(UCLIBC_DIR)/.unpacked: $(DL_DIR)/$(UCLIBC_SOURCE)
-	mkdir -p $(TOOL_BUILD_DIR)
-	bzcat $(DL_DIR)/$(UCLIBC_SOURCE) | tar -C $(TOOL_BUILD_DIR) $(TAR_OPTIONS) -
-	$(PATCH) $(UCLIBC_DIR) ./patches
-	touch $(UCLIBC_DIR)/.unpacked
-
-$(UCLIBC_DIR)/.configured: $(UCLIBC_DIR)/.unpacked
-	$(SED) 's,^CROSS=.*,CROSS=$(TARGET_CROSS),g' $(UCLIBC_DIR)/Rules.mak
-	$(CP) ./files/config.$(ARCH) $(UCLIBC_DIR)/.config
+define Build/Prepare
+	$(call Build/Prepare/Default)
+	$(SED) 's,^CROSS=.*,CROSS=$(TARGET_CROSS),g' $(PKG_BUILD_DIR)/Rules.mak
+	$(CP) ./files/config.$(ARCH) $(PKG_BUILD_DIR)/.config
 	$(SED) 's,^KERNEL_SOURCE=.*,KERNEL_SOURCE=\"$(LINUX_HEADERS_DIR)\",g' \
-		$(UCLIBC_DIR)/.config
+		$(PKG_BUILD_DIR)/.config
 ifeq ($(CONFIG_LARGEFILE),y)
-	$(SED) 's,^.*UCLIBC_HAS_LFS.*,UCLIBC_HAS_LFS=y,g' $(UCLIBC_DIR)/.config
+	$(SED) 's,^.*UCLIBC_HAS_LFS.*,UCLIBC_HAS_LFS=y,g' $(PKG_BUILD_DIR)/.config
 else
-	$(SED) 's,^.*UCLIBC_HAS_LFS.*,UCLIBC_HAS_LFS=n,g' $(UCLIBC_DIR)/.config
+	$(SED) 's,^.*UCLIBC_HAS_LFS.*,UCLIBC_HAS_LFS=n,g' $(PKG_BUILD_DIR)/.config
 endif
-	$(SED) 's,.*UCLIBC_HAS_WCHAR.*,UCLIBC_HAS_WCHAR=y,g' $(UCLIBC_DIR)/.config
+	$(SED) 's,.*UCLIBC_HAS_WCHAR.*,UCLIBC_HAS_WCHAR=y,g' $(PKG_BUILD_DIR)/.config
 ifeq ($(CONFIG_SOFT_FLOAT),y)
-	$(SED) 's,.*HAS_FPU.*,HAS_FPU=n\nUCLIBC_HAS_FLOATS=y\nUCLIBC_HAS_SOFT_FLOAT=y,g' $(UCLIBC_DIR)/.config
+	$(SED) 's,.*HAS_FPU.*,HAS_FPU=n\nUCLIBC_HAS_FLOATS=y\nUCLIBC_HAS_SOFT_FLOAT=y,g' $(PKG_BUILD_DIR)/.config
 endif
 	mkdir -p $(TOOL_BUILD_DIR)/uClibc_dev/usr/include
 	mkdir -p $(TOOL_BUILD_DIR)/uClibc_dev/usr/lib
 	mkdir -p $(TOOL_BUILD_DIR)/uClibc_dev/lib
-	$(MAKE) -C $(UCLIBC_DIR) \
+	$(MAKE) -C $(PKG_BUILD_DIR) \
 		PREFIX=$(TOOL_BUILD_DIR)/uClibc_dev/ \
 		DEVEL_PREFIX=/usr/ \
 		RUNTIME_PREFIX=$(TOOL_BUILD_DIR)/uClibc_dev/ \
 		HOSTCC="$(HOSTCC)" \
 		CPU_CFLAGS="$(TARGET_CFLAGS)" \
 		pregen install_dev;
-	touch $(UCLIBC_DIR)/.configured
+endef
 
-$(UCLIBC_DIR)/lib/libc.a: $(UCLIBC_DIR)/.configured $(LIBFLOAT_TARGET)
-	$(MAKE) -C $(UCLIBC_DIR) \
+define Build/Configure
+endef
+
+define Build/Compile
+	$(MAKE) -C $(PKG_BUILD_DIR) \
 		PREFIX= \
 		DEVEL_PREFIX=/ \
 		RUNTIME_PREFIX=/ \
 		HOSTCC="$(HOSTCC)" \
 		CPU_CFLAGS="$(TARGET_CFLAGS)" \
 		all
-	touch -c $(UCLIBC_DIR)/lib/libc.a
+endef
 
-$(STAGING_DIR)/lib/libc.a: $(UCLIBC_DIR)/lib/libc.a
-	$(MAKE) -C $(UCLIBC_DIR) \
+define Build/Install
+	$(MAKE) -C $(PKG_BUILD_DIR) \
 		PREFIX=$(STAGING_DIR)/ \
 		DEVEL_PREFIX=/ \
 		RUNTIME_PREFIX=/ \
 		install_runtime
-	$(MAKE) -C $(UCLIBC_DIR) \
+	$(MAKE) -C $(PKG_BUILD_DIR) \
 		PREFIX=$(STAGING_DIR)/ \
 		DEVEL_PREFIX=/ \
 		RUNTIME_PREFIX=/ \
 		install_dev
-	echo $(UCLIBC_VER) > $(STAGING_DIR)/uclibc_version
-	touch -c $(STAGING_DIR)/lib/libc.a
+	echo $(PKG_VERSION) > $(STAGING_DIR)/uclibc_version
+endef
+
+define Build/Clean
+	rm -rf $(PKG_BUILD_DIR) $(TOOL_BUILD_DIR)/uClibc_dev
+endef
 
-source: $(DL_DIR)/$(UCLIBC_SOURCE)
-prepare: $(UCLIBC_DIR)/.configured
-compile: $(UCLIBC_DIR)/lib/libc.a
-install: $(STAGING_DIR)/lib/libc.a $(UCLIBC_TARGETS)
-clean:  FORCE
-	rm -rf $(UCLIBC_DIR) $(TOOL_BUILD_DIR)/uClibc_dev
+$(eval $(call HostBuild))
diff --git a/openwrt/toolchain/utils/Makefile b/openwrt/toolchain/utils/Makefile
deleted file mode 100644
index f79ed891e45ae98374fb3a91617f4949755e365c..0000000000000000000000000000000000000000
--- a/openwrt/toolchain/utils/Makefile
+++ /dev/null
@@ -1,27 +0,0 @@
-include $(TOPDIR)/rules.mk
-
-TARGETS:=sstrip
-UTILS_BUILD_DIR:=$(TOOL_BUILD_DIR)/utils
-
-OS:=$(shell uname)
-ifeq ($(OS),Darwin)
-CFLAGS += -I./include
-endif
-
-source:
-prepare: $(UTILS_BUILD_DIR)
-compile: prepare $(patsubst %,$(UTILS_BUILD_DIR)/%,$(TARGETS))
-install: compile
-	mkdir -p $(STAGING_DIR)/bin
-	$(CP) $(UTILS_BUILD_DIR)/* $(STAGING_DIR)/bin/
-package:
-clean: FORCE
-	rm -rf $(UTILS_BUILD_DIR)
-
-$(UTILS_BUILD_DIR):
-	mkdir -p $(UTILS_BUILD_DIR)
-	
-$(UTILS_BUILD_DIR)/%: src/%.c
-	$(CC) $(CFLAGS) -o $@ $(patsubst $(UTILS_BUILD_DIR)/%,src/%.c,$@)
-	chmod 755 $@
-