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.

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