Makefile 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. );
  64. endef
  65. define Stage1/Compile
  66. export SHELL="$(BASH)"; $(MAKE) -C $(BUILD_DIR1) all-gcc
  67. endef
  68. define Stage1/Install
  69. export SHELL="$(BASH)"; $(MAKE) -C $(BUILD_DIR1) install-gcc
  70. endef
  71. define Stage2/Configure
  72. mkdir -p $(BUILD_DIR2)
  73. # Important! Required for limits.h to be fixed.
  74. rm -rf $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
  75. ln -sf ../include $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
  76. rm -rf $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib
  77. ln -sf ../lib $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib
  78. (cd $(BUILD_DIR2); rm -f config.cache; \
  79. SHELL="$(BASH)" \
  80. $(PKG_BUILD_DIR)/configure \
  81. --prefix=$(STAGING_DIR) \
  82. --build=$(GNU_HOST_NAME) \
  83. --host=$(GNU_HOST_NAME) \
  84. --target=$(REAL_GNU_TARGET_NAME) \
  85. --enable-languages=$(TARGET_LANGUAGES) \
  86. --enable-shared \
  87. --disable-__cxa_atexit \
  88. --enable-target-optspace \
  89. --with-gnu-ld \
  90. --disable-nls \
  91. );
  92. endef
  93. define Stage2/Compile
  94. export SHELL="$(BASH)"; $(MAKE) -C $(BUILD_DIR2) all
  95. endef
  96. define Stage2/Install
  97. export SHELL="$(BASH)"; $(MAKE) -C $(BUILD_DIR2) install
  98. echo $(PKG_VERSION) > $(STAGING_DIR)/gcc_version
  99. # Set up the symlinks to enable lying about target name.
  100. set -e; \
  101. (cd $(STAGING_DIR); \
  102. ln -sf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
  103. cd bin; \
  104. for app in $(REAL_GNU_TARGET_NAME)-* ; do \
  105. ln -sf $$$${app} \
  106. $(GNU_TARGET_NAME)$$$${app##$(REAL_GNU_TARGET_NAME)}; \
  107. done; \
  108. );
  109. endef
  110. define Build/Prepare
  111. $(call Build/Prepare/Default)
  112. $(SCRIPT_DIR)/patch-kernel.sh $(PKG_BUILD_DIR) $(PATCH_DIR) \*.patch
  113. $(SED) 's,\(version_string.. = "[0-9\.]*\).*\(";\),\1 (OpenWrt-2.0)\2,' $(PKG_BUILD_DIR)/gcc/version.c
  114. $(SED) 's,\(bug_report_url.. = "\).*\(";\),\1<URL:https://dev.openwrt.org/>\2,' $(PKG_BUILD_DIR)/gcc/version.c
  115. (cd $(PKG_BUILD_DIR)/libstdc++-v3; autoconf;);
  116. endef
  117. define Build/Configure
  118. $(call Stage1/Configure)
  119. endef
  120. define Build/Compile
  121. $(call Stage1/Compile)
  122. $(call Stage1/Install)
  123. endef
  124. define Build/Install
  125. $(call Stage2/Configure)
  126. $(call Stage2/Compile)
  127. $(call Stage2/Install)
  128. endef
  129. define Build/Clean
  130. rm -rf $(PKG_BUILD_DIR)
  131. rm -rf $(BUILD_DIR1)
  132. rm -rf $(BUILD_DIR2)
  133. rm -f $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gc*
  134. rm -f $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-c*
  135. endef
  136. $(eval $(call HostBuild))