Makefile 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. --enable-lto \
  11. --with-libelf=$(TOPDIR)/staging_dir/host
  12. ifdef CONFIG_USE_MUSL
  13. GCC_MAKE += gcc_cv_libc_provides_ssp=yes
  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. ifeq ($(CONFIG_USE_GLIBC)$(CONFIG_INSTALL_GCCGO),yy)
  36. define FixGogccCrt
  37. # link crtX.o for gotools
  38. mkdir -p $(GCC_BUILD_DIR)/gotools
  39. $(foreach crt, i 1 n, ln -sf ../../glibc-dev/lib/crt$(crt).o $(GCC_BUILD_DIR)/gotools/ ; )
  40. endef
  41. endif
  42. define Host/Compile
  43. $(FixGogccCrt)
  44. +$(GCC_MAKE) $(HOST_JOBS) -C $(GCC_BUILD_DIR) all
  45. endef
  46. define SetupExtraArch
  47. for app in $(TOOLCHAIN_DIR)/bin/$(OPTIMIZE_FOR_CPU)*-{gcc,gcc-*,g++}; do \
  48. [ -e $$$$app ] || continue; \
  49. old_base=$$$$(basename $$$$app); \
  50. new_base=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-$$$${old_base##$(OPTIMIZE_FOR_CPU)-}; \
  51. sed -e "s/@CC_BASE@/$$$$old_base/" \
  52. -e 's/@EXTRA_ARCH_OPTS@/$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_OPTS))/' \
  53. ../files/alternate-arch-cc.in > \
  54. $(TOOLCHAIN_DIR)/bin/$$$$new_base; \
  55. chmod a+x $(TOOLCHAIN_DIR)/bin/$$$$new_base; \
  56. done
  57. endef
  58. define Host/Install
  59. $(CleanupToolchain)
  60. $(_SINGLE)$(GCC_MAKE) -C $(GCC_BUILD_DIR) install
  61. # Set up the symlinks to enable lying about target name.
  62. set -e; \
  63. (cd $(TOOLCHAIN_DIR); \
  64. ln -sf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
  65. cd bin; \
  66. for app in $(REAL_GNU_TARGET_NAME)-* ; do \
  67. ln -sf $$$${app} \
  68. $(GNU_TARGET_NAME)$$$${app##$(REAL_GNU_TARGET_NAME)}; \
  69. done; \
  70. );
  71. $(if $(CONFIG_EXTRA_TARGET_ARCH),$(call SetupExtraArch))
  72. $(RM) $(TOOLCHAIN_DIR)/lib/libiberty.a
  73. $(SCRIPT_DIR)/patch-specs.sh "$(TOOLCHAIN_DIR)"
  74. endef
  75. $(eval $(call HostBuild))