You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

176 lines
5.6 KiB

  1. #
  2. # Copyright (C) 2008 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. include $(TOPDIR)/rules.mk
  8. PKG_NAME:=gcc
  9. PKG_VERSION:=5.4.0
  10. PKG_RELEASE:=3
  11. PKG_SOURCE_URL:=@GNU/gcc/gcc-$(PKG_VERSION)
  12. PKG_HASH:=608df76dec2d34de6558249d8af4cbee21eceddbcb580d666f7a5a583ca3303a
  13. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
  14. PKG_INSTALL:=1
  15. PKG_FIXUP:=libtool
  16. PKG_BUILD_PARALLEL:=1
  17. include $(INCLUDE_DIR)/package.mk
  18. TARGET_LANGUAGES:="c,c++"
  19. BUGURL=https://dev.openwrt.org/
  20. PKGVERSION=OpenWrt GCC $(PKG_VERSION)
  21. TARGET_CPPFLAGS += -D_GLIBCXX_INCLUDE_NEXT_C_HEADERS
  22. # not using sstrip here as this fucks up the .so's somehow
  23. STRIP:=$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)strip
  24. RSTRIP:= \
  25. NM="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)nm" \
  26. STRIP="$(STRIP)" \
  27. STRIP_KMOD="$(STRIP) --strip-debug" \
  28. $(SCRIPT_DIR)/rstrip.sh
  29. ifneq ($(CONFIG_SOFT_FLOAT),y)
  30. ifeq ($(CONFIG_arm),y)
  31. ARM_FLOAT_OPTION:= --with-float=hard
  32. endif
  33. endif
  34. define Package/gcc
  35. SECTION:=devel
  36. CATEGORY:=Development
  37. TITLE:=gcc
  38. MAINTAINER:=Noble Pepper <gccmaintain@noblepepper.com>
  39. DEPENDS:= +binutils +libstdcpp
  40. endef
  41. define Package/gcc/description
  42. build a native toolchain for compiling on target
  43. endef
  44. GMPSRC=gmp-4.3.2
  45. define Download/gmp
  46. URL:=ftp://gcc.gnu.org/pub/gcc/infrastructure/
  47. FILE:=$(GMPSRC).tar.bz2
  48. HASH:=936162c0312886c21581002b79932829aa048cfaf9937c6265aeaa14f1cd1775
  49. endef
  50. $(eval $(call Download,gmp))
  51. MPCSRC=mpc-0.8.1
  52. define Download/mpc
  53. URL:=ftp://gcc.gnu.org/pub/gcc/infrastructure/
  54. FILE:=$(MPCSRC).tar.gz
  55. HASH:=e664603757251fd8a352848276497a4c79b7f8b21fd8aedd5cc0598a38fee3e4
  56. endef
  57. $(eval $(call Download,mpc))
  58. MPFRSRC=mpfr-2.4.2
  59. define Download/mpfr
  60. URL:=ftp://gcc.gnu.org/pub/gcc/infrastructure/
  61. FILE:=$(MPFRSRC).tar.bz2
  62. HASH:=c7e75a08a8d49d2082e4caee1591a05d11b9d5627514e678f02d66a124bcf2ba
  63. endef
  64. $(eval $(call Download,mpfr))
  65. define Build/Prepare
  66. $(PKG_UNPACK)
  67. # we have to download and unpack additional stuff before patching
  68. tar -C $(PKG_BUILD_DIR) -xvjf $(DL_DIR)/$(GMPSRC).tar.bz2
  69. ln -sf $(PKG_BUILD_DIR)/$(GMPSRC) $(PKG_BUILD_DIR)/gmp
  70. tar -C $(PKG_BUILD_DIR) -xvzf $(DL_DIR)/$(MPCSRC).tar.gz
  71. ln -sf $(PKG_BUILD_DIR)/$(MPCSRC) $(PKG_BUILD_DIR)/mpc
  72. tar -C $(PKG_BUILD_DIR) -xvjf $(DL_DIR)/$(MPFRSRC).tar.bz2
  73. ln -sf $(PKG_BUILD_DIR)/$(MPFRSRC) $(PKG_BUILD_DIR)/mpfr
  74. $(Build/Patch)
  75. # poor man's fix for `none-openwrt-linux' not recognized when building with musl
  76. cp $(PKG_BUILD_DIR)/config.sub $(PKG_BUILD_DIR)/mpfr/
  77. cp $(PKG_BUILD_DIR)/config.sub $(PKG_BUILD_DIR)/gmp/
  78. cp $(PKG_BUILD_DIR)/config.sub $(PKG_BUILD_DIR)/mpc/
  79. endef
  80. TARGET_CXX += -std=gnu++03
  81. CONFIGURE_ARGS += CXX_FOR_TARGET="$(TARGET_CXX)" CXXFLAGS_FOR_TARGET="-g -O2 -D_GLIBCXX_INCLUDE_NEXT_C_HEADERS"
  82. define Build/Configure
  83. (cd $(PKG_BUILD_DIR); rm -f config.cache; \
  84. SHELL="$(BASH)" \
  85. $(TARGET_CONFIGURE_OPTS) \
  86. $(PKG_BUILD_DIR)/configure \
  87. $(CONFIGURE_ARGS) \
  88. --build=$(GNU_HOST_NAME) \
  89. --host=$(REAL_GNU_TARGET_NAME) \
  90. --target=$(REAL_GNU_TARGET_NAME) \
  91. --enable-languages=$(TARGET_LANGUAGES) \
  92. --with-bugurl=$(BUGURL) \
  93. --with-pkgversion="$(PKGVERSION)" \
  94. --enable-shared \
  95. $(if $(CONFIG_LIBC_USE_GLIBC),--enable,--disable)-__cxa_atexit \
  96. --with-default-libstdcxx-abi=gcc4-compatible \
  97. --enable-target-optspace \
  98. --with-gnu-ld \
  99. --disable-nls \
  100. --disable-libsanitizer \
  101. --disable-libvtv \
  102. --disable-libcilkrts \
  103. --disable-libmudflap \
  104. --disable-multilib \
  105. --disable-libgomp \
  106. --disable-libquadmath \
  107. --disable-libssp \
  108. --disable-decimal-float \
  109. --disable-libstdcxx-pch \
  110. --with-host-libstdcxx=-lstdc++ \
  111. --prefix=/usr \
  112. --libexecdir=/usr/lib \
  113. --with-local-prefix=/usr \
  114. $(ARM_FLOAT_OPTION) \
  115. $(SOFT_FLOAT_CONFIG_OPTION) \
  116. $(call qstrip,$(CONFIG_EXTRA_GCC_CONFIG_OPTIONS)) \
  117. );
  118. endef
  119. define Build/Compile
  120. export SHELL="$(BASH)"; $(MAKE_VARS) $(MAKE) -C $(PKG_BUILD_DIR) \
  121. DESTDIR="$(PKG_INSTALL_DIR)" $(MAKE_ARGS) all install
  122. endef
  123. ENVCFLAGS:="$(TARGET_OPTIMIZATION) $(EXTRA_OPTIMIZATION)
  124. ifeq ($(CONFIG_SOFT_FLOAT),y)
  125. ifeq ($(CONFIG_arm),y)
  126. ENVCFLAGS+= -mfloat-abi=soft
  127. else
  128. ENVCFLAGS+= -msoft-float
  129. endif
  130. endif
  131. ENVCFLAGS+="
  132. ENVLDFLAGS:="-Wl,-rpath=/usr/lib -Wl,--dynamic-linker=/usr/lib/$(DYNLINKER) -L/usr/lib"
  133. define Package/gcc/install
  134. $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib $(1)/usr/lib/$(PKG_NAME)/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION)
  135. cp -ar $(PKG_INSTALL_DIR)/usr/include $(1)/usr
  136. cp -a $(PKG_INSTALL_DIR)/usr/bin/{$(REAL_GNU_TARGET_NAME)-{g++,gcc},cpp,gcov} $(1)/usr/bin
  137. ln -s $(REAL_GNU_TARGET_NAME)-g++ $(1)/usr/bin/c++
  138. ln -s $(REAL_GNU_TARGET_NAME)-g++ $(1)/usr/bin/g++
  139. ln -s $(REAL_GNU_TARGET_NAME)-g++ $(1)/usr/bin/$(REAL_GNU_TARGET_NAME)-c++
  140. ln -s $(REAL_GNU_TARGET_NAME)-gcc $(1)/usr/bin/gcc
  141. ln -s $(REAL_GNU_TARGET_NAME)-gcc $(1)/usr/bin/$(REAL_GNU_TARGET_NAME)-gcc-$(PKG_VERSION)
  142. cp -ar $(PKG_INSTALL_DIR)/usr/lib/gcc $(1)/usr/lib
  143. cp -ar $(TOOLCHAIN_DIR)/include $(1)/usr
  144. cp -a $(TOOLCHAIN_DIR)/lib/*.{o,so*} $(1)/usr/lib/$(PKG_NAME)/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION)
  145. cp -a $(TOOLCHAIN_DIR)/lib/*nonshared*.a $(1)/usr/lib/$(PKG_NAME)/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION)
  146. cp -a $(TOOLCHAIN_DIR)/lib/libm.a $(1)/usr/lib/$(PKG_NAME)/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION)
  147. rm -f $(1)/usr/lib/$(PKG_NAME)/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION)/libgo*
  148. rm -f $(1)/usr/lib/$(PKG_NAME)/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION)/libcc1*
  149. echo '#!/bin/sh' > $(1)/usr/bin/gcc_env.sh
  150. echo 'export LDFLAGS=$(ENVLDFLAGS)' >> $(1)/usr/bin/gcc_env.sh
  151. echo 'export CFLAGS=$(ENVCFLAGS)' >> $(1)/usr/bin/gcc_env.sh
  152. chmod +x $(1)/usr/bin/gcc_env.sh
  153. endef
  154. $(eval $(call BuildPackage,gcc))