binutils.mk 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. #############################################################
  2. #
  3. # build binutils for use on the host system
  4. #
  5. #############################################################
  6. BINUTILS_VERSION:=$(strip $(subst ",, $(BR2_BINUTILS_VERSION)))
  7. BINUTILS_SITE:=http://ftp.kernel.org/pub/linux/devel/binutils
  8. ifeq ($(BINUTILS_VERSION),2.16)
  9. BINUTILS_SITE:=http://ftp.gnu.org/gnu/binutils/
  10. endif
  11. ifeq ($(BINUTILS_VERSION),2.16.1)
  12. BINUTILS_SITE:=http://ftp.gnu.org/gnu/binutils/
  13. endif
  14. ifeq ($(BINUTILS_VERSION),2.15)
  15. BINUTILS_SITE:=http://ftp.gnu.org/gnu/binutils/
  16. endif
  17. ifeq ($(BINUTILS_VERSION),2.14)
  18. BINUTILS_SITE:=http://ftp.gnu.org/gnu/binutils/
  19. endif
  20. ifeq ($(BINUTILS_VERSION),2.13)
  21. BINUTILS_SITE:=http://ftp.gnu.org/gnu/binutils/
  22. endif
  23. ifeq ($(BINUTILS_VERSION),2.15.97)
  24. BINUTILS_SITE:=ftp://sources.redhat.com/pub/binutils/snapshots/
  25. endif
  26. BINUTILS_SOURCE:=binutils-$(BINUTILS_VERSION).tar.bz2
  27. BINUTILS_DIR:=$(TOOL_BUILD_DIR)/binutils-$(BINUTILS_VERSION)
  28. BINUTILS_CAT:=bzcat
  29. BINUTILS_DIR1:=$(TOOL_BUILD_DIR)/binutils-$(BINUTILS_VERSION)-build
  30. $(DL_DIR)/$(BINUTILS_SOURCE):
  31. mkdir -p $(DL_DIR)
  32. $(WGET) -P $(DL_DIR) $(BINUTILS_SITE)/$(BINUTILS_SOURCE)
  33. $(BINUTILS_DIR)/.unpacked: $(DL_DIR)/$(BINUTILS_SOURCE)
  34. mkdir -p $(TOOL_BUILD_DIR)
  35. $(BINUTILS_CAT) $(DL_DIR)/$(BINUTILS_SOURCE) | tar -C $(TOOL_BUILD_DIR) $(TAR_OPTIONS) -
  36. $(CONFIG_UPDATE) $(BINUTILS_DIR)
  37. touch $(BINUTILS_DIR)/.unpacked
  38. $(BINUTILS_DIR)/.patched: $(BINUTILS_DIR)/.unpacked
  39. # Apply appropriate binutils patches.
  40. toolchain/patch-kernel.sh $(BINUTILS_DIR) toolchain/binutils/$(BINUTILS_VERSION) \*.patch
  41. touch $(BINUTILS_DIR)/.patched
  42. $(BINUTILS_DIR1)/.configured: $(BINUTILS_DIR)/.patched
  43. mkdir -p $(BINUTILS_DIR1)
  44. (cd $(BINUTILS_DIR1); \
  45. $(BINUTILS_DIR)/configure \
  46. --prefix=$(STAGING_DIR) \
  47. --build=$(GNU_HOST_NAME) \
  48. --host=$(GNU_HOST_NAME) \
  49. --target=$(REAL_GNU_TARGET_NAME) \
  50. $(DISABLE_NLS) \
  51. $(MULTILIB) \
  52. --disable-werror \
  53. $(SOFT_FLOAT_CONFIG_OPTION) );
  54. touch $(BINUTILS_DIR1)/.configured
  55. $(BINUTILS_DIR1)/binutils/objdump: $(BINUTILS_DIR1)/.configured
  56. $(MAKE) -C $(BINUTILS_DIR1) all
  57. # Make install will put gettext data in staging_dir/share/locale.
  58. # Unfortunatey, it isn't configureable.
  59. $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/bin/ld: $(BINUTILS_DIR1)/binutils/objdump
  60. $(MAKE) -C $(BINUTILS_DIR1) install
  61. binutils-dependancies:
  62. @if ! which which > /dev/null ; then \
  63. echo -e "\n\nYou must install 'which' on your build machine\n"; \
  64. exit 1; \
  65. fi;
  66. @if ! which bison > /dev/null ; then \
  67. echo -e "\n\nYou must install 'bison' on your build machine\n"; \
  68. exit 1; \
  69. fi;
  70. @if ! which flex > /dev/null ; then \
  71. echo -e "\n\nYou must install 'flex' on your build machine\n"; \
  72. exit 1; \
  73. fi;
  74. @if ! which msgfmt > /dev/null ; then \
  75. echo -e "\n\nYou must install 'gettext' on your build machine\n"; \
  76. exit 1; \
  77. fi;
  78. binutils: binutils-dependancies $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/bin/ld
  79. binutils-source: $(DL_DIR)/$(BINUTILS_SOURCE)
  80. binutils-clean:
  81. rm -f $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)*
  82. -$(MAKE) -C $(BINUTILS_DIR1) clean
  83. binutils-dirclean:
  84. rm -rf $(BINUTILS_DIR1)
  85. #############################################################
  86. #
  87. # build binutils for use on the target system
  88. #
  89. #############################################################
  90. BINUTILS_DIR2:=$(BUILD_DIR)/binutils-$(BINUTILS_VERSION)-target
  91. $(BINUTILS_DIR2)/.configured: $(BINUTILS_DIR)/.patched
  92. mkdir -p $(BINUTILS_DIR2)
  93. (cd $(BINUTILS_DIR2); \
  94. PATH=$(TARGET_PATH) \
  95. CFLAGS="$(TARGET_CFLAGS)" \
  96. CFLAGS_FOR_BUILD="-O2 -g" \
  97. $(BINUTILS_DIR)/configure \
  98. --prefix=/usr \
  99. --exec-prefix=/usr \
  100. --build=$(GNU_HOST_NAME) \
  101. --host=$(REAL_GNU_TARGET_NAME) \
  102. --target=$(REAL_GNU_TARGET_NAME) \
  103. $(DISABLE_NLS) \
  104. $(MULTILIB) \
  105. --disable-werror \
  106. $(SOFT_FLOAT_CONFIG_OPTION) );
  107. touch $(BINUTILS_DIR2)/.configured
  108. $(BINUTILS_DIR2)/binutils/objdump: $(BINUTILS_DIR2)/.configured
  109. PATH=$(TARGET_PATH) \
  110. $(MAKE) -C $(BINUTILS_DIR2) all
  111. $(TARGET_DIR)/usr/bin/ld: $(BINUTILS_DIR2)/binutils/objdump
  112. PATH=$(TARGET_PATH) \
  113. $(MAKE) DESTDIR=$(TARGET_DIR) \
  114. tooldir=/usr build_tooldir=/usr \
  115. -C $(BINUTILS_DIR2) install
  116. #rm -rf $(TARGET_DIR)/share/locale $(TARGET_DIR)/usr/info \
  117. # $(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/doc
  118. -$(STRIP) $(TARGET_DIR)/usr/$(REAL_GNU_TARGET_NAME)/bin/* > /dev/null 2>&1
  119. -$(STRIP) $(TARGET_DIR)/usr/bin/* > /dev/null 2>&1
  120. binutils_target: $(GCC_DEPENDANCY) $(TARGET_DIR)/usr/bin/ld
  121. binutils_target-clean:
  122. (cd $(TARGET_DIR)/usr/bin; \
  123. rm -f addr2line ar as gprof ld nm objcopy \
  124. objdump ranlib readelf size strings strip)
  125. rm -f $(TARGET_DIR)/bin/$(REAL_GNU_TARGET_NAME)*
  126. -$(MAKE) -C $(BINUTILS_DIR2) clean
  127. binutils_target-dirclean:
  128. rm -rf $(BINUTILS_DIR2)