Makefile 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. GCC_VARIANT:=final
  2. include ../common.mk
  3. GCC_CONFIGURE += \
  4. --with-headers=$(TOOLCHAIN_DIR)/include \
  5. --disable-libsanitizer \
  6. --enable-languages=$(TARGET_LANGUAGES) \
  7. --enable-shared \
  8. --enable-threads \
  9. --with-slibdir=$(TOOLCHAIN_DIR)/lib
  10. ifneq ($(CONFIG_GCC_VERSION_4_5)$(CONFIG_GCC_VERSION_4_6),)
  11. GCC_CONFIGURE += \
  12. --enable-lto \
  13. --with-libelf=$(TOPDIR)/staging_dir/host
  14. endif
  15. ifneq ($(CONFIG_SJLJ_EXCEPTIONS),)
  16. GCC_CONFIGURE += \
  17. --enable-sjlj-exceptions
  18. endif
  19. define CleanupToolchain
  20. $(INSTALL_DIR) $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)
  21. # Important! Required for limits.h to be fixed.
  22. rm -rf $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
  23. ln -sf ../include $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
  24. rm -rf $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/lib
  25. ln -sf ../lib $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/lib
  26. $(if $(CONFIG_ARCH_64BIT),ln -sf ../lib64 $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/lib64)
  27. endef
  28. define Host/Configure
  29. $(CleanupToolchain)
  30. mkdir -p $(GCC_BUILD_DIR)
  31. (cd $(GCC_BUILD_DIR) && rm -f config.cache; \
  32. $(GCC_CONFIGURE) \
  33. );
  34. endef
  35. define Host/Compile
  36. +$(GCC_MAKE) $(HOST_JOBS) -C $(GCC_BUILD_DIR) all
  37. endef
  38. define SetupExtraArch
  39. for app in $(TOOLCHAIN_DIR)/bin/$(OPTIMIZE_FOR_CPU)*-{gcc,gcc-*,g++}; do \
  40. [ -e $$$$app ] || continue; \
  41. old_base=$$$$(basename $$$$app); \
  42. new_base=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-$$$${old_base##$(OPTIMIZE_FOR_CPU)-}; \
  43. sed -e "s/@CC_BASE@/$$$$old_base/" \
  44. -e 's/@EXTRA_ARCH_OPTS@/$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_OPTS))/' \
  45. ../files/alternate-arch-cc.in > \
  46. $(TOOLCHAIN_DIR)/bin/$$$$new_base; \
  47. chmod a+x $(TOOLCHAIN_DIR)/bin/$$$$new_base; \
  48. done
  49. endef
  50. define Host/Install
  51. $(CleanupToolchain)
  52. $(_SINGLE)$(GCC_MAKE) -C $(GCC_BUILD_DIR) install
  53. # Set up the symlinks to enable lying about target name.
  54. set -e; \
  55. (cd $(TOOLCHAIN_DIR); \
  56. ln -sf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
  57. cd bin; \
  58. for app in $(REAL_GNU_TARGET_NAME)-* ; do \
  59. ln -sf $$$${app} \
  60. $(GNU_TARGET_NAME)$$$${app##$(REAL_GNU_TARGET_NAME)}; \
  61. done; \
  62. );
  63. $(if $(CONFIG_EXTRA_TARGET_ARCH),$(call SetupExtraArch))
  64. $(RM) $(TOOLCHAIN_DIR)/lib/libiberty.a
  65. $(SCRIPT_DIR)/patch-specs.sh "$(TOOLCHAIN_DIR)"
  66. endef
  67. $(eval $(call HostBuild))