common.mk 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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-2011 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. ifdef CONFIG_GCC_VERSION_LLVM
  26. PKG_SOURCE_VERSION:=c98c494b72ff875884c0c7286be67f16f9f6d7ab
  27. PKG_REV:=83504
  28. GCC_DIR:=llvm-gcc-4.2-r$(PKG_REV)
  29. PKG_VERSION:=4.2.1
  30. PKG_SOURCE:=$(GCC_DIR).tar.gz
  31. PKG_SOURCE_PROTO:=git
  32. PKG_SOURCE_URL:=git://repo.or.cz/llvm-gcc-4.2.git
  33. PKG_SOURCE_SUBDIR:=$(GCC_DIR)
  34. HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(GCC_DIR)
  35. else
  36. ifeq ($(CONFIG_GCC_VERSION),"linaro")
  37. PKG_REV:=4.5-2011.06-0
  38. PKG_VERSION:=4.5.4
  39. PKG_SOURCE_URL:=http://launchpad.net/gcc-linaro/4.5/$(PKG_REV)/+download/
  40. PKG_SOURCE:=$(PKG_NAME)-linaro-$(PKG_REV).tar.bz2
  41. PKG_MD5SUM:=34562e19a3ea5baf05a2046c7da0a00b
  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.6)
  48. PKG_MD5SUM:=ab525d429ee4425050a554bc9247d6c4
  49. endif
  50. ifeq ($(PKG_VERSION),4.6.1)
  51. PKG_MD5SUM:=c57a9170c677bf795bdc04ed796ca491
  52. endif
  53. endif
  54. endif
  55. PATCH_DIR=../patches/$(GCC_VERSION)
  56. BUGURL=https://dev.openwrt.org/
  57. include $(INCLUDE_DIR)/toolchain-build.mk
  58. HOST_SOURCE_DIR:=$(HOST_BUILD_DIR)
  59. ifeq ($(GCC_VARIANT),minimal)
  60. GCC_BUILD_DIR:=$(HOST_BUILD_DIR)-$(GCC_VARIANT)
  61. else
  62. HOST_BUILD_DIR:=$(HOST_BUILD_DIR)-$(GCC_VARIANT)
  63. GCC_BUILD_DIR:=$(HOST_BUILD_DIR)
  64. endif
  65. HOST_STAMP_PREPARED:=$(HOST_BUILD_DIR)/.prepared
  66. HOST_STAMP_BUILT:=$(GCC_BUILD_DIR)/.built
  67. HOST_STAMP_CONFIGURED:=$(GCC_BUILD_DIR)/.configured
  68. HOST_STAMP_INSTALLED:=$(STAGING_DIR_HOST)/stamp/.gcc_$(GCC_VARIANT)_installed
  69. SEP:=,
  70. TARGET_LANGUAGES:="c$(if $(CONFIG_INSTALL_LIBSTDCPP),$(SEP)c++)$(if $(CONFIG_INSTALL_LIBGCJ),$(SEP)java)$(if $(CONFIG_INSTALL_GFORTRAN),$(SEP)fortran)"
  71. export libgcc_cv_fixed_point=no
  72. ifdef CONFIG_USE_UCLIBC
  73. export glibcxx_cv_c99_math_tr1=no
  74. endif
  75. GCC_CONFIGURE:= \
  76. SHELL="$(BASH)" \
  77. $(HOST_SOURCE_DIR)/configure \
  78. --prefix=$(TOOLCHAIN_DIR) \
  79. --build=$(GNU_HOST_NAME) \
  80. --host=$(GNU_HOST_NAME) \
  81. --target=$(REAL_GNU_TARGET_NAME) \
  82. --with-gnu-ld \
  83. --enable-target-optspace \
  84. --disable-libgomp \
  85. --disable-libmudflap \
  86. --disable-multilib \
  87. --disable-nls \
  88. $(GRAPHITE_CONFIGURE) \
  89. $(if $(CONFIG_GCC_USE_GRAPHITE),--with-host-libstdcxx=-lstdc++) \
  90. $(SOFT_FLOAT_CONFIG_OPTION) \
  91. $(call qstrip,$(CONFIG_EXTRA_GCC_CONFIG_OPTIONS)) \
  92. $(if $(CONFIG_mips64)$(CONFIG_mips64el),--with-arch=mips64 --with-abi=64) \
  93. $(if $(CONFIG_GCC_VERSION_LLVM),--enable-llvm=$(BUILD_DIR_BASE)/host/llvm) \
  94. ifeq ($(CONFIG_GCC_LLVM),)
  95. GCC_BUILD_TARGET_LIBGCC:=y
  96. GCC_CONFIGURE+= \
  97. --with-gmp=$(TOPDIR)/staging_dir/host \
  98. --with-mpfr=$(TOPDIR)/staging_dir/host \
  99. --disable-decimal-float
  100. ifneq ($(CONFIG_mips)$(CONFIG_mipsel),)
  101. GCC_CONFIGURE += --with-mips-plt
  102. endif
  103. endif
  104. ifneq ($(CONFIG_GCC_VERSION_4_5)$(CONFIG_GCC_VERSION_4_6),)
  105. GCC_CONFIGURE+= \
  106. --with-mpc=$(TOPDIR)/staging_dir/host
  107. endif
  108. ifneq ($(CONFIG_SSP_SUPPORT),)
  109. GCC_CONFIGURE+= \
  110. --enable-libssp
  111. else
  112. GCC_CONFIGURE+= \
  113. --disable-libssp
  114. endif
  115. ifneq ($(CONFIG_EXTRA_TARGET_ARCH),)
  116. GCC_CONFIGURE+= \
  117. --enable-biarch \
  118. --enable-targets=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-linux-$(TARGET_SUFFIX)
  119. endif
  120. ifdef CONFIG_sparc
  121. GCC_CONFIGURE+= --enable-targets=all
  122. endif
  123. ifeq ($(LIBC),uClibc)
  124. GCC_CONFIGURE+= \
  125. --disable-__cxa_atexit
  126. else
  127. GCC_CONFIGURE+= \
  128. --enable-__cxa_atexit
  129. endif
  130. ifdef CONFIG_powerpc
  131. TARGET_CFLAGS := $(patsubst -Os,-O2,$(TARGET_CFLAGS))
  132. endif
  133. ifneq ($(GCC_ARCH),)
  134. GCC_CONFIGURE+= --with-arch=$(GCC_ARCH)
  135. endif
  136. GCC_MAKE:= \
  137. export SHELL="$(BASH)"; \
  138. $(MAKE) $(TOOLCHAIN_JOBS) \
  139. CFLAGS_FOR_TARGET="$(TARGET_CFLAGS)" \
  140. CXXFLAGS_FOR_TARGET="$(TARGET_CFLAGS)"
  141. define Host/Prepare
  142. mkdir -p $(GCC_BUILD_DIR)
  143. endef
  144. define Host/Configure
  145. (cd $(GCC_BUILD_DIR) && rm -f config.cache; \
  146. $(GCC_CONFIGURE) \
  147. );
  148. endef
  149. define Host/Clean
  150. rm -rf \
  151. $(STAGING_DIR_HOST)/stamp/.gcc_* \
  152. $(STAGING_DIR_HOST)/stamp/.binutils_* \
  153. $(GCC_BUILD_DIR) \
  154. $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
  155. $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME) \
  156. $(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gc* \
  157. $(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-c*
  158. endef