Add support to build an ARM toolchain.
[ipfire-2.x.git] / lfs / binutils
1 ###############################################################################
2 #                                                                             #
3 # IPFire.org - A linux based firewall                                         #
4 # Copyright (C) 2007-2011  IPFire Team  <info@ipfire.org>                     #
5 #                                                                             #
6 # This program is free software: you can redistribute it and/or modify        #
7 # it under the terms of the GNU General Public License as published by        #
8 # the Free Software Foundation, either version 3 of the License, or           #
9 # (at your option) any later version.                                         #
10 #                                                                             #
11 # This program is distributed in the hope that it will be useful,             #
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of              #
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
14 # GNU General Public License for more details.                                #
15 #                                                                             #
16 # You should have received a copy of the GNU General Public License           #
17 # along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
18 #                                                                             #
19 ###############################################################################
20
21 ###############################################################################
22 # Definitions
23 ###############################################################################
24
25 include Config
26
27 ifeq "$(MACHINE)" "arm"
28         VER = 2.18
29 else
30         VER = 2.17
31 endif
32
33 THISAPP    = binutils-$(VER)
34 DL_FILE    = $(THISAPP).tar.bz2
35 DL_FROM    = $(URL_IPFIRE)
36 DIR_APP    = $(DIR_SRC)/$(THISAPP)
37
38 # XXX maybe we can remove that ugly MACHINE= by this
39 #unexport MACHINE
40
41 # Normal build or /tools build.
42 #
43 ifeq "$(ROOT)" ""
44 ifeq "$(LFS_PASS)" "install"
45   TARGET = $(DIR_INFO)/$(THISAPP)-install
46   EXTRA_CONFIG = --prefix=/opt/$(MACHINE)-uClibc \
47                 --build=$(MACHINE)-pc-linux-gnu \
48                 --host=$(MACHINE)-pc-linux-gnu \
49                 --target=$(MACHINE)-linux-uclibc \
50                 --disable-nls \
51                 --enable-multilib \
52                 --disable-werror
53   EXTRA_MAKE = all
54   EXTRA_INSTALL = 
55 else
56   TARGET = $(DIR_INFO)/$(THISAPP)
57   EXTRA_CONFIG = --prefix=/usr --enable-shared --disable-nls
58   EXTRA_MAKE = tooldir=/usr
59   EXTRA_INSTALL = tooldir=/usr
60 endif
61 else
62 ifeq "$(PASS)" "1"
63   TARGET = $(DIR_INFO)/$(THISAPP)-tools1
64   EXTRA_CONFIG = --prefix=/tools --disable-nls --disable-werror --disable-gprof
65   #EXTRA_MAKE = LDFLAGS="-all-static"
66   EXTRA_INSTALL = 
67 else
68   TARGET = $(DIR_INFO)/$(THISAPP)-tools2
69   EXTRA_CONFIG = --prefix=/tools --with-lib-path=/tools/lib --disable-nls
70   EXTRA_MAKE = 
71   EXTRA_INSTALL = 
72 endif
73 endif
74
75 ifeq "$(MACHINE)" "arm"
76         EXTRA_CONFIG += \
77                 --host=$(BUILDTARGET) \
78                 --build=$(BUILDTARGET) \
79                 --target=$(BUILDTARGET) \
80                 --with-abi=aapcs-linux \
81                 --with-float=soft
82 endif
83
84 ###############################################################################
85 # Top-level Rules
86 ###############################################################################
87
88 objects = $(DL_FILE)
89
90 $(DL_FILE) = $(DL_FROM)/$(DL_FILE)
91
92 ifeq "$(MACHINE)" "arm"
93         $(DL_FILE)_MD5 = 9d22ee4dafa3a194457caf4706f9cf01
94 else
95         $(DL_FILE)_MD5 = e26e2e06b6e4bf3acf1dc8688a94c0d1
96 endif
97
98 install : $(TARGET)
99
100 check : $(patsubst %,$(DIR_CHK)/%,$(objects))
101
102 download :$(patsubst %,$(DIR_DL)/%,$(objects))
103
104 md5 : $(subst %,%_MD5,$(objects))
105
106 ###############################################################################
107 # Downloading, checking, md5sum
108 ###############################################################################
109
110 $(patsubst %,$(DIR_CHK)/%,$(objects)) :
111         @$(CHECK)
112
113 $(patsubst %,$(DIR_DL)/%,$(objects)) :
114         @$(LOAD)
115
116 $(subst %,%_MD5,$(objects)) :
117         @$(MD5)
118
119 ###############################################################################
120 # Installation Details
121 ###############################################################################
122
123 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
124         @$(PREBUILD)
125         @rm -rf $(DIR_APP) $(DIR_SRC)/binutils-build && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE)
126         @mkdir $(DIR_SRC)/binutils-build
127         cd $(DIR_SRC)/binutils-build && MACHINE= $(DIR_APP)/configure $(EXTRA_CONFIG)
128 ifeq "$(PASS)" "1"
129         cd $(DIR_SRC)/binutils-build && make configure-host MAKEINFO=makeinfo MACHINE=
130 endif
131         cd $(DIR_SRC)/binutils-build && make $(EXTRA_MAKE) $(MAKETUNING) MAKEINFO=makeinfo MACHINE=
132         cd $(DIR_SRC)/binutils-build && make $(EXTRA_INSTALL) install MAKEINFO=makeinfo MACHINE=
133 ifeq "$(ROOT)" ""
134 ifneq "$(LFS_PASS)" "install"
135         cp -v $(DIR_APP)/include/libiberty.h /usr/include
136 endif
137 else
138 ifeq "$(PASS)" "1"
139         cd $(DIR_SRC)/binutils-build && make -C ld clean MACHINE=
140         cd $(DIR_SRC)/binutils-build && make -C ld LIB_PATH=/tools/lib MACHINE=
141         cd $(DIR_SRC)/binutils-build && cp -v ld/ld-new /tools/bin
142 else
143         cd $(DIR_SRC)/binutils-build && make -C ld clean MACHINE=
144         cd $(DIR_SRC)/binutils-build && make -C ld LIB_PATH=/usr/lib:/lib MACHINE=
145         cd $(DIR_SRC)/binutils-build && cp -v ld/ld-new /tools/bin
146 endif
147 endif
148         @rm -rf $(DIR_APP) $(DIR_SRC)/binutils-build
149         @$(POSTBUILD)