- --disable-__cxa_atexit \
- --enable-target-optspace \
- --with-gnu-ld \
- $(DISABLE_NLS) \
- $(MULTILIB) \
- $(SOFT_FLOAT_CONFIG_OPTION) \
- $(GCC_WITH_CPU) $(GCC_WITH_ARCH) $(GCC_WITH_TUNE) \
- $(GCC_USE_SJLJ_EXCEPTIONS) \
- $(EXTRA_GCC_CONFIG_OPTIONS));
- 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
- PATH=$(TARGET_PATH) $(MAKE) -C $(GCC_BUILD_DIR2) install
- echo $(GCC_VERSION) > $(STAGING_DIR)/gcc_version
+ --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) \
+ );
+endef
+
+define Stage1/Compile
+ $(CP) $(BUILD_DIR_TOOLCHAIN)/linux-dev/* $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/
+ $(GCC_MAKE) -C $(PKG_BUILD_DIR1) \
+ all-build-libiberty \
+ all-gcc \
+ $(if $(GCC_BUILD_TARGET_LIBGCC),all-target-libgcc)
+endef
+
+define Stage1/Install
+ $(GCC_MAKE) -C $(PKG_BUILD_DIR1) \
+ install-gcc \
+ $(if $(GCC_BUILD_TARGET_LIBGCC),install-target-libgcc)
+
+ # XXX: glibc insists on linking against libgcc_eh
+ ( cd $(TOOLCHAIN_DIR)/usr/lib/gcc/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION) ; \
+ [ -e libgcc_eh.a ] || ln -sf libgcc.a libgcc_eh.a ; \
+ )
+endef
+
+
+define Stage2/Configure
+ mkdir -p $(PKG_BUILD_DIR2) $(TOOLCHAIN_DIR)/usr/$(REAL_GNU_TARGET_NAME)
+ # Important! Required for limits.h to be fixed.
+ rm -rf $(TOOLCHAIN_DIR)/usr/$(REAL_GNU_TARGET_NAME)/sys-include
+ ln -sf ../include $(TOOLCHAIN_DIR)/usr/$(REAL_GNU_TARGET_NAME)/sys-include
+ rm -rf $(TOOLCHAIN_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib
+ ln -sf ../lib $(TOOLCHAIN_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib
+ (cd $(PKG_BUILD_DIR2); rm -f config.cache; \
+ $(GCC_CONFIGURE_STAGE2) \
+ );
+endef
+
+define Stage2/Compile
+ $(GCC_MAKE) -C $(PKG_BUILD_DIR2) all
+endef
+
+define SetupExtraArch
+ for app in $(TOOLCHAIN_DIR)/usr/bin/$(OPTIMIZE_FOR_CPU)*-{gcc,gcc-*,g++}; do \
+ [ -e $$$$app ] || continue; \
+ old_base=$$$$(basename $$$$app); \
+ new_base=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-$$$${old_base##$(OPTIMIZE_FOR_CPU)-}; \
+ sed -e "s/@CC_BASE@/$$$$old_base/" \
+ -e 's/@EXTRA_ARCH_OPTS@/$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_OPTS))/' \
+ ./files/alternate-arch-cc.in > \
+ $(TOOLCHAIN_DIR)/usr/bin/$$$$new_base; \
+ chmod a+x $(TOOLCHAIN_DIR)/usr/bin/$$$$new_base; \
+ done
+endef
+
+define Stage2/Install
+ $(GCC_MAKE) -C $(PKG_BUILD_DIR2) install