c0d504d6dc90f0d239fc76f1f3b628cd002628e9
[openwrt.git] / openwrt / toolchain / binutils / binutils.mk
1 #############################################################
2 #
3 # build binutils for use on the host system
4 #
5 #############################################################
6 BINUTILS_VERSION:=$(strip $(subst ",, $(BR2_BINUTILS_VERSION)))
7
8 BINUTILS_SITE:=http://ftp.kernel.org/pub/linux/devel/binutils
9 ifeq ($(BINUTILS_VERSION),2.15)
10 BINUTILS_SITE:=http://ftp.gnu.org/gnu/binutils/
11 endif
12 ifeq ($(BINUTILS_VERSION),2.14)
13 BINUTILS_SITE:=http://ftp.gnu.org/gnu/binutils/
14 endif
15 ifeq ($(BINUTILS_VERSION),2.13)
16 BINUTILS_SITE:=http://ftp.gnu.org/gnu/binutils/
17 endif
18
19 BINUTILS_SOURCE:=binutils-$(BINUTILS_VERSION).tar.bz2
20 BINUTILS_DIR:=$(TOOL_BUILD_DIR)/binutils-$(BINUTILS_VERSION)
21 BINUTILS_CAT:=bzcat
22
23 BINUTILS_DIR1:=$(TOOL_BUILD_DIR)/binutils-$(BINUTILS_VERSION)-build
24
25 $(DL_DIR)/$(BINUTILS_SOURCE):
26 mkdir -p $(DL_DIR)
27 $(WGET) -P $(DL_DIR) $(BINUTILS_SITE)/$(BINUTILS_SOURCE)
28
29 $(BINUTILS_DIR)/.unpacked: $(DL_DIR)/$(BINUTILS_SOURCE)
30 mkdir -p $(TOOL_BUILD_DIR)
31 $(BINUTILS_CAT) $(DL_DIR)/$(BINUTILS_SOURCE) | tar -C $(TOOL_BUILD_DIR) $(TAR_OPTIONS) -
32 touch $(BINUTILS_DIR)/.unpacked
33
34 $(BINUTILS_DIR)/.patched: $(BINUTILS_DIR)/.unpacked
35 # Apply appropriate binutils patches.
36 $(SCRIPT_DIR)/patch-kernel.sh $(BINUTILS_DIR) ./$(BINUTILS_VERSION) \*.patch
37 touch $(BINUTILS_DIR)/.patched
38
39 $(BINUTILS_DIR1)/.configured: $(BINUTILS_DIR)/.patched
40 mkdir -p $(BINUTILS_DIR1)
41 (cd $(BINUTILS_DIR1); \
42 $(BINUTILS_DIR)/configure \
43 --prefix=$(STAGING_DIR) \
44 --build=$(GNU_HOST_NAME) \
45 --host=$(GNU_HOST_NAME) \
46 --target=$(REAL_GNU_TARGET_NAME) \
47 $(DISABLE_NLS) \
48 $(MULTILIB) \
49 $(SOFT_FLOAT_CONFIG_OPTION) );
50 touch $(BINUTILS_DIR1)/.configured
51
52 $(BINUTILS_DIR1)/binutils/objdump: $(BINUTILS_DIR1)/.configured
53 $(MAKE) -C $(BINUTILS_DIR1) all
54
55 # Make install will put gettext data in staging_dir/share/locale.
56 # Unfortunatey, it isn't configureable.
57 $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-ld: $(BINUTILS_DIR1)/binutils/objdump
58 $(MAKE) -C $(BINUTILS_DIR1) install
59
60 binutils-dependencies:
61 @if ! which bison > /dev/null ; then \
62 echo -e "\n\nYou must install 'bison' on your build machine\n"; \
63 exit 1; \
64 fi;
65 @if ! which flex > /dev/null ; then \
66 echo -e "\n\nYou must install 'flex' on your build machine\n"; \
67 exit 1; \
68 fi;
69 @if ! which msgfmt > /dev/null ; then \
70 echo -e "\n\nYou must install 'gettext' on your build machine\n"; \
71 exit 1; \
72 fi;
73
74 binutils: binutils-dependencies $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-ld
75
76 binutils-source: $(DL_DIR)/$(BINUTILS_SOURCE)
77
78 binutils-clean:
79 rm -f $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)*
80 -$(MAKE) -C $(BINUTILS_DIR1) clean
81
82 binutils-toolclean:
83 rm -rf $(BINUTILS_DIR1)
84
85 binutils-distclean:
86 rm -rf $(BINUTILS_DIR)
87
88
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 $(SOFT_FLOAT_CONFIG_OPTION) );
110 touch $(BINUTILS_DIR2)/.configured
111
112 $(BINUTILS_DIR2)/binutils/objdump: $(BINUTILS_DIR2)/.configured
113 PATH=$(TARGET_PATH) \
114 $(MAKE) -C $(BINUTILS_DIR2) all
115
116 $(TARGET_DIR)/usr/bin/ld: $(BINUTILS_DIR2)/binutils/objdump
117 PATH=$(TARGET_PATH) \
118 $(MAKE) DESTDIR=$(TARGET_DIR) \
119 tooldir=/usr build_tooldir=/usr \
120 -C $(BINUTILS_DIR2) install
121 #rm -rf $(TARGET_DIR)/share/locale $(TARGET_DIR)/usr/info \
122 # $(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/doc
123 -$(STRIP) $(TARGET_DIR)/usr/$(REAL_GNU_TARGET_NAME)/bin/* > /dev/null 2>&1
124 -$(STRIP) $(TARGET_DIR)/usr/bin/* > /dev/null 2>&1
125
126 binutils_target: $(GCC_DEPENDANCY) $(TARGET_DIR)/usr/bin/ld
127
128 binutils_target-clean:
129 (cd $(TARGET_DIR)/usr/bin; \
130 rm -f addr2line ar as gprof ld nm objcopy \
131 objdump ranlib readelf size strings strip)
132 rm -f $(TARGET_DIR)/bin/$(REAL_GNU_TARGET_NAME)*
133 -$(MAKE) -C $(BINUTILS_DIR2) clean
134
135 binutils_target-toolclean:
136 rm -rf $(BINUTILS_DIR2)
This page took 0.04373 seconds and 3 git commands to generate.