1 %define binutils_target %{_target_platform}
3 %define enable_shared 1
4 %define run_testsuite 0
5 %define accelerator_crossbuild 0
7 Summary: A GNU collection of binary utilities
8 Name: cross-armv7hl-binutils
9 Version: 2.21.51.20110421
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
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
50 %define run_testsuite 0
51 %define cross %{binutils_target}-
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
59 %define accelerator_crossbuild 1
61 %define _build_name_fmt %%{ARCH}/%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.dontuse.rpm
65 #BuildRequires: gettext
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
73 BuildRequires: dejagnu, zlib-static, glibc-static, sharutils
75 Conflicts: gcc-c++ < 4.0.0
77 # On ARM EABI systems, we do want -gnueabi to be part of the
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).
97 Summary: BFD and opcodes static libraries and header files
98 Group: System/Libraries
99 Conflicts: binutils < 2.17.50.0.3-4
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.
109 %setup -q -n binutils-%{version}
137 # We cannot run autotools as there is an exact requirement of autoconf-2.59.
139 # On ppc64 we might use 64KiB pages
140 sed -i -e '/#define.*ELF_COMMONPAGESIZE/s/0x1000$/0x10000/' bfd/elf*ppc.c
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}
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
155 sed -i -e "2aDEJATOOL = $tool" $tool/Makefile.am
156 sed -i -e "s/^DEJATOOL = .*/DEJATOOL = $tool/" $tool/Makefile.in
161 echo target is %{binutils_target}
162 export CFLAGS="$RPM_OPT_FLAGS"
165 case %{binutils_target} in i?86*)
166 CARGS="$CARGS --enable-64-bit-bfd"
170 %if 0%{?_with_debug:1}
171 CFLAGS="$CFLAGS -O0 -ggdb2"
172 %define enable_shared 0
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"
181 --build=%{_target_platform} --host=%{_target_platform} \
182 --target=%{binutils_target} \
184 %if !%{accelerator_crossbuild}
185 --enable-targets=%{_host} \
186 --with-sysroot=%{_prefix}/%{binutils_target}/sys-root \
187 --program-prefix=%{cross} \
190 --program-prefix="" \
201 --enable-ld=default \
205 make %{_smp_mflags} tooldir=%{_prefix} all
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=========================
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}
218 ln $file binutils-%{_target_platform}-$(basename $file) || :
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}
227 make install DESTDIR=%{buildroot}
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
235 # Rebuild libbfd.a with -fPIC.
236 # Without the hidden visibility the 3rd party shared libraries would export
237 # the bfd non-stable ABI.
239 make CFLAGS="-g -fPIC $RPM_OPT_FLAGS -fvisibility=hidden" -C bfd
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}*
248 chmod +x %{buildroot}%{_prefix}/%{_lib}/lib*.so*
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
255 # Remove libtool files, which reference the .so libs
256 rm -f %{buildroot}%{_prefix}/%{_lib}/lib{bfd,opcodes}.la
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
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\
270 #define BFD_HOST_64_BIT long\
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
275 touch -r bfd/bfd-in2.h %{buildroot}%{_prefix}/include/bfd.h
277 # Generate .so linker scripts for dependencies; imported from glibc/Makerules:
279 # This fragment of linker script gives the OUTPUT_FORMAT statement
280 # for the configuration we are building.
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}")"
286 tee %{buildroot}%{_prefix}/%{_lib}/libbfd.so <<EOH
291 /* The libz dependency is unexpected by legacy build scripts. */
292 INPUT ( %{_libdir}/libbfd.a -liberty -lz )
295 tee %{buildroot}%{_prefix}/%{_lib}/libopcodes.so <<EOH
300 INPUT ( %{_libdir}/libopcodes.a -lbfd )
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}
310 # This one comes from gcc
311 rm -f %{buildroot}%{_infodir}/dir
312 rm -rf %{buildroot}%{_prefix}/%{binutils_target}
314 # As gas/README points out (search for --enable-targets),
315 # multi-arch gas is not ready yet.
316 rm -rf %{buildroot}%{_libdir}/ldscripts
319 %postun -p /sbin/ldconfig
322 %defattr(-,root,root,-)
326 %{_prefix}/%{_lib}/lib*.so
327 %exclude %{_prefix}/%{_lib}/libbfd.so
328 %exclude %{_prefix}/%{_lib}/libopcodes.so
333 %defattr(-,root,root,-)
335 %{_prefix}/%{_lib}/libbfd.so
336 %{_prefix}/%{_lib}/libopcodes.so
337 %{_prefix}/%{_lib}/lib*.a