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