common.mk 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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@openwrt.org>
  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. ifeq ($(findstring linaro, $(CONFIG_GCC_VERSION)),linaro)
  26. LINARO_RELEASE:=
  27. ifeq ($(CONFIG_GCC_VERSION),"4.6-linaro")
  28. PKG_REV:=4.6-2013.05
  29. PKG_VERSION:=4.6.4
  30. PKG_VERSION_MAJOR:=4.6
  31. PKG_MD5SUM:=26b48802ae1203cd99415026fbf56ed7
  32. PKG_COMP:=bz2
  33. endif
  34. ifeq ($(CONFIG_GCC_VERSION),"4.8-linaro")
  35. PKG_REV:=4.8-2014.04
  36. PKG_VERSION:=4.8.3
  37. PKG_VERSION_MAJOR:=4.8
  38. PKG_MD5SUM:=5ba2f3a449b1658ccc09d27cc7ab3c03
  39. PKG_COMP:=xz
  40. endif
  41. ifeq ($(CONFIG_GCC_VERSION),"4.9-linaro")
  42. LINARO_RELEASE:=15.03
  43. PKG_REV:=4.9-2015.03
  44. PKG_VERSION:=4.9.3
  45. PKG_VERSION_MAJOR:=4.9
  46. PKG_MD5SUM:=f9d256d120adfbb45dd3e2d22b70cba9
  47. PKG_COMP:=xz
  48. endif
  49. ifneq ($(LINARO_RELEASE),)
  50. PKG_SOURCE_URL:=http://releases.linaro.org/$(LINARO_RELEASE)/components/toolchain/gcc-linaro/$(PKG_VERSION_MAJOR)
  51. else
  52. PKG_SOURCE_URL:=http://launchpad.net/gcc-linaro/$(PKG_VERSION_MAJOR)/$(PKG_REV)/+download/
  53. endif
  54. PKG_SOURCE:=$(PKG_NAME)-linaro-$(PKG_REV).tar.$(PKG_COMP)
  55. GCC_DIR:=gcc-linaro-$(PKG_REV)
  56. HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(GCC_DIR)
  57. else
  58. PKG_SOURCE_URL:=@GNU/gcc/gcc-$(PKG_VERSION)
  59. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
  60. ifeq ($(PKG_VERSION),4.6.3)
  61. PKG_MD5SUM:=773092fe5194353b02bb0110052a972e
  62. endif
  63. ifeq ($(PKG_VERSION),4.8.0)
  64. PKG_MD5SUM:=e6040024eb9e761c3bea348d1fa5abb0
  65. endif
  66. endif
  67. PATCH_DIR=../patches/$(GCC_VERSION)
  68. BUGURL=https://dev.librecmc.org/
  69. ifeq ($(findstring linaro, $(CONFIG_GCC_VERSION)),linaro)
  70. PKGVERSION=libreCMC/Linaro GCC $(PKG_REV) $(REVISION)
  71. else
  72. PKGVERSION=libreCMC GCC $(PKG_VERSION) $(REVISION)
  73. endif
  74. HOST_BUILD_PARALLEL:=1
  75. include $(INCLUDE_DIR)/toolchain-build.mk
  76. HOST_SOURCE_DIR:=$(HOST_BUILD_DIR)
  77. ifeq ($(GCC_VARIANT),minimal)
  78. GCC_BUILD_DIR:=$(HOST_BUILD_DIR)-$(GCC_VARIANT)
  79. else
  80. HOST_BUILD_DIR:=$(HOST_BUILD_DIR)-$(GCC_VARIANT)
  81. GCC_BUILD_DIR:=$(HOST_BUILD_DIR)
  82. endif
  83. HOST_STAMP_PREPARED:=$(HOST_BUILD_DIR)/.prepared
  84. HOST_STAMP_BUILT:=$(GCC_BUILD_DIR)/.built
  85. HOST_STAMP_CONFIGURED:=$(GCC_BUILD_DIR)/.configured
  86. HOST_STAMP_INSTALLED:=$(STAGING_DIR_HOST)/stamp/.gcc_$(GCC_VARIANT)_installed
  87. SEP:=,
  88. TARGET_LANGUAGES:="c,c++$(if $(CONFIG_INSTALL_LIBGCJ),$(SEP)java)$(if $(CONFIG_INSTALL_GFORTRAN),$(SEP)fortran)"
  89. export libgcc_cv_fixed_point=no
  90. ifdef CONFIG_USE_UCLIBC
  91. export glibcxx_cv_c99_math_tr1=no
  92. endif
  93. GCC_CONFIGURE:= \
  94. SHELL="$(BASH)" \
  95. $(if $(shell gcc --version 2>&1 | grep LLVM), \
  96. CFLAGS="-O2 -fbracket-depth=512 -pipe" \
  97. CXXFLAGS="-O2 -fbracket-depth=512 -pipe" \
  98. ) \
  99. $(HOST_SOURCE_DIR)/configure \
  100. --with-bugurl=$(BUGURL) \
  101. --with-pkgversion="$(PKGVERSION)" \
  102. --prefix=$(TOOLCHAIN_DIR) \
  103. --build=$(GNU_HOST_NAME) \
  104. --host=$(GNU_HOST_NAME) \
  105. --target=$(REAL_GNU_TARGET_NAME) \
  106. --with-gnu-ld \
  107. --enable-target-optspace \
  108. --disable-libgomp \
  109. --disable-libmudflap \
  110. --disable-multilib \
  111. --disable-nls \
  112. $(GRAPHITE_CONFIGURE) \
  113. --with-host-libstdcxx=-lstdc++ \
  114. $(SOFT_FLOAT_CONFIG_OPTION) \
  115. $(call qstrip,$(CONFIG_EXTRA_GCC_CONFIG_OPTIONS)) \
  116. $(if $(CONFIG_mips64)$(CONFIG_mips64el),--with-arch=mips64 \
  117. --with-abi=$(subst ",,$(CONFIG_MIPS64_ABI))) \
  118. --with-gmp=$(TOPDIR)/staging_dir/host \
  119. --with-mpfr=$(TOPDIR)/staging_dir/host \
  120. --with-mpc=$(TOPDIR)/staging_dir/host \
  121. --disable-decimal-float
  122. ifneq ($(CONFIG_mips)$(CONFIG_mipsel),)
  123. GCC_CONFIGURE += --with-mips-plt
  124. endif
  125. ifneq ($(CONFIG_SSP_SUPPORT),)
  126. GCC_CONFIGURE+= \
  127. --enable-libssp
  128. else
  129. GCC_CONFIGURE+= \
  130. --disable-libssp
  131. endif
  132. ifneq ($(CONFIG_EXTRA_TARGET_ARCH),)
  133. GCC_CONFIGURE+= \
  134. --enable-biarch \
  135. --enable-targets=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-linux-$(TARGET_SUFFIX)
  136. endif
  137. ifdef CONFIG_sparc
  138. GCC_CONFIGURE+= \
  139. --enable-targets=all \
  140. --with-long-double-128
  141. endif
  142. ifeq ($(LIBC),uClibc)
  143. GCC_CONFIGURE+= \
  144. --disable-__cxa_atexit
  145. else
  146. GCC_CONFIGURE+= \
  147. --enable-__cxa_atexit
  148. endif
  149. ifneq ($(GCC_ARCH),)
  150. GCC_CONFIGURE+= --with-arch=$(GCC_ARCH)
  151. endif
  152. ifneq ($(CONFIG_SOFT_FLOAT),y)
  153. ifeq ($(CONFIG_arm),y)
  154. GCC_CONFIGURE+= \
  155. --with-float=hard
  156. endif
  157. endif
  158. GCC_MAKE:= \
  159. export SHELL="$(BASH)"; \
  160. $(MAKE) \
  161. CFLAGS="$(HOST_CFLAGS)" \
  162. CFLAGS_FOR_TARGET="$(TARGET_CFLAGS)" \
  163. CXXFLAGS_FOR_TARGET="$(TARGET_CFLAGS)"
  164. define Host/Prepare
  165. mkdir -p $(GCC_BUILD_DIR)
  166. endef
  167. define Host/Configure
  168. (cd $(GCC_BUILD_DIR) && rm -f config.cache; \
  169. $(GCC_CONFIGURE) \
  170. );
  171. endef
  172. define Host/Clean
  173. rm -rf \
  174. $(STAGING_DIR_HOST)/stamp/.gcc_* \
  175. $(STAGING_DIR_HOST)/stamp/.binutils_* \
  176. $(GCC_BUILD_DIR) \
  177. $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
  178. $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME) \
  179. $(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gc* \
  180. $(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-c*
  181. endef