afbb63ac3e2f155dff0d7f762d6f4e655451c9eb
[openwrt.git] / openwrt / toolchain / binutils / binutils.mk
1 #############################################################
2 #
3 # build binutils for use on the host system
4 #
5 #############################################################
6 BINUTILS_VERSION:=$(strip $(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 toolchain/patch-kernel.sh $(BINUTILS_DIR) toolchain/binutils/$(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)/$(REAL_GNU_TARGET_NAME)/bin/ld: $(BINUTILS_DIR1)/binutils/objdump
58 $(MAKE) -C $(BINUTILS_DIR1) install
59
60 binutils-dependancies:
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-dependancies $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/bin/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-dirclean:
83 rm -rf $(BINUTILS_DIR1)
84
85
86
87 #############################################################
88 #
89 # build binutils for use on the target system
90 #
91 #############################################################
92 BINUTILS_DIR2:=$(BUILD_DIR)/binutils-$(BINUTILS_VERSION)-target
93 $(BINUTILS_DIR2)/.configured: $(BINUTILS_DIR)/.patched
94 mkdir -p $(BINUTILS_DIR2)
95 (cd $(BINUTILS_DIR2); \
96 PATH=$(TARGET_PATH) \
97 CFLAGS="$(TARGET_CFLAGS)" \
98 CFLAGS_FOR_BUILD="-O2 -g" \
99 $(BINUTILS_DIR)/configure \
100 --prefix=/usr \
101 --exec-prefix=/usr \
102 --build=$(GNU_HOST_NAME) \
103 --host=$(REAL_GNU_TARGET_NAME) \
104 --target=$(REAL_GNU_TARGET_NAME) \
105 $(DISABLE_NLS) \
106 $(MULTILIB) \
107 $(SOFT_FLOAT_CONFIG_OPTION) );
108 touch $(BINUTILS_DIR2)/.configured
109
110 $(BINUTILS_DIR2)/binutils/objdump: $(BINUTILS_DIR2)/.configured
111 PATH=$(TARGET_PATH) \
112 $(MAKE) -C $(BINUTILS_DIR2) all
113
114 $(TARGET_DIR)/usr/bin/ld: $(BINUTILS_DIR2)/binutils/objdump
115 PATH=$(TARGET_PATH) \
116 $(MAKE) DESTDIR=$(TARGET_DIR) \
117 tooldir=/usr build_tooldir=/usr \
118 -C $(BINUTILS_DIR2) install
119 #rm -rf $(TARGET_DIR)/share/locale $(TARGET_DIR)/usr/info \
120 # $(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/doc
121 -$(STRIP) $(TARGET_DIR)/usr/$(REAL_GNU_TARGET_NAME)/bin/* > /dev/null 2>&1
122 -$(STRIP) $(TARGET_DIR)/usr/bin/* > /dev/null 2>&1
123
124 binutils_target: $(GCC_DEPENDANCY) $(TARGET_DIR)/usr/bin/ld
125
126 binutils_target-clean:
127 (cd $(TARGET_DIR)/usr/bin; \
128 rm -f addr2line ar as gprof ld nm objcopy \
129 objdump ranlib readelf size strings strip)
130 rm -f $(TARGET_DIR)/bin/$(REAL_GNU_TARGET_NAME)*
131 -$(MAKE) -C $(BINUTILS_DIR2) clean
132
133 binutils_target-dirclean:
134 rm -rf $(BINUTILS_DIR2)
This page took 0.046284 seconds and 3 git commands to generate.