binutils.mk 4.8 KB

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