common.mk 5.4 KB

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