Upload Tizen:Base source
[external/binutils.git] / packaging / cross-armv7l-binutils.spec
1 %define binutils_target %{_target_platform}
2 %define isnative 1
3 %define enable_shared 1
4 %define run_testsuite 0
5 %define accelerator_crossbuild 0
6
7 Summary: A GNU collection of binary utilities
8 Name: cross-armv7l-binutils
9 Version: 2.21.51.20110421
10 Release: 5
11 License: GPLv3+
12 Group: Development/Tools
13 URL: http://sources.redhat.com/binutils
14 Source: ftp://ftp.kernel.org/pub/linux/devel/binutils/binutils-%{version}.tar.gz
15 Source2: binutils-2.19.50.0.1-output-format.sed
16 Source100: baselibs.conf
17 Source200: precheckin.sh
18 Source201: README.PACKAGER
19 Patch1: 001_ld_makefile_patch.patch
20 Patch2: 006_better_file_error.patch
21 Patch3: 012_check_ldrunpath_length.patch
22 Patch4: 013_bash_in_ld_testsuite.patch
23 Patch5: 127_x86_64_i386_biarch.patch
24 Patch6: 128_build_id.patch
25 Patch7: 129_ld_mulitarch_dirs.patch
26 Patch8: 130_gold_disable_testsuite_build.patch
27 Patch9: 131_ld_bootstrap_testsuite.patch
28 Patch10: 134_gold_no_spu.patch
29 Patch11: 135_bfd_version.patch
30 Patch12: 140_pr10340.patch
31 Patch13: 156_pr10144.patch
32 Patch14: 157_ar_scripts_with_tilde.patch
33 Patch15: 158_ld_system_root.patch
34 Patch16: 159_gas-i8775.diff
35 Patch17: 160_gas_pr12698.diff
36 Patch18: 161_ar_delete_members.diff
37 Patch19: 162_pr12730.diff
38 Patch20: 162_ld_cortex_a8_erratum.diff
39 Patch21: 163_pr12726.diff
40 Patch22: 200_pr12715.diff
41 Patch23: 201_pr12778.diff
42 Patch24: Fix-gold-libopcode.patch
43 Patch25: Disable-info.patch
44
45 %if "%{name}" != "binutils"
46 %define binutils_target %(echo %{name} | sed -e "s/cross-\\(.*\\)-binutils/\\1/")-tizen-linux-gnueabi
47 %define _prefix /opt/cross
48 %define enable_shared 0
49 %define isnative 0
50 %define run_testsuite 0
51 %define cross %{binutils_target}-
52 # single target atm.
53 ExclusiveArch: %ix86
54 # special handling for ARM build acceleration
55 %if "%(echo %{name} | sed -e "s/cross-.*-binutils-\\(.*\\)/\\1/")" == "accel"
56 %define binutils_target %(echo %{name} | sed -e "s/cross-\\(.*\\)-binutils-accel/\\1/")-tizen-linux-gnueabi
57 %define _prefix /usr
58 %define cross ""
59 %define accelerator_crossbuild 1
60 AutoReqProv: 0
61 %define _build_name_fmt    %%{ARCH}/%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.dontuse.rpm
62 %endif
63 %endif
64
65 #BuildRequires: gettext
66 BuildRequires: flex
67 BuildRequires: bison
68 BuildRequires: zlib-devel
69 BuildRequires: elfutils-libelf-devel
70 # Required for: ld-bootstrap/bootstrap.exp bootstrap with --static
71 # It should not be required for: ld-elf/elf.exp static {preinit,init,fini} array
72 %if %{run_testsuite}
73 BuildRequires: dejagnu, zlib-static, glibc-static, sharutils
74 %endif
75 Conflicts: gcc-c++ < 4.0.0
76
77 # On ARM EABI systems, we do want -gnueabi to be part of the
78 # target triple.
79 %ifnarch %{arm}
80 %define _gnu %{nil}
81 %endif
82
83 %description
84 Binutils is a collection of binary utilities, including ar (for
85 creating, modifying and extracting from archives), as (a family of GNU
86 assemblers), gprof (for displaying call graph profile data), ld (the
87 GNU linker), nm (for listing symbols from object files), objcopy (for
88 copying and translating object files), objdump (for displaying
89 information from object files), ranlib (for generating an index for
90 the contents of an archive), readelf (for displaying detailed
91 information about binary files), size (for listing the section sizes
92 of an object or archive file), strings (for listing printable strings
93 from files), strip (for discarding symbols), and addr2line (for
94 converting addresses to file and line).
95
96 %package devel
97 Summary: BFD and opcodes static libraries and header files
98 Group: System/Libraries
99 Conflicts: binutils < 2.17.50.0.3-4
100 Requires: zlib-devel
101
102 %description devel
103 This package contains BFD and opcodes static libraries and associated
104 header files.  Only *.a libraries are included, because BFD doesn't
105 have a stable ABI.  Developers starting new projects are strongly encouraged
106 to consider using libelf instead of BFD.
107
108 %prep
109 %setup -q -n binutils-%{version}
110 %patch1 -p1
111 %patch2 -p1
112 %patch3 -p1
113 %patch4 -p1
114 %patch5 -p1
115 %patch6 -p1
116 %patch7 -p1
117 %patch8 -p1
118 %patch9 -p1
119 %patch10 -p1
120 %patch11 -p1
121 %patch12 -p1
122 %patch13 -p1
123 %patch14 -p1
124 %patch15 -p1
125 %patch16 -p1
126 %patch17 -p1
127 %patch18 -p1
128 %patch19 -p1
129 %patch20 -p1
130 %patch21 -p1
131 %patch22 -p1
132 %patch23 -p1
133 %patch24 -p1
134 %patch25 -p1
135
136
137 # We cannot run autotools as there is an exact requirement of autoconf-2.59.
138
139 # On ppc64 we might use 64KiB pages
140 sed -i -e '/#define.*ELF_COMMONPAGESIZE/s/0x1000$/0x10000/' bfd/elf*ppc.c
141 # LTP sucks
142 perl -pi -e 's/i\[3-7\]86/i[34567]86/g' */conf*
143 sed -i -e 's/%''{release}/%{release}/g' bfd/Makefile{.am,.in}
144 sed -i -e '/^libopcodes_la_\(DEPENDENCIES\|LIBADD\)/s,$, ../bfd/libbfd.la,' opcodes/Makefile.{am,in}
145 # Build libbfd.so and libopcodes.so with -Bsymbolic-functions if possible.
146 if gcc %{optflags} -v --help 2>&1 | grep -q -- -Bsymbolic-functions; then
147 sed -i -e 's/^libbfd_la_LDFLAGS = /&-Wl,-Bsymbolic-functions /' bfd/Makefile.{am,in}
148 sed -i -e 's/^libopcodes_la_LDFLAGS = /&-Wl,-Bsymbolic-functions /' opcodes/Makefile.{am,in}
149 fi
150 # $PACKAGE is used for the gettext catalog name.
151 sed -i -e 's/^ PACKAGE=/ PACKAGE=%{?cross}/' */configure
152 # Undo the name change to run the testsuite.
153 for tool in binutils gas ld
154 do
155   sed -i -e "2aDEJATOOL = $tool" $tool/Makefile.am
156   sed -i -e "s/^DEJATOOL = .*/DEJATOOL = $tool/" $tool/Makefile.in
157 done
158 touch */configure
159
160 %build
161 echo target is %{binutils_target}
162 export CFLAGS="$RPM_OPT_FLAGS"
163 CARGS=
164
165 case %{binutils_target} in i?86*)
166   CARGS="$CARGS --enable-64-bit-bfd"
167   ;;
168 esac
169
170 %if 0%{?_with_debug:1}
171 CFLAGS="$CFLAGS -O0 -ggdb2"
172 %define enable_shared 0
173 %endif
174
175 # We could optimize the cross builds size by --enable-shared but the produced
176 # binaries may be less convenient in the embedded environment.
177 %if %{accelerator_crossbuild}
178 export CFLAGS="$CFLAGS -Wl,-rpath,/emul/ia32-linux/usr/lib:/emul/ia32-linux/lib:/usr/lib:/lib"
179 %endif
180 %configure \
181   --build=%{_target_platform} --host=%{_target_platform} \
182   --target=%{binutils_target} \
183 %if !%{isnative} 
184 %if !%{accelerator_crossbuild}
185   --enable-targets=%{_host} \
186   --with-sysroot=%{_prefix}/%{binutils_target}/sys-root \
187   --program-prefix=%{cross} \
188 %else
189   --with-sysroot=/ \
190   --program-prefix="" \
191 %endif
192 %endif
193 %if %{enable_shared}
194   --enable-shared \
195 %else
196   --disable-shared \
197 %endif
198   $CARGS \
199   --enable-plugins \
200   --disable-werror \
201   --enable-ld=default \
202   --disable-info \
203   --enable-gold
204
205 make %{_smp_mflags} tooldir=%{_prefix} all
206
207 # Do not use %%check as it is run after %%install where libbfd.so is rebuild
208 # with -fvisibility=hidden no longer being usable in its shared form.
209 %if !%{run_testsuite}
210 echo ====================TESTSUITE DISABLED=========================
211 %else
212 make -k check < /dev/null || :
213 echo ====================TESTING=========================
214 cat {gas/testsuite/gas,ld/ld,binutils/binutils}.sum
215 echo ====================TESTING END=====================
216 for file in {gas/testsuite/gas,ld/ld,binutils/binutils}.{sum,log}
217 do
218   ln $file binutils-%{_target_platform}-$(basename $file) || :
219 done
220 tar cjf binutils-%{_target_platform}.tar.bz2 binutils-%{_target_platform}-*.{sum,log}
221 uuencode binutils-%{_target_platform}.tar.bz2 binutils-%{_target_platform}.tar.bz2
222 rm -f binutils-%{_target_platform}.tar.bz2 binutils-%{_target_platform}-*.{sum,log}
223 %endif
224
225 %install
226 rm -rf %{buildroot}
227 make install DESTDIR=%{buildroot}
228 %if %{isnative}
229
230 # Rebuild libiberty.a with -fPIC.
231 # Future: Remove it together with its header file, projects should bundle it.
232 make -C libiberty clean
233 make CFLAGS="-g -fPIC $RPM_OPT_FLAGS" -C libiberty
234
235 # Rebuild libbfd.a with -fPIC.
236 # Without the hidden visibility the 3rd party shared libraries would export
237 # the bfd non-stable ABI.
238 make -C bfd clean
239 make CFLAGS="-g -fPIC $RPM_OPT_FLAGS -fvisibility=hidden" -C bfd
240
241 install -m 644 bfd/libbfd.a %{buildroot}%{_prefix}/%{_lib}
242 install -m 644 libiberty/libiberty.a %{buildroot}%{_prefix}/%{_lib}
243 install -m 644 include/libiberty.h %{buildroot}%{_prefix}/include
244 # Remove Windows/Novell only man pages
245 rm -f %{buildroot}%{_mandir}/man1/{dlltool,nlmconv,windres}*
246
247 %if %{enable_shared}
248 chmod +x %{buildroot}%{_prefix}/%{_lib}/lib*.so*
249 %endif
250
251 # Prevent programs to link against libbfd and libopcodes dynamically,
252 # they are changing far too often
253 rm -f %{buildroot}%{_prefix}/%{_lib}/lib{bfd,opcodes}.so
254
255 # Remove libtool files, which reference the .so libs
256 rm -f %{buildroot}%{_prefix}/%{_lib}/lib{bfd,opcodes}.la
257
258 %if "%{__isa_bits}" == "64"
259 # Sanity check --enable-64-bit-bfd really works.
260 grep '^#define BFD_ARCH_SIZE 64$' %{buildroot}%{_prefix}/include/bfd.h
261 %endif
262 # Fix multilib conflicts of generated values by __WORDSIZE-based expressions.
263 %ifarch %{ix86} x86_64 
264 sed -i -e '/^#include "ansidecl.h"/{p;s~^.*$~#include <bits/wordsize.h>~;}' \
265     -e 's/^#define BFD_DEFAULT_TARGET_SIZE \(32\|64\) *$/#define BFD_DEFAULT_TARGET_SIZE __WORDSIZE/' \
266     -e 's/^#define BFD_HOST_64BIT_LONG [01] *$/#define BFD_HOST_64BIT_LONG (__WORDSIZE == 64)/' \
267     -e 's/^#define BFD_HOST_64_BIT \(long \)\?long *$/#if __WORDSIZE == 32\
268 #define BFD_HOST_64_BIT long long\
269 #else\
270 #define BFD_HOST_64_BIT long\
271 #endif/' \
272     -e 's/^#define BFD_HOST_U_64_BIT unsigned \(long \)\?long *$/#define BFD_HOST_U_64_BIT unsigned BFD_HOST_64_BIT/' \
273     %{buildroot}%{_prefix}/include/bfd.h
274 %endif
275 touch -r bfd/bfd-in2.h %{buildroot}%{_prefix}/include/bfd.h
276
277 # Generate .so linker scripts for dependencies; imported from glibc/Makerules:
278
279 # This fragment of linker script gives the OUTPUT_FORMAT statement
280 # for the configuration we are building.
281 OUTPUT_FORMAT="\
282 /* Ensure this .so library will not be used by a link for a different format
283    on a multi-architecture system.  */
284 $(gcc $CFLAGS $LDFLAGS -shared -x c /dev/null -o /dev/null -Wl,--verbose -v 2>&1 | sed -n -f "%{SOURCE2}")"
285
286 tee %{buildroot}%{_prefix}/%{_lib}/libbfd.so <<EOH
287 /* GNU ld script */
288
289 $OUTPUT_FORMAT
290
291 /* The libz dependency is unexpected by legacy build scripts.  */
292 INPUT ( %{_libdir}/libbfd.a -liberty -lz )
293 EOH
294
295 tee %{buildroot}%{_prefix}/%{_lib}/libopcodes.so <<EOH
296 /* GNU ld script */
297
298 $OUTPUT_FORMAT
299
300 INPUT ( %{_libdir}/libopcodes.a -lbfd )
301 EOH
302
303 %else # !%{isnative}
304 # We keep these as one can have native + cross binutils of different versions.
305 #rm -rf %{buildroot}%{_prefix}/share/locale
306 #rm -rf %{buildroot}%{_mandir}
307 rm -rf %{buildroot}%{_prefix}/%{_lib}/libiberty.a
308 %endif # !%{isnative}
309
310 # This one comes from gcc
311 rm -f %{buildroot}%{_infodir}/dir
312 rm -rf %{buildroot}%{_prefix}/%{binutils_target}
313
314 # As gas/README points out (search for --enable-targets),
315 # multi-arch gas is not ready yet.
316 rm -rf %{buildroot}%{_libdir}/ldscripts
317
318
319 %postun -p /sbin/ldconfig
320
321 %files 
322 %defattr(-,root,root,-)
323 %{_prefix}/bin/*
324 %{_mandir}/man1/*
325 %if %{enable_shared}
326 %{_prefix}/%{_lib}/lib*.so
327 %exclude %{_prefix}/%{_lib}/libbfd.so
328 %exclude %{_prefix}/%{_lib}/libopcodes.so
329 %endif
330 %if %{isnative}
331
332 %files devel
333 %defattr(-,root,root,-)
334 %{_prefix}/include/*
335 %{_prefix}/%{_lib}/libbfd.so
336 %{_prefix}/%{_lib}/libopcodes.so
337 %{_prefix}/%{_lib}/lib*.a
338 %endif # %{isnative}
339