common.mk 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. #
  2. # Copyright (C) 2002-2003 Erik Andersen <[email protected]>
  3. # Copyright (C) 2004 Manuel Novoa III <[email protected]>
  4. # Copyright (C) 2005-2006 Felix Fietkau <[email protected]>
  5. # Copyright (C) 2006-2014 OpenWrt.org
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. # General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. include $(TOPDIR)/rules.mk
  21. PKG_NAME:=gcc
  22. GCC_VERSION:=$(call qstrip,$(CONFIG_GCC_VERSION))
  23. PKG_VERSION:=$(firstword $(subst +, ,$(GCC_VERSION)))
  24. GCC_DIR:=$(PKG_NAME)-$(PKG_VERSION)
  25. PKG_SOURCE_URL:=@GNU/gcc/gcc-$(PKG_VERSION)
  26. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
  27. ifeq ($(PKG_VERSION),5.4.0)
  28. PKG_HASH:=608df76dec2d34de6558249d8af4cbee21eceddbcb580d666f7a5a583ca3303a
  29. endif
  30. ifeq ($(PKG_VERSION),6.3.0)
  31. PKG_HASH:=f06ae7f3f790fbf0f018f6d40e844451e6bc3b7bc96e128e63b09825c1f8b29f
  32. endif
  33. ifeq ($(PKG_VERSION),7.2.0)
  34. PKG_HASH:=1cf7adf8ff4b5aa49041c8734bbcf1ad18cc4c94d0029aae0f4e48841088479a
  35. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
  36. endif
  37. ifneq ($(CONFIG_GCC_VERSION_6_3_ARC),)
  38. PKG_VERSION:=6.3.0
  39. PKG_SOURCE_URL:=https://github.com/foss-for-synopsys-dwc-arc-processors/gcc/archive/$(GCC_VERSION)
  40. PKG_SOURCE:=$(PKG_NAME)-$(GCC_VERSION).tar.gz
  41. PKG_HASH:=b7223e134199b1a6f71de629da6aa845790e55d28e9892143dde09b1bc878110
  42. PKG_REV:=2017.03-release
  43. GCC_DIR:=gcc-arc-$(PKG_REV)
  44. HOST_BUILD_DIR = $(BUILD_DIR_HOST)/$(PKG_NAME)-$(GCC_VERSION)
  45. endif
  46. PATCH_DIR=../patches/$(GCC_VERSION)
  47. BUGURL=http://www.lede-project.org/bugs/
  48. PKGVERSION=LEDE GCC $(PKG_VERSION) $(REVISION)
  49. HOST_BUILD_PARALLEL:=1
  50. include $(INCLUDE_DIR)/toolchain-build.mk
  51. HOST_SOURCE_DIR:=$(HOST_BUILD_DIR)
  52. ifeq ($(GCC_VARIANT),minimal)
  53. GCC_BUILD_DIR:=$(HOST_BUILD_DIR)-$(GCC_VARIANT)
  54. else
  55. HOST_BUILD_DIR:=$(HOST_BUILD_DIR)-$(GCC_VARIANT)
  56. GCC_BUILD_DIR:=$(HOST_BUILD_DIR)
  57. endif
  58. HOST_STAMP_PREPARED:=$(HOST_BUILD_DIR)/.prepared
  59. HOST_STAMP_BUILT:=$(GCC_BUILD_DIR)/.built
  60. HOST_STAMP_CONFIGURED:=$(GCC_BUILD_DIR)/.configured
  61. HOST_STAMP_INSTALLED:=$(HOST_BUILD_PREFIX)/stamp/.gcc_$(GCC_VARIANT)_installed
  62. SEP:=,
  63. TARGET_LANGUAGES:="c,c++$(if $(CONFIG_INSTALL_LIBGCJ),$(SEP)java)$(if $(CONFIG_INSTALL_GFORTRAN),$(SEP)fortran)$(if $(CONFIG_INSTALL_GCCGO),$(SEP)go)"
  64. TAR_OPTIONS += \
  65. --exclude-from='$(CURDIR)/../exclude-testsuite' --exclude=gcc/ada/*.ad* \
  66. ifndef CONFIG_INSTALL_LIBGCJ
  67. TAR_OPTIONS += --exclude=libjava
  68. endif
  69. export libgcc_cv_fixed_point=no
  70. ifdef CONFIG_USE_UCLIBC
  71. export glibcxx_cv_c99_math_tr1=no
  72. endif
  73. ifdef CONFIG_INSTALL_GCCGO
  74. export libgo_cv_c_split_stack_supported=no
  75. endif
  76. ifdef CONFIG_GCC_USE_GRAPHITE
  77. GRAPHITE_CONFIGURE:= --with-isl=$(TOPDIR)/staging_dir/host
  78. else
  79. GRAPHITE_CONFIGURE:= --without-isl --without-cloog
  80. endif
  81. GCC_CONFIGURE:= \
  82. SHELL="$(BASH)" \
  83. $(if $(shell gcc --version 2>&1 | grep LLVM), \
  84. CFLAGS="-O2 -fbracket-depth=512 -pipe" \
  85. CXXFLAGS="-O2 -fbracket-depth=512 -pipe" \
  86. ) \
  87. $(HOST_SOURCE_DIR)/configure \
  88. --with-bugurl=$(BUGURL) \
  89. --with-pkgversion="$(PKGVERSION)" \
  90. --prefix=$(TOOLCHAIN_DIR) \
  91. --build=$(GNU_HOST_NAME) \
  92. --host=$(GNU_HOST_NAME) \
  93. --target=$(REAL_GNU_TARGET_NAME) \
  94. --with-gnu-ld \
  95. --enable-target-optspace \
  96. --disable-libgomp \
  97. --disable-libmudflap \
  98. --disable-multilib \
  99. --disable-libmpx \
  100. --disable-nls \
  101. $(GRAPHITE_CONFIGURE) \
  102. --with-host-libstdcxx=-lstdc++ \
  103. $(SOFT_FLOAT_CONFIG_OPTION) \
  104. $(call qstrip,$(CONFIG_EXTRA_GCC_CONFIG_OPTIONS)) \
  105. $(if $(CONFIG_mips64)$(CONFIG_mips64el),--with-arch=mips64 \
  106. --with-abi=$(call qstrip,$(CONFIG_MIPS64_ABI))) \
  107. $(if $(CONFIG_arc),--with-cpu=$(CONFIG_CPU_TYPE)) \
  108. --with-gmp=$(TOPDIR)/staging_dir/host \
  109. --with-mpfr=$(TOPDIR)/staging_dir/host \
  110. --with-mpc=$(TOPDIR)/staging_dir/host \
  111. --disable-decimal-float
  112. ifneq ($(CONFIG_mips)$(CONFIG_mipsel),)
  113. GCC_CONFIGURE += --with-mips-plt
  114. endif
  115. ifndef GCC_VERSION_4_8
  116. GCC_CONFIGURE += --with-diagnostics-color=auto-if-env
  117. endif
  118. ifneq ($(CONFIG_SSP_SUPPORT),)
  119. GCC_CONFIGURE+= \
  120. --enable-libssp
  121. else
  122. GCC_CONFIGURE+= \
  123. --disable-libssp
  124. endif
  125. ifneq ($(CONFIG_EXTRA_TARGET_ARCH),)
  126. GCC_CONFIGURE+= \
  127. --enable-biarch \
  128. --enable-targets=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-linux-$(TARGET_SUFFIX)
  129. endif
  130. ifdef CONFIG_sparc
  131. GCC_CONFIGURE+= \
  132. --enable-targets=all \
  133. --with-long-double-128
  134. endif
  135. ifeq ($(LIBC),uClibc)
  136. GCC_CONFIGURE+= \
  137. --disable-__cxa_atexit
  138. else
  139. GCC_CONFIGURE+= \
  140. --enable-__cxa_atexit
  141. endif
  142. ifneq ($(GCC_ARCH),)
  143. GCC_CONFIGURE+= --with-arch=$(GCC_ARCH)
  144. endif
  145. ifneq ($(CONFIG_SOFT_FLOAT),y)
  146. ifeq ($(CONFIG_arm),y)
  147. GCC_CONFIGURE+= \
  148. --with-float=hard
  149. endif
  150. endif
  151. ifeq ($(CONFIG_TARGET_x86)$(CONFIG_USE_GLIBC)$(CONFIG_INSTALL_GCCGO),yyy)
  152. TARGET_CFLAGS+=-fno-split-stack
  153. endif
  154. GCC_MAKE:= \
  155. export SHELL="$(BASH)"; \
  156. $(MAKE) \
  157. CFLAGS="$(HOST_CFLAGS)" \
  158. CFLAGS_FOR_TARGET="$(TARGET_CFLAGS)" \
  159. CXXFLAGS_FOR_TARGET="$(TARGET_CFLAGS)" \
  160. GOCFLAGS_FOR_TARGET="$(TARGET_CFLAGS)"
  161. define Host/SetToolchainInfo
  162. $(SED) 's,TARGET_CROSS=.*,TARGET_CROSS=$(REAL_GNU_TARGET_NAME)-,' $(TOOLCHAIN_DIR)/info.mk
  163. $(SED) 's,GCC_VERSION=.*,GCC_VERSION=$(GCC_VERSION),' $(TOOLCHAIN_DIR)/info.mk
  164. endef
  165. ifneq ($(GCC_PREPARE),)
  166. define Host/Prepare
  167. $(call Host/SetToolchainInfo)
  168. $(call Host/Prepare/Default)
  169. ln -snf $(GCC_DIR) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
  170. $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_SOURCE_DIR)/
  171. $(SED) 's,^MULTILIB_OSDIRNAMES,# MULTILIB_OSDIRNAMES,' $(HOST_SOURCE_DIR)/gcc/config/*/t-*
  172. $(SED) 'd' $(HOST_SOURCE_DIR)/gcc/DEV-PHASE
  173. $(SED) 's, DATESTAMP,,' $(HOST_SOURCE_DIR)/gcc/version.c
  174. #(cd $(HOST_SOURCE_DIR)/libstdc++-v3; autoconf;);
  175. $(SED) 's,gcc_no_link=yes,gcc_no_link=no,' $(HOST_SOURCE_DIR)/libstdc++-v3/configure
  176. mkdir -p $(GCC_BUILD_DIR)
  177. endef
  178. else
  179. define Host/Prepare
  180. mkdir -p $(GCC_BUILD_DIR)
  181. endef
  182. endif
  183. define Host/Configure
  184. (cd $(GCC_BUILD_DIR) && rm -f config.cache; \
  185. $(GCC_CONFIGURE) \
  186. );
  187. endef
  188. define Host/Clean
  189. rm -rf $(if $(GCC_PREPARE),$(HOST_SOURCE_DIR)) \
  190. $(HOST_BUILD_PREFIX)/stamp/.gcc_* \
  191. $(HOST_BUILD_PREFIX)/stamp/.binutils_* \
  192. $(GCC_BUILD_DIR) \
  193. $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
  194. $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME) \
  195. $(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gc* \
  196. $(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-c*
  197. endef