add fixes from whiterussian
[openwrt.git] / toolchain / binutils / Makefile
1 include $(TOPDIR)/rules.mk
2
3 #############################################################
4 #
5 # build binutils for use on the host system
6 #
7 #############################################################
8 BINUTILS_VERSION:=$(strip $(subst ",, $(BR2_BINUTILS_VERSION)))
9 #"
10
11 BINUTILS_SITE:=http://www.fr.kernel.org/pub/linux/devel/binutils \
12                http://www.fi.kernel.org/pub/linux/devel/binutils \
13                http://ftp.kernel.org/pub/linux/devel/binutils \
14                http://www.de.kernel.org/pub/linux/devel/binutils
15
16 ifeq ($(BINUTILS_VERSION),2.15)
17 BINUTILS_SITE:=http://ftp.gnu.org/gnu/binutils/ \
18         ftp://gatekeeper.dec.com/pub/GNU/ \
19         ftp://ftp.uu.net/archive/systems/gnu/ \
20         ftp://ftp.eu.uu.net/pub/gnu/ \
21         ftp://ftp.funet.fi/pub/gnu/prep/ \
22         ftp://ftp.leo.org/pub/comp/os/unix/gnu/ 
23 endif
24 ifeq ($(BINUTILS_VERSION),2.14)
25 BINUTILS_SITE:=http://ftp.gnu.org/gnu/binutils/ \
26         ftp://gatekeeper.dec.com/pub/GNU/ \
27         ftp://ftp.uu.net/archive/systems/gnu/ \
28         ftp://ftp.eu.uu.net/pub/gnu/ \
29         ftp://ftp.funet.fi/pub/gnu/prep/ \
30         ftp://ftp.leo.org/pub/comp/os/unix/gnu/ 
31 endif
32 ifeq ($(BINUTILS_VERSION),2.13)
33 BINUTILS_SITE:=http://ftp.gnu.org/gnu/binutils/ \
34         ftp://gatekeeper.dec.com/pub/GNU/ \
35         ftp://ftp.uu.net/archive/systems/gnu/ \
36         ftp://ftp.eu.uu.net/pub/gnu/ \
37         ftp://ftp.funet.fi/pub/gnu/prep/ \
38         ftp://ftp.leo.org/pub/comp/os/unix/gnu/ 
39 endif
40
41 BINUTILS_SOURCE:=binutils-$(BINUTILS_VERSION).tar.bz2
42 BINUTILS_DIR:=$(TOOL_BUILD_DIR)/binutils-$(BINUTILS_VERSION)
43 BINUTILS_CAT:=bzcat
44
45 BINUTILS_DIR1:=$(TOOL_BUILD_DIR)/binutils-$(BINUTILS_VERSION)-build
46
47 $(DL_DIR)/$(BINUTILS_SOURCE):
48         mkdir -p $(DL_DIR)
49         $(SCRIPT_DIR)/download.pl $(DL_DIR) $(BINUTILS_SOURCE) x $(BINUTILS_SITE)
50
51 $(BINUTILS_DIR)/.unpacked: $(DL_DIR)/$(BINUTILS_SOURCE)
52         mkdir -p $(TOOL_BUILD_DIR)
53         $(BINUTILS_CAT) $(DL_DIR)/$(BINUTILS_SOURCE) | tar -C $(TOOL_BUILD_DIR) $(TAR_OPTIONS) -
54         touch $(BINUTILS_DIR)/.unpacked
55
56 $(BINUTILS_DIR)/.patched: $(BINUTILS_DIR)/.unpacked
57         # Apply appropriate binutils patches.
58         $(SCRIPT_DIR)/patch-kernel.sh $(BINUTILS_DIR) ./all \*.patch
59         $(SCRIPT_DIR)/patch-kernel.sh $(BINUTILS_DIR) ./$(BINUTILS_VERSION) \*.patch
60         touch $(BINUTILS_DIR)/.patched
61
62 $(BINUTILS_DIR1)/.configured: $(BINUTILS_DIR)/.patched
63         mkdir -p $(BINUTILS_DIR1)
64         (cd $(BINUTILS_DIR1); \
65                 $(BINUTILS_DIR)/configure \
66                 --prefix=$(STAGING_DIR) \
67                 --build=$(GNU_HOST_NAME) \
68                 --host=$(GNU_HOST_NAME) \
69                 --target=$(REAL_GNU_TARGET_NAME) \
70                 --disable-werror \
71                 $(DISABLE_NLS) \
72                 $(MULTILIB) \
73                 $(SOFT_FLOAT_CONFIG_OPTION) );
74         touch $(BINUTILS_DIR1)/.configured
75
76 $(BINUTILS_DIR1)/binutils/objdump: $(BINUTILS_DIR1)/.configured
77         $(MAKE) -C $(BINUTILS_DIR1) all
78
79 # Make install will put gettext data in staging_dir/share/locale.
80 # Unfortunatey, it isn't configureable.
81 $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-ld: $(BINUTILS_DIR1)/binutils/objdump
82         $(MAKE) -C $(BINUTILS_DIR1) install
83
84
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                 $(SOFT_FLOAT_CONFIG_OPTION) );
106         touch $(BINUTILS_DIR2)/.configured
107
108 $(BINUTILS_DIR2)/binutils/objdump: $(BINUTILS_DIR2)/.configured
109         PATH=$(TARGET_PATH) \
110         $(MAKE) -C $(BINUTILS_DIR2) all
111
112 source: $(DL_DIR)/$(BINUTILS_SOURCE)
113 prepare: $(BINUTILS_DIR)/.patched
114 compile: $(BINUTILS_DIR1)/binutils/objdump
115 install: $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-ld
116 clean:
117         rm -f $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)*
118         rm -rf $(BINUTILS_DIR) $(BINUTILS_DIR1)
119
120