-GCC_VERSION:=$(strip $(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)
-
-GCC_SOURCE:=gcc-$(GCC_VERSION).tar.bz2
-GCC_DIR:=$(TOOL_BUILD_DIR)/gcc-$(GCC_VERSION)
-GCC_CAT:=bzcat
-GCC_STRIP_HOST_BINARIES:=true
-
-#############################################################
-#
-# Setup some initial stuff
-#
-#############################################################
-
-ifeq ($(BR2_INSTALL_LIBGCJ),y)
-TARGET_LANGUAGES:=c,c++,java
-else
-ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
-TARGET_LANGUAGES:=c,c++
-else
-TARGET_LANGUAGES:=c
-endif
-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.
-ifeq ($(BR2_SOFT_FLOAT),y)
-ifeq ("$(strip $(ARCH))","arm")
- $(SCRIPT_DIR)/patch-kernel.sh $(GCC_DIR) ./$(GCC_VERSION) arm-softfloat.patch.conditional
-endif
-ifeq ("$(strip $(ARCH))","armeb")
- $(SCRIPT_DIR)/patch-kernel.sh $(GCC_DIR) ./$(GCC_VERSION) arm-softfloat.patch.conditional
-endif
-endif
- $(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 \
- --prefix=$(STAGING_DIR) \
+PKG_NAME:=gcc
+PKG_VERSION:=$(strip $(subst ",, $(CONFIG_GCC_VERSION)))#"))
+
+PATCH_DIR=./patches/$(PKG_VERSION)
+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_SOURCE:=gcc-$(PKG_VERSION).tar.bz2
+STAGING_DIR_HOST:=$(TOOLCHAIN_DIR)
+BUILD_DIR_HOST:=$(BUILD_DIR_TOOLCHAIN)
+
+include $(INCLUDE_DIR)/host-build.mk
+
+STAMP_BUILT:=$(STAGING_DIR)/stamp/.gcc-initial_installed
+BUILD_DIR1:=$(BUILD_DIR_HOST)/gcc-$(PKG_VERSION)-initial
+BUILD_DIR2:=$(BUILD_DIR_HOST)/gcc-$(PKG_VERSION)-final
+
+SEP:=,
+TARGET_LANGUAGES:="c$(if $(CONFIG_INSTALL_LIBSTDCPP),$(SEP)c++)$(if $(CONFIG_INSTALL_LIBGCJ),$(SEP)java)"
+
+define Stage1/Configure
+ $(SED) 's,TARGET_CROSS=.*,TARGET_CROSS=$(REAL_GNU_TARGET_NAME)-,' $(TOOLCHAIN_DIR)/info.mk
+ $(SED) 's,GCC_VERSION=.*,GCC_VERSION=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
+ mkdir -p $(BUILD_DIR1)
+ (cd $(BUILD_DIR1); rm -f config.cache; \
+ SHELL="$(BASH)" \
+ $(PKG_BUILD_DIR)/configure \
+ --prefix=$(TOOLCHAIN_DIR) \