common.mk 6.5 KB

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