common.mk 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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.3.0)
  28. PKG_MD5SUM:=c9616fd448f980259c31de613e575719
  29. endif
  30. ifneq ($(CONFIG_GCC_VERSION_4_8_ARC),)
  31. PKG_VERSION:=4.8.5
  32. PKG_SOURCE_URL:=https://github.com/foss-for-synopsys-dwc-arc-processors/gcc/archive/arc-2016.03
  33. PKG_SOURCE:=$(PKG_NAME)-$(GCC_VERSION).tar.gz
  34. PKG_MD5SUM:=ca59c8140d6efd07b97a18869bddbb53
  35. PKG_REV:=2016.03
  36. GCC_DIR:=gcc-arc-$(PKG_REV)
  37. HOST_BUILD_DIR = $(BUILD_DIR_HOST)/$(PKG_NAME)-$(GCC_VERSION)
  38. endif
  39. PATCH_DIR=../patches/$(GCC_VERSION)
  40. BUGURL=https://dev.openwrt.org/
  41. ifeq ($(findstring linaro, $(CONFIG_GCC_VERSION)),linaro)
  42. PKGVERSION=OpenWrt/Linaro GCC $(PKG_REV) $(REVISION)
  43. else
  44. PKGVERSION=OpenWrt GCC $(PKG_VERSION) $(REVISION)
  45. endif
  46. HOST_BUILD_PARALLEL:=1
  47. include $(INCLUDE_DIR)/toolchain-build.mk
  48. HOST_SOURCE_DIR:=$(HOST_BUILD_DIR)
  49. ifeq ($(GCC_VARIANT),minimal)
  50. GCC_BUILD_DIR:=$(HOST_BUILD_DIR)-$(GCC_VARIANT)
  51. else
  52. HOST_BUILD_DIR:=$(HOST_BUILD_DIR)-$(GCC_VARIANT)
  53. GCC_BUILD_DIR:=$(HOST_BUILD_DIR)
  54. endif
  55. HOST_STAMP_PREPARED:=$(HOST_BUILD_DIR)/.prepared
  56. HOST_STAMP_BUILT:=$(GCC_BUILD_DIR)/.built
  57. HOST_STAMP_CONFIGURED:=$(GCC_BUILD_DIR)/.configured
  58. HOST_STAMP_INSTALLED:=$(STAGING_DIR_HOST)/stamp/.gcc_$(GCC_VARIANT)_installed
  59. SEP:=,
  60. TARGET_LANGUAGES:="c,c++$(if $(CONFIG_INSTALL_LIBGCJ),$(SEP)java)$(if $(CONFIG_INSTALL_GFORTRAN),$(SEP)fortran)"
  61. export libgcc_cv_fixed_point=no
  62. ifdef CONFIG_USE_UCLIBC
  63. export glibcxx_cv_c99_math_tr1=no
  64. endif
  65. ifdef CONFIG_GCC_USE_GRAPHITE
  66. ifdef CONFIG_GCC_VERSION_4_8
  67. GRAPHITE_CONFIGURE=--with-cloog=$(REAL_STAGING_DIR_HOST)
  68. else
  69. GRAPHITE_CONFIGURE=--with-isl=$(REAL_STAGING_DIR_HOST)
  70. endif
  71. else
  72. GRAPHITE_CONFIGURE=--without-isl --without-cloog
  73. endif
  74. GCC_CONFIGURE:= \
  75. SHELL="$(BASH)" \
  76. $(if $(shell gcc --version 2>&1 | grep LLVM), \
  77. CFLAGS="-O2 -fbracket-depth=512 -pipe" \
  78. CXXFLAGS="-O2 -fbracket-depth=512 -pipe" \
  79. ) \
  80. $(HOST_SOURCE_DIR)/configure \
  81. --with-bugurl=$(BUGURL) \
  82. --with-pkgversion="$(PKGVERSION)" \
  83. --prefix=$(TOOLCHAIN_DIR) \
  84. --build=$(GNU_HOST_NAME) \
  85. --host=$(GNU_HOST_NAME) \
  86. --target=$(REAL_GNU_TARGET_NAME) \
  87. --with-gnu-ld \
  88. --enable-target-optspace \
  89. --disable-libgomp \
  90. --disable-libmudflap \
  91. --disable-multilib \
  92. --disable-nls \
  93. $(GRAPHITE_CONFIGURE) \
  94. --with-host-libstdcxx=-lstdc++ \
  95. $(SOFT_FLOAT_CONFIG_OPTION) \
  96. $(call qstrip,$(CONFIG_EXTRA_GCC_CONFIG_OPTIONS)) \
  97. $(if $(CONFIG_mips64)$(CONFIG_mips64el),--with-arch=mips64 \
  98. --with-abi=$(call qstrip,$(CONFIG_MIPS64_ABI))) \
  99. $(if $(CONFIG_arc),--with-cpu=$(CONFIG_CPU_TYPE)) \
  100. --with-gmp=$(TOPDIR)/staging_dir/host \
  101. --with-mpfr=$(TOPDIR)/staging_dir/host \
  102. --with-mpc=$(TOPDIR)/staging_dir/host \
  103. --disable-decimal-float
  104. ifneq ($(CONFIG_mips)$(CONFIG_mipsel),)
  105. GCC_CONFIGURE += --with-mips-plt
  106. endif
  107. ifndef GCC_VERSION_4_8
  108. GCC_CONFIGURE += --with-diagnostics-color=auto-if-env
  109. endif
  110. ifneq ($(CONFIG_SSP_SUPPORT),)
  111. GCC_CONFIGURE+= \
  112. --enable-libssp
  113. else
  114. GCC_CONFIGURE+= \
  115. --disable-libssp
  116. endif
  117. ifneq ($(CONFIG_EXTRA_TARGET_ARCH),)
  118. GCC_CONFIGURE+= \
  119. --enable-biarch \
  120. --enable-targets=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-linux-$(TARGET_SUFFIX)
  121. endif
  122. ifdef CONFIG_sparc
  123. GCC_CONFIGURE+= \
  124. --enable-targets=all \
  125. --with-long-double-128
  126. endif
  127. ifeq ($(LIBC),uClibc)
  128. GCC_CONFIGURE+= \
  129. --disable-__cxa_atexit
  130. else
  131. GCC_CONFIGURE+= \
  132. --enable-__cxa_atexit
  133. endif
  134. ifneq ($(GCC_ARCH),)
  135. GCC_CONFIGURE+= --with-arch=$(GCC_ARCH)
  136. endif
  137. ifneq ($(CONFIG_SOFT_FLOAT),y)
  138. ifeq ($(CONFIG_arm),y)
  139. GCC_CONFIGURE+= \
  140. --with-float=hard
  141. endif
  142. endif
  143. GCC_MAKE:= \
  144. export SHELL="$(BASH)"; \
  145. $(MAKE) \
  146. CFLAGS="$(HOST_CFLAGS)" \
  147. CFLAGS_FOR_TARGET="$(TARGET_CFLAGS)" \
  148. CXXFLAGS_FOR_TARGET="$(TARGET_CFLAGS)"
  149. define Host/Prepare
  150. mkdir -p $(GCC_BUILD_DIR)
  151. endef
  152. define Host/Configure
  153. (cd $(GCC_BUILD_DIR) && rm -f config.cache; \
  154. $(GCC_CONFIGURE) \
  155. );
  156. endef
  157. define Host/Clean
  158. rm -rf \
  159. $(STAGING_DIR_HOST)/stamp/.gcc_* \
  160. $(STAGING_DIR_HOST)/stamp/.binutils_* \
  161. $(GCC_BUILD_DIR) \
  162. $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
  163. $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME) \
  164. $(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gc* \
  165. $(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-c*
  166. endef