+
+ifneq ($(CONFIG_GCC_VERSION_4_3),)
+ GCC_BUILD_TARGET_LIBGCC:=y
+ GCC_CONFIGURE_COMMON+= \
+ --with-gmp=$(TOPDIR)/staging_dir/host \
+ --with-mpfr=$(TOPDIR)/staging_dir/host \
+ --disable-decimal-float
+endif
+
+ifneq ($(CONFIG_SSP_SUPPORT),)
+ GCC_CONFIGURE_COMMON+= \
+ --enable-libssp
+else
+ GCC_CONFIGURE_COMMON+= \
+ --disable-libssp
+endif
+
+ifneq ($(CONFIG_EXTRA_TARGET_ARCH),)
+ GCC_CONFIGURE_COMMON+= \
+ --enable-biarch \
+ --enable-targets=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-linux-$(TARGET_SUFFIX)
+endif
+
+ifeq ($(LIBC),uClibc)
+ GCC_CONFIGURE_COMMON+= \
+ --disable-__cxa_atexit
+else
+ GCC_CONFIGURE_COMMON+= \
+ --enable-__cxa_atexit
+endif
+
+GCC_CONFIGURE_STAGE0:= \
+ $(GCC_CONFIGURE_COMMON) \
+ --with-newlib \
+ --without-headers \
+ --enable-languages=c \
+ --disable-libssp \
+ --disable-shared \
+ --disable-threads \
+
+GCC_CONFIGURE_STAGE1:= \
+ $(GCC_CONFIGURE_COMMON) \
+ --with-newlib \
+ --with-sysroot=$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev \
+ --enable-languages=c \
+ --disable-shared \
+ --disable-threads \
+
+GCC_CONFIGURE_STAGE2:= \
+ $(GCC_CONFIGURE_COMMON) \
+ --enable-languages=$(TARGET_LANGUAGES) \
+ --enable-shared \
+ --enable-threads \
+ --with-slibdir=$(TOOLCHAIN_DIR)/lib \
+
+GCC_MAKE:= \
+ export SHELL="$(BASH)"; \
+ $(MAKE) \
+
+
+define Build/SetToolchainInfo
+ $(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
+endef
+
+
+define Stage0/Configure
+ mkdir -p $(PKG_BUILD_DIR0)
+ (cd $(PKG_BUILD_DIR0); rm -f config.cache; \
+ $(GCC_CONFIGURE_STAGE0) \
+ );
+endef
+
+define Stage0/Compile
+ $(GCC_MAKE) -C $(PKG_BUILD_DIR0) all-gcc
+endef
+
+define Stage0/Install
+ $(GCC_MAKE) -C $(PKG_BUILD_DIR0) install-gcc
+endef
+
+
+define Stage1/Configure
+ mkdir -p $(PKG_BUILD_DIR1)
+ (cd $(PKG_BUILD_DIR1); rm -f config.cache; \
+ $(GCC_CONFIGURE_STAGE1) \