common.mk 5.9 KB

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