47011bcb40f546739eb2a05dba3ad22f258da8db
[people/pmueller/ipfire-2.x.git] / src / uClibc / make / binutils.mk
1 #############################################################
2 #
3 # build binutils for use on the host system
4 #
5 #############################################################
6 #BINUTILS_SITE:=http://ftp.kernel.org/pub/linux/devel/binutils
7 BINUTILS_VER:=2.16.1
8 BINUTILS_SOURCE:=binutils-$(BINUTILS_VER).tar.bz2
9 BINUTILS_DIR:=$(TOOL_BUILD_DIR)/binutils-$(BINUTILS_VER)
10 BINUTILS_CAT:=bzcat
11
12 BINUTILS_DIR1:=$(TOOL_BUILD_DIR)/binutils-build
13
14 $(DL_DIR)/$(BINUTILS_SOURCE):
15 # $(WGET) -P $(DL_DIR) $(BINUTILS_SITE)/$(BINUTILS_SOURCE)
16
17 $(BINUTILS_DIR)/.unpacked: $(DL_DIR)/$(BINUTILS_SOURCE)
18 mkdir -p $(TOOL_BUILD_DIR)
19 mkdir -p $(DL_DIR)
20 mkdir -p $(STAGING_DIR)
21 mkdir -p $(STAGING_DIR)/lib/gcc-lib
22 mkdir -p $(STAGING_DIR)/usr/bin;
23 mkdir -p $(STAGING_DIR)/$(GNU_TARGET_NAME)/
24 (cd $(STAGING_DIR)/$(GNU_TARGET_NAME); ln -fs ../lib)
25 (cd $(STAGING_DIR)/$(GNU_TARGET_NAME); ln -fs ../include)
26 (cd $(STAGING_DIR)/$(GNU_TARGET_NAME); ln -fs ../include sys-include)
27 $(BINUTILS_CAT) $(DL_DIR)/$(BINUTILS_SOURCE) | tar -C $(TOOL_BUILD_DIR) -xvf -
28 touch $(BINUTILS_DIR)/.unpacked
29
30 $(BINUTILS_DIR)/.patched: $(BINUTILS_DIR)/.unpacked
31 # Apply any files named binutils-*.patch from the source directory to binutils
32 $(SOURCE_DIR)/patch-kernel.sh $(BINUTILS_DIR) $(SOURCE_DIR) binutils/$(BINUTILS_VER)/*.patch
33 touch $(BINUTILS_DIR)/.patched
34
35 $(BINUTILS_DIR1)/.configured: $(BINUTILS_DIR)/.patched
36 mkdir -p $(BINUTILS_DIR1)
37 (cd $(BINUTILS_DIR1); CC="$(HOSTCC)" \
38 CC_FOR_HOST="$(HOSTCC)" \
39 CXX_FOR_HOST="$(HOSTCC)" \
40 LDFLAGS="$(HOSTLDFLAGS)" \
41 $(BINUTILS_DIR)/configure \
42 --target=$(GNU_TARGET_NAME) \
43 --host=$(GNU_HOST_NAME) \
44 --build=$(GNU_HOST_NAME) \
45 --prefix=$(STAGING_DIR) \
46 --exec-prefix=$(STAGING_DIR) \
47 --bindir=$(STAGING_DIR)/bin \
48 --sbindir=$(STAGING_DIR)/sbin \
49 --sysconfdir=$(STAGING_DIR)/etc \
50 --datadir=$(STAGING_DIR)/share \
51 --includedir=$(STAGING_DIR)/include \
52 --libdir=$(STAGING_DIR)/lib \
53 --localstatedir=$(STAGING_DIR)/var \
54 --mandir=$(STAGING_DIR)/man \
55 --infodir=$(STAGING_DIR)/info \
56 --enable-targets=$(GNU_TARGET_NAME) \
57 --with-sysroot=$(STAGING_DIR) \
58 $(MULTILIB) \
59 $(SOFT_FLOAT_CONFIG_OPTION) \
60 --program-prefix=$(ARCH)-linux-uclibc-);
61 touch $(BINUTILS_DIR1)/.configured
62
63 $(BINUTILS_DIR1)/binutils/objdump: $(BINUTILS_DIR1)/.configured
64 $(MAKE) $(JLEVEL) CC_FOR_HOST="$(HOSTCC)" \
65 CXX_FOR_HOST="$(HOSTCC)" LDFLAGS="$(HOSTLDFLAGS)" \
66 -C $(BINUTILS_DIR1);
67
68 $(STAGING_DIR)/$(GNU_TARGET_NAME)/bin/ld: $(BINUTILS_DIR1)/binutils/objdump
69 $(MAKE) $(JLEVEL) CC_FOR_HOST="$(HOSTCC)" \
70 CXX_FOR_HOST="$(HOSTCC)" LDFLAGS="$(HOSTLDFLAGS)" \
71 -C $(BINUTILS_DIR1) install;
72 rm -rf $(STAGING_DIR)/info $(STAGING_DIR)/man $(STAGING_DIR)/share/doc \
73 $(STAGING_DIR)/share/locale
74 mkdir -p $(STAGING_DIR)/usr/bin;
75 set -e; \
76 for app in addr2line ar as c++filt gprof ld nm objcopy \
77 objdump ranlib readelf size strings strip ; \
78 do \
79 if [ -x $(STAGING_DIR)/bin/$(ARCH)-linux-uclibc-$${app} ] ; then \
80 (cd $(STAGING_DIR)/$(GNU_TARGET_NAME)/bin; \
81 ln -fs ../../bin/$(ARCH)-linux-uclibc-$${app} $${app}; \
82 ); \
83 (cd $(STAGING_DIR)/usr/bin; \
84 ln -fs ../../bin/$(ARCH)-linux-uclibc-$${app} $${app}; \
85 ); \
86 fi; \
87 done;
88
89 $(STAGING_DIR)/lib/libg.a:
90 mkdir -p $(STAGING_DIR)/$(GNU_TARGET_NAME)/bin
91 mkdir -p $(STAGING_DIR)/usr/include/
92 mkdir -p $(STAGING_DIR)/usr/lib/
93 $(TARGET_CROSS)ar rv $(STAGING_DIR)/lib/libg.a;
94 cp $(BINUTILS_DIR)/include/ansidecl.h $(STAGING_DIR)/usr/include/
95 cp $(BINUTILS_DIR)/include/bfdlink.h $(STAGING_DIR)/usr/include/
96 cp $(BINUTILS_DIR)/include/dis-asm.h $(STAGING_DIR)/usr/include/
97 cp $(BINUTILS_DIR)/include/libiberty.h $(STAGING_DIR)/usr/include/
98 cp $(BINUTILS_DIR)/include/symcat.h $(STAGING_DIR)/usr/include/
99 cp $(BINUTILS_DIR1)/bfd/bfd.h $(STAGING_DIR)/usr/include/
100 cp -a $(BINUTILS_DIR1)/bfd/.libs/* $(STAGING_DIR)/usr/lib/
101 cp -a $(BINUTILS_DIR1)/opcodes/.libs/* $(STAGING_DIR)/usr/lib/
102 cp -a $(BINUTILS_DIR1)/libiberty/libiberty.a $(STAGING_DIR)/usr/lib/
103
104 binutils: $(STAGING_DIR)/$(GNU_TARGET_NAME)/bin/ld $(STAGING_DIR)/lib/libg.a
105
106 binutils-source: $(DL_DIR)/$(BINUTILS_SOURCE)
107
108 binutils-clean:
109 rm -f $(STAGING_DIR)/bin/$(GNU_TARGET_NAME)*
110 -$(MAKE) -C $(BINUTILS_DIR1) clean
111
112 binutils-dirclean:
113 rm -rf $(BINUTILS_DIR1)
114
115
116
117 #############################################################
118 #
119 # build binutils for use on the target system
120 #
121 #############################################################
122 BINUTILS_DIR2:=$(BUILD_DIR)/binutils-target
123 $(BINUTILS_DIR2)/.configured: $(BINUTILS_DIR)/.patched
124 mkdir -p $(BINUTILS_DIR2)
125 mkdir -p $(TARGET_DIR)/usr/include
126 mkdir -p $(TARGET_DIR)/usr/$(GNU_TARGET_NAME)/
127 (cd $(BINUTILS_DIR2); \
128 $(TARGET_CONFIGURE_OPTS) \
129 CFLAGS="$(TARGET_CFLAGS)" \
130 CC_FOR_BUILD="$(HOSTCC)" \
131 CXX_FOR_BUILD="$(HOSTCC)" \
132 LDFLAGS="$(HOSTLDFLAGS)" \
133 AR_FOR_TARGET=$(TARGET_CROSS)ar \
134 AS_FOR_TARGET=$(TARGET_CROSS)as \
135 LD_FOR_TARGET=$(TARGET_CROSS)ld \
136 NM_FOR_TARGET=$(TARGET_CROSS)nm \
137 CC_FOR_TARGET=$(TARGET_CROSS)gcc$(TARGET_SOFT_FLOAT) \
138 GCC_FOR_TARGET=$(TARGET_CROSS)gcc$(TARGET_SOFT_FLOAT) \
139 CXX_FOR_TARGET=$(TARGET_CROSS)g++$(TARGET_SOFT_FLOAT) \
140 RANLIB_FOR_TARGET=$(TARGET_CROSS)ranlib \
141 $(BINUTILS_DIR)/configure \
142 --target=$(GNU_TARGET_NAME) \
143 --host=$(GNU_TARGET_NAME) \
144 --build=$(ARCH)-linux \
145 --prefix=/usr \
146 --mandir=/usr/man \
147 --infodir=/usr/info \
148 $(MULTILIB) \
149 $(SOFT_FLOAT_CONFIG_OPTION) \
150 );
151 touch $(BINUTILS_DIR2)/.configured
152
153 $(BINUTILS_DIR2)/binutils/objdump: $(BINUTILS_DIR2)/.configured
154 $(MAKE) $(JLEVEL) -C $(BINUTILS_DIR2) \
155 CC_FOR_BUILD="$(HOSTCC)" \
156 CXX_FOR_BUILD="$(HOSTCC)" \
157 LDFLAGS="$(HOSTLDFLAGS)" \
158 AR_FOR_TARGET=$(TARGET_CROSS)ar \
159 AS_FOR_TARGET=$(TARGET_CROSS)as \
160 LD_FOR_TARGET=$(TARGET_CROSS)ld \
161 NM_FOR_TARGET=$(TARGET_CROSS)nm \
162 CC_FOR_TARGET=$(TARGET_CROSS)gcc$(TARGET_SOFT_FLOAT) \
163 GCC_FOR_TARGET=$(TARGET_CROSS)gcc$(TARGET_SOFT_FLOAT) \
164 CXX_FOR_TARGET=$(TARGET_CROSS)g++$(TARGET_SOFT_FLOAT) \
165 RANLIB_FOR_TARGET=$(TARGET_CROSS)ranlib
166 touch -c $(BINUTILS_DIR2)/binutils/objdump
167
168 $(TARGET_DIR)/usr/bin/ld: $(BINUTILS_DIR2)/binutils/objdump
169 $(MAKE) $(JLEVEL) -C $(BINUTILS_DIR2) \
170 CC_FOR_BUILD="$(HOSTCC)" \
171 CXX_FOR_BUILD="$(HOSTCC)" \
172 LDFLAGS="$(HOSTLDFLAGS)" \
173 AR_FOR_TARGET=$(TARGET_CROSS)ar \
174 AS_FOR_TARGET=$(TARGET_CROSS)as \
175 LD_FOR_TARGET=$(TARGET_CROSS)ld \
176 NM_FOR_TARGET=$(TARGET_CROSS)nm \
177 CC_FOR_TARGET=$(TARGET_CROSS)gcc$(TARGET_SOFT_FLOAT) \
178 GCC_FOR_TARGET=$(TARGET_CROSS)gcc$(TARGET_SOFT_FLOAT) \
179 CXX_FOR_TARGET=$(TARGET_CROSS)g++$(TARGET_SOFT_FLOAT) \
180 RANLIB_FOR_TARGET=$(TARGET_CROSS)ranlib \
181 prefix=/usr \
182 infodir=/usr/info \
183 mandir=/usr/man \
184 DESTDIR=$(TARGET_DIR) install
185 rm -rf $(TARGET_DIR)/share/locale $(TARGET_DIR)/usr/info \
186 $(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/doc
187 -$(STRIP) $(TARGET_DIR)/usr/$(GNU_TARGET_NAME)/bin/* > /dev/null 2>&1
188 -$(STRIP) $(TARGET_DIR)/usr/bin/* > /dev/null 2>&1
189
190 $(TARGET_DIR)/usr/lib/libg.a:
191 $(TARGET_CROSS)ar rv $(TARGET_DIR)/usr/lib/libg.a;
192 cp $(BINUTILS_DIR)/include/ansidecl.h $(TARGET_DIR)/usr/include/
193 cp $(BINUTILS_DIR)/include/bfdlink.h $(TARGET_DIR)/usr/include/
194 cp $(BINUTILS_DIR)/include/dis-asm.h $(TARGET_DIR)/usr/include/
195 cp $(BINUTILS_DIR)/include/libiberty.h $(TARGET_DIR)/usr/include/
196 cp $(BINUTILS_DIR)/include/symcat.h $(TARGET_DIR)/usr/include/
197 cp $(BINUTILS_DIR2)/bfd/bfd.h $(TARGET_DIR)/usr/include/
198 cp -a $(BINUTILS_DIR2)/bfd/.libs/* $(TARGET_DIR)/usr/lib/
199 cp -a $(BINUTILS_DIR2)/opcodes/.libs/* $(TARGET_DIR)/usr/lib/
200 cp -a $(BINUTILS_DIR2)/libiberty/libiberty.a $(TARGET_DIR)/usr/lib/
201
202 binutils_target: $(GCC_DEPENDANCY) $(TARGET_DIR)/usr/bin/ld $(TARGET_DIR)/usr/lib/libg.a
203
204 binutils_target-clean:
205 rm -f $(TARGET_DIR)/bin/$(GNU_TARGET_NAME)*
206 -$(MAKE) -C $(BINUTILS_DIR2) clean
207
208 binutils_target-dirclean:
209 rm -rf $(BINUTILS_DIR2)
210