common.mk 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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.1.0)
  34. PKG_HASH:=8a8136c235f64c6fef69cac0d73a46a1a09bb250776a050aec8f9fc880bebc17
  35. endif
  36. ifneq ($(CONFIG_GCC_VERSION_6_2_ARC),)
  37. PKG_VERSION:=6.2.1
  38. PKG_SOURCE_URL:=https://github.com/foss-for-synopsys-dwc-arc-processors/gcc/archive/$(GCC_VERSION)
  39. PKG_SOURCE:=$(PKG_NAME)-$(GCC_VERSION).tar.gz
  40. PKG_HASH:=d6f842dd266ccb0d5a53b51e2b2951503569f2ff3c84f81b2a1d9fea109ec077
  41. PKG_REV:=2016.09
  42. GCC_DIR:=gcc-arc-$(PKG_REV)
  43. HOST_BUILD_DIR = $(BUILD_DIR_HOST)/$(PKG_NAME)-$(GCC_VERSION)
  44. endif
  45. PATCH_DIR=../patches/$(GCC_VERSION)
  46. BUGURL=http://www.lede-project.org/bugs/
  47. PKGVERSION=LEDE GCC $(PKG_VERSION) $(REVISION)
  48. HOST_BUILD_PARALLEL:=1
  49. include $(INCLUDE_DIR)/toolchain-build.mk
  50. HOST_SOURCE_DIR:=$(HOST_BUILD_DIR)
  51. ifeq ($(GCC_VARIANT),minimal)
  52. GCC_BUILD_DIR:=$(HOST_BUILD_DIR)-$(GCC_VARIANT)
  53. else
  54. HOST_BUILD_DIR:=$(HOST_BUILD_DIR)-$(GCC_VARIANT)
  55. GCC_BUILD_DIR:=$(HOST_BUILD_DIR)
  56. endif
  57. HOST_STAMP_PREPARED:=$(HOST_BUILD_DIR)/.prepared
  58. HOST_STAMP_BUILT:=$(GCC_BUILD_DIR)/.built
  59. HOST_STAMP_CONFIGURED:=$(GCC_BUILD_DIR)/.configured
  60. HOST_STAMP_INSTALLED:=$(HOST_BUILD_PREFIX)/stamp/.gcc_$(GCC_VARIANT)_installed
  61. SEP:=,
  62. TARGET_LANGUAGES:="c,c++$(if $(CONFIG_INSTALL_LIBGCJ),$(SEP)java)$(if $(CONFIG_INSTALL_GFORTRAN),$(SEP)fortran)$(if $(CONFIG_INSTALL_GCCGO),$(SEP)go)"
  63. TAR_OPTIONS += \
  64. --exclude-from='$(CURDIR)/../exclude-testsuite' --exclude=gcc/ada/*.ad* \
  65. ifndef CONFIG_INSTALL_LIBGCJ
  66. TAR_OPTIONS += --exclude=libjava
  67. endif
  68. export libgcc_cv_fixed_point=no
  69. ifdef CONFIG_USE_UCLIBC
  70. export glibcxx_cv_c99_math_tr1=no
  71. endif
  72. ifdef CONFIG_INSTALL_GCCGO
  73. export libgo_cv_c_split_stack_supported=no
  74. endif
  75. ifdef CONFIG_GCC_USE_GRAPHITE
  76. GRAPHITE_CONFIGURE=--with-isl=$(HOST_BUILD_PREFIX)
  77. else
  78. GRAPHITE_CONFIGURE=--without-isl --without-cloog
  79. endif
  80. GCC_CONFIGURE:= \
  81. SHELL="$(BASH)" \
  82. $(if $(shell gcc --version 2>&1 | grep LLVM), \
  83. CFLAGS="-O2 -fbracket-depth=512 -pipe" \
  84. CXXFLAGS="-O2 -fbracket-depth=512 -pipe" \
  85. ) \
  86. $(HOST_SOURCE_DIR)/configure \
  87. --with-bugurl=$(BUGURL) \
  88. --with-pkgversion="$(PKGVERSION)" \
  89. --prefix=$(TOOLCHAIN_DIR) \
  90. --build=$(GNU_HOST_NAME) \
  91. --host=$(GNU_HOST_NAME) \
  92. --target=$(REAL_GNU_TARGET_NAME) \
  93. --with-gnu-ld \
  94. --enable-target-optspace \
  95. --disable-libgomp \
  96. --disable-libmudflap \
  97. --disable-multilib \
  98. --disable-libmpx \
  99. --disable-nls \
  100. $(GRAPHITE_CONFIGURE) \
  101. --with-host-libstdcxx=-lstdc++ \
  102. $(SOFT_FLOAT_CONFIG_OPTION) \
  103. $(call qstrip,$(CONFIG_EXTRA_GCC_CONFIG_OPTIONS)) \
  104. $(if $(CONFIG_mips64)$(CONFIG_mips64el),--with-arch=mips64 \
  105. --with-abi=$(call qstrip,$(CONFIG_MIPS64_ABI))) \
  106. $(if $(CONFIG_arc),--with-cpu=$(CONFIG_CPU_TYPE)) \
  107. --with-gmp=$(TOPDIR)/staging_dir/host \
  108. --with-mpfr=$(TOPDIR)/staging_dir/host \
  109. --with-mpc=$(TOPDIR)/staging_dir/host \
  110. --disable-decimal-float
  111. ifneq ($(CONFIG_mips)$(CONFIG_mipsel),)
  112. GCC_CONFIGURE += --with-mips-plt
  113. endif
  114. ifndef GCC_VERSION_4_8
  115. GCC_CONFIGURE += --with-diagnostics-color=auto-if-env
  116. endif
  117. ifneq ($(CONFIG_SSP_SUPPORT),)
  118. GCC_CONFIGURE+= \
  119. --enable-libssp
  120. else
  121. GCC_CONFIGURE+= \
  122. --disable-libssp
  123. endif
  124. ifneq ($(CONFIG_EXTRA_TARGET_ARCH),)
  125. GCC_CONFIGURE+= \
  126. --enable-biarch \
  127. --enable-targets=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-linux-$(TARGET_SUFFIX)
  128. endif
  129. ifdef CONFIG_sparc
  130. GCC_CONFIGURE+= \
  131. --enable-targets=all \
  132. --with-long-double-128
  133. endif
  134. ifeq ($(LIBC),uClibc)
  135. GCC_CONFIGURE+= \
  136. --disable-__cxa_atexit
  137. else
  138. GCC_CONFIGURE+= \
  139. --enable-__cxa_atexit
  140. endif
  141. ifneq ($(GCC_ARCH),)
  142. GCC_CONFIGURE+= --with-arch=$(GCC_ARCH)
  143. endif
  144. ifneq ($(CONFIG_SOFT_FLOAT),y)
  145. ifeq ($(CONFIG_arm),y)
  146. GCC_CONFIGURE+= \
  147. --with-float=hard
  148. endif
  149. endif
  150. ifeq ($(CONFIG_TARGET_x86)$(CONFIG_USE_GLIBC)$(CONFIG_INSTALL_GCCGO),yyy)
  151. TARGET_CFLAGS+=-fno-split-stack
  152. endif
  153. GCC_MAKE:= \
  154. export SHELL="$(BASH)"; \
  155. $(MAKE) \
  156. CFLAGS="$(HOST_CFLAGS)" \
  157. CFLAGS_FOR_TARGET="$(TARGET_CFLAGS)" \
  158. CXXFLAGS_FOR_TARGET="$(TARGET_CFLAGS)" \
  159. GOCFLAGS_FOR_TARGET="$(TARGET_CFLAGS)"
  160. define Host/SetToolchainInfo
  161. $(SED) 's,TARGET_CROSS=.*,TARGET_CROSS=$(REAL_GNU_TARGET_NAME)-,' $(TOOLCHAIN_DIR)/info.mk
  162. $(SED) 's,GCC_VERSION=.*,GCC_VERSION=$(GCC_VERSION),' $(TOOLCHAIN_DIR)/info.mk
  163. endef
  164. ifneq ($(GCC_PREPARE),)
  165. define Host/Prepare
  166. $(call Host/SetToolchainInfo)
  167. $(call Host/Prepare/Default)
  168. ln -snf $(GCC_DIR) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
  169. $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_SOURCE_DIR)/
  170. $(SED) 's,^MULTILIB_OSDIRNAMES,# MULTILIB_OSDIRNAMES,' $(HOST_SOURCE_DIR)/gcc/config/*/t-*
  171. $(SED) 'd' $(HOST_SOURCE_DIR)/gcc/DEV-PHASE
  172. $(SED) 's, DATESTAMP,,' $(HOST_SOURCE_DIR)/gcc/version.c
  173. #(cd $(HOST_SOURCE_DIR)/libstdc++-v3; autoconf;);
  174. $(SED) 's,gcc_no_link=yes,gcc_no_link=no,' $(HOST_SOURCE_DIR)/libstdc++-v3/configure
  175. mkdir -p $(GCC_BUILD_DIR)
  176. endef
  177. else
  178. define Host/Prepare
  179. mkdir -p $(GCC_BUILD_DIR)
  180. endef
  181. endif
  182. define Host/Configure
  183. (cd $(GCC_BUILD_DIR) && rm -f config.cache; \
  184. $(GCC_CONFIGURE) \
  185. );
  186. endef
  187. define Host/Clean
  188. rm -rf $(if $(GCC_PREPARE),$(HOST_SOURCE_DIR)) \
  189. $(HOST_BUILD_PREFIX)/stamp/.gcc_* \
  190. $(HOST_BUILD_PREFIX)/stamp/.binutils_* \
  191. $(GCC_BUILD_DIR) \
  192. $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
  193. $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME) \
  194. $(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gc* \
  195. $(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-c*
  196. endef