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.

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