common.mk 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. ifeq ($(findstring linaro, $(CONFIG_GCC_VERSION)),linaro)
  26. ifeq ($(CONFIG_GCC_VERSION),"4.6-linaro")
  27. PKG_REV:=4.6-2013.05
  28. PKG_VERSION:=4.6.4
  29. PKG_VERSION_MAJOR:=4.6
  30. PKG_MD5SUM:=26b48802ae1203cd99415026fbf56ed7
  31. PKG_COMP:=bz2
  32. endif
  33. ifeq ($(CONFIG_GCC_VERSION),"4.8-linaro")
  34. PKG_REV:=4.8-2014.04
  35. PKG_VERSION:=4.8.3
  36. PKG_VERSION_MAJOR:=4.8
  37. PKG_MD5SUM:=5ba2f3a449b1658ccc09d27cc7ab3c03
  38. PKG_COMP:=xz
  39. endif
  40. PKG_SOURCE_URL:=http://launchpad.net/gcc-linaro/$(PKG_VERSION_MAJOR)/$(PKG_REV)/+download/
  41. PKG_SOURCE:=$(PKG_NAME)-linaro-$(PKG_REV).tar.$(PKG_COMP)
  42. GCC_DIR:=gcc-linaro-$(PKG_REV)
  43. HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(GCC_DIR)
  44. else
  45. PKG_SOURCE_URL:=@GNU/gcc/gcc-$(PKG_VERSION)
  46. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
  47. ifeq ($(PKG_VERSION),4.4.7)
  48. PKG_MD5SUM:=295709feb4441b04e87dea3f1bab4281
  49. endif
  50. ifeq ($(PKG_VERSION),4.6.3)
  51. PKG_MD5SUM:=773092fe5194353b02bb0110052a972e
  52. endif
  53. ifeq ($(PKG_VERSION),4.8.0)
  54. PKG_MD5SUM:=e6040024eb9e761c3bea348d1fa5abb0
  55. endif
  56. endif
  57. PATCH_DIR=../patches/$(GCC_VERSION)
  58. BUGURL=https://dev.openwrt.org/
  59. ifeq ($(findstring linaro, $(CONFIG_GCC_VERSION)),linaro)
  60. PKGVERSION=OpenWrt/Linaro GCC $(PKG_REV) $(REVISION)
  61. else
  62. PKGVERSION=OpenWrt GCC $(PKG_VERSION) $(REVISION)
  63. endif
  64. HOST_BUILD_PARALLEL:=1
  65. include $(INCLUDE_DIR)/toolchain-build.mk
  66. HOST_SOURCE_DIR:=$(HOST_BUILD_DIR)
  67. ifeq ($(GCC_VARIANT),minimal)
  68. GCC_BUILD_DIR:=$(HOST_BUILD_DIR)-$(GCC_VARIANT)
  69. else
  70. HOST_BUILD_DIR:=$(HOST_BUILD_DIR)-$(GCC_VARIANT)
  71. GCC_BUILD_DIR:=$(HOST_BUILD_DIR)
  72. endif
  73. HOST_STAMP_PREPARED:=$(HOST_BUILD_DIR)/.prepared
  74. HOST_STAMP_BUILT:=$(GCC_BUILD_DIR)/.built
  75. HOST_STAMP_CONFIGURED:=$(GCC_BUILD_DIR)/.configured
  76. HOST_STAMP_INSTALLED:=$(STAGING_DIR_HOST)/stamp/.gcc_$(GCC_VARIANT)_installed
  77. SEP:=,
  78. TARGET_LANGUAGES:="c,c++$(if $(CONFIG_INSTALL_LIBGCJ),$(SEP)java)$(if $(CONFIG_INSTALL_GFORTRAN),$(SEP)fortran)"
  79. export libgcc_cv_fixed_point=no
  80. ifdef CONFIG_USE_UCLIBC
  81. export glibcxx_cv_c99_math_tr1=no
  82. endif
  83. GCC_CONFIGURE:= \
  84. SHELL="$(BASH)" \
  85. $(if $(shell gcc --version 2>&1 | grep LLVM), \
  86. CFLAGS="-O2 -fbracket-depth=512 -pipe" \
  87. CXXFLAGS="-O2 -fbracket-depth=512 -pipe" \
  88. ) \
  89. $(HOST_SOURCE_DIR)/configure \
  90. --with-bugurl=$(BUGURL) \
  91. --with-pkgversion="$(PKGVERSION)" \
  92. --prefix=$(TOOLCHAIN_DIR) \
  93. --build=$(GNU_HOST_NAME) \
  94. --host=$(GNU_HOST_NAME) \
  95. --target=$(REAL_GNU_TARGET_NAME) \
  96. --with-gnu-ld \
  97. --enable-target-optspace \
  98. --disable-libgomp \
  99. --disable-libmudflap \
  100. --disable-multilib \
  101. --disable-nls \
  102. $(GRAPHITE_CONFIGURE) \
  103. --with-host-libstdcxx=-lstdc++ \
  104. $(SOFT_FLOAT_CONFIG_OPTION) \
  105. $(call qstrip,$(CONFIG_EXTRA_GCC_CONFIG_OPTIONS)) \
  106. $(if $(CONFIG_mips64)$(CONFIG_mips64el),--with-arch=mips64 \
  107. --with-abi=$(subst ",,$(CONFIG_MIPS64_ABI))) \
  108. --with-gmp=$(TOPDIR)/staging_dir/host \
  109. --with-mpfr=$(TOPDIR)/staging_dir/host \
  110. --disable-decimal-float
  111. ifneq ($(CONFIG_mips)$(CONFIG_mipsel),)
  112. GCC_CONFIGURE += --with-mips-plt
  113. endif
  114. ifeq ($(CONFIG_GCC_VERSION_4_4),)
  115. GCC_CONFIGURE+= \
  116. --with-mpc=$(TOPDIR)/staging_dir/host
  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. GCC_MAKE:= \
  146. export SHELL="$(BASH)"; \
  147. $(MAKE) \
  148. CFLAGS="$(HOST_CFLAGS)" \
  149. CFLAGS_FOR_TARGET="$(TARGET_CFLAGS)" \
  150. CXXFLAGS_FOR_TARGET="$(TARGET_CFLAGS)"
  151. define Host/Prepare
  152. mkdir -p $(GCC_BUILD_DIR)
  153. endef
  154. define Host/Configure
  155. (cd $(GCC_BUILD_DIR) && rm -f config.cache; \
  156. $(GCC_CONFIGURE) \
  157. );
  158. endef
  159. define Host/Clean
  160. rm -rf \
  161. $(STAGING_DIR_HOST)/stamp/.gcc_* \
  162. $(STAGING_DIR_HOST)/stamp/.binutils_* \
  163. $(GCC_BUILD_DIR) \
  164. $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
  165. $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME) \
  166. $(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gc* \
  167. $(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-c*
  168. endef