Makefile 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. # Makefile for to build a gcc/uClibc toolchain
  2. #
  3. # Copyright (C) 2002-2003 Erik Andersen <[email protected]>
  4. # Copyright (C) 2004 Manuel Novoa III <[email protected]>
  5. # Copyright (C) 2005-2006 Felix Fietkau <[email protected]>
  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. PKG_VERSION:=$(strip $(subst ",, $(CONFIG_GCC_VERSION)))#"))
  23. ifeq ($(PKG_VERSION),4.2)
  24. PKG_VERSION:=20060709
  25. PKG_SOURCE_URL:=http://downloads.openwrt.org/sources
  26. PATCH_DIR=./patches/4.2
  27. else
  28. PATCH_DIR=./patches/$(PKG_VERSION)
  29. PKG_SOURCE_URL:=ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-$(PKG_VERSION) \
  30. http://mirrors.rcn.net/pub/sourceware/gcc/releases/gcc-$(PKG_VERSION) \
  31. ftp://ftp.gnu.org/gnu/gcc/releases/gcc-$(PKG_VERSION)
  32. endif
  33. PKG_SOURCE:=gcc-$(PKG_VERSION).tar.bz2
  34. PKG_MD5SUM:=unknown
  35. PKG_CAT:=bzcat
  36. PKG_BUILD_DIR:=$(TOOLCHAIN_BUILD_DIR)/gcc-$(PKG_VERSION)
  37. TARGET_LANGUAGES:=c
  38. ifeq ($(CONFIG_INSTALL_LIBSTDCPP),y)
  39. TARGET_LANGUAGES:=$(TARGET_LANGUAGES),c++
  40. endif
  41. ifeq ($(CONFIG_INSTALL_LIBGCJ),y)
  42. TARGET_LANGUAGES:=$(TARGET_LANGUAGES),java
  43. endif
  44. include $(INCLUDE_DIR)/host-build.mk
  45. BUILD_DIR1:=$(TOOLCHAIN_BUILD_DIR)/gcc-$(PKG_VERSION)-initial
  46. BUILD_DIR2:=$(TOOLCHAIN_BUILD_DIR)/gcc-$(PKG_VERSION)-final
  47. define Stage1/Configure
  48. mkdir -p $(BUILD_DIR1)
  49. (cd $(BUILD_DIR1); rm -f config.cache; \
  50. SHELL="$(BASH)" \
  51. $(PKG_BUILD_DIR)/configure \
  52. --prefix=$(STAGING_DIR) \
  53. --build=$(GNU_HOST_NAME) \
  54. --host=$(GNU_HOST_NAME) \
  55. --target=$(REAL_GNU_TARGET_NAME) \
  56. --enable-languages=c \
  57. --disable-shared \
  58. --with-sysroot=$(TOOLCHAIN_BUILD_DIR)/uClibc_dev/ \
  59. --disable-__cxa_atexit \
  60. --enable-target-optspace \
  61. --with-gnu-ld \
  62. --disable-nls \
  63. --disable-libmudflap \
  64. );
  65. endef
  66. define Stage1/Compile
  67. export SHELL="$(BASH)"; $(MAKE) -C $(BUILD_DIR1) all-gcc
  68. endef
  69. define Stage1/Install
  70. export SHELL="$(BASH)"; $(MAKE) -C $(BUILD_DIR1) install-gcc
  71. endef
  72. define Stage2/Configure
  73. mkdir -p $(BUILD_DIR2)
  74. # Important! Required for limits.h to be fixed.
  75. rm -rf $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
  76. ln -sf ../include $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
  77. rm -rf $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib
  78. ln -sf ../lib $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib
  79. (cd $(BUILD_DIR2); rm -f config.cache; \
  80. SHELL="$(BASH)" \
  81. $(PKG_BUILD_DIR)/configure \
  82. --prefix=$(STAGING_DIR) \
  83. --build=$(GNU_HOST_NAME) \
  84. --host=$(GNU_HOST_NAME) \
  85. --target=$(REAL_GNU_TARGET_NAME) \
  86. --enable-languages=$(TARGET_LANGUAGES) \
  87. --enable-shared \
  88. --disable-__cxa_atexit \
  89. --enable-target-optspace \
  90. --with-gnu-ld \
  91. --disable-nls \
  92. --disable-libmudflap \
  93. );
  94. endef
  95. define Stage2/Compile
  96. export SHELL="$(BASH)"; $(MAKE) -C $(BUILD_DIR2) all
  97. endef
  98. define Stage2/Install
  99. export SHELL="$(BASH)"; $(MAKE) -C $(BUILD_DIR2) install
  100. echo $(PKG_VERSION) > $(STAGING_DIR)/gcc_version
  101. # Set up the symlinks to enable lying about target name.
  102. set -e; \
  103. (cd $(STAGING_DIR); \
  104. ln -sf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
  105. cd bin; \
  106. for app in $(REAL_GNU_TARGET_NAME)-* ; do \
  107. ln -sf $$$${app} \
  108. $(GNU_TARGET_NAME)$$$${app##$(REAL_GNU_TARGET_NAME)}; \
  109. done; \
  110. );
  111. endef
  112. define Build/Prepare
  113. $(call Build/Prepare/Default)
  114. $(SCRIPT_DIR)/patch-kernel.sh $(PKG_BUILD_DIR) $(PATCH_DIR) \*.patch
  115. $(SED) 's,\(version_string.. = "[0-9\.]*\).*\(";\),\1 (OpenWrt-2.0)\2,' $(PKG_BUILD_DIR)/gcc/version.c
  116. $(SED) 's,\(bug_report_url.. = "\).*\(";\),\1<URL:https://dev.openwrt.org/>\2,' $(PKG_BUILD_DIR)/gcc/version.c
  117. (cd $(PKG_BUILD_DIR)/libstdc++-v3; autoconf;);
  118. endef
  119. define Build/Configure
  120. $(call Stage1/Configure)
  121. endef
  122. define Build/Compile
  123. $(call Stage1/Compile)
  124. $(call Stage1/Install)
  125. endef
  126. define Build/Install
  127. $(call Stage2/Configure)
  128. $(call Stage2/Compile)
  129. $(call Stage2/Install)
  130. endef
  131. define Build/Clean
  132. rm -rf $(PKG_BUILD_DIR)
  133. rm -rf $(BUILD_DIR1)
  134. rm -rf $(BUILD_DIR2)
  135. rm -f $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gc*
  136. rm -f $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-c*
  137. endef
  138. $(eval $(call HostBuild))