rollback
[external/binutils.git] / packaging / cross-armv5tel-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-armv5tel-binutils
9 Version: 2.22
10 Release: 1.21.Mer
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.bz2
15 Source2: binutils-2.19.50.0.1-output-format.sed
16 Source100: baselibs.conf
17 Source200: precheckin.sh
18 Source201: README.PACKAGER
19 Patch01: binutils-2.20.51.0.2-libtool-lib64.patch
20 Patch04: binutils-2.20.51.0.2-version.patch
21 Patch05: binutils-2.20.51.0.2-set-long-long.patch
22 Patch06: binutils-2.20.51.0.10-copy-osabi.patch
23 Patch07: binutils-2.20.51.0.10-sec-merge-emit.patch
24 Patch08: binutils-2.20.51.0.2-build-id.patch
25 Patch09: binutils-2.22-branch-updates.patch
26 Patch10: binutils-2.22-156-pr10144.patch
27 Patch11: fixbug13534_1.patch
28 Patch12: fixbug13534_2.patch
29 Patch13: fixbug13534_3.patch
30 Patch14: fixbug13534_4.patch
31 Patch15: fixbug13534_5.patch
32
33 %if "%{name}" != "binutils"
34 %if "%{name}" != "cross-mipsel-binutils"
35 %define binutils_target %(echo %{name} | sed -e "s/cross-\\(.*\\)-binutils/\\1/")-tizen-linux-gnueabi
36 %else
37 %define binutils_target %(echo %{name} | sed -e "s/cross-\\(.*\\)-binutils/\\1/")-tizen-linux-gnu
38 %endif
39 %define _prefix /opt/cross
40 %define enable_shared 0
41 %define isnative 0
42 %define run_testsuite 0
43 %define cross %{binutils_target}-
44 # single target atm.
45 ExclusiveArch: %ix86
46 # special handling for Tizen ARM build acceleration
47 %if "%(echo %{name} | sed -e "s/cross-.*-binutils-\\(.*\\)/\\1/")" == "accel"
48 %define binutils_target %(echo %{name} | sed -e "s/cross-\\(.*\\)-binutils-accel/\\1/")-tizen-linux-gnueabi
49 %define _prefix /usr
50 %define cross ""
51 %define accelerator_crossbuild 1
52 AutoReqProv: 0
53 %define _build_name_fmt    %%{ARCH}/%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.dontuse.rpm
54 %endif
55 %endif
56
57 BuildRequires: texinfo >= 4.0, gettext, flex, bison, zlib-devel
58 # Required for: ld-bootstrap/bootstrap.exp bootstrap with --static
59 # It should not be required for: ld-elf/elf.exp static {preinit,init,fini} array
60 %if %{run_testsuite}
61 BuildRequires: dejagnu, zlib-static, glibc-static, sharutils
62 %endif
63 BuildRequires: elfutils-libelf-devel
64 Conflicts: gcc-c++ < 4.0.0
65 Requires(post): /sbin/install-info
66 Requires(preun): /sbin/install-info
67
68 # On ARM EABI systems, we do want -gnueabi to be part of the
69 # target triple.
70 %ifnarch %{arm}
71 %define _gnu %{nil}
72 %endif
73
74 %description
75 Binutils is a collection of binary utilities, including ar (for
76 creating, modifying and extracting from archives), as (a family of GNU
77 assemblers), gprof (for displaying call graph profile data), ld (the
78 GNU linker), nm (for listing symbols from object files), objcopy (for
79 copying and translating object files), objdump (for displaying
80 information from object files), ranlib (for generating an index for
81 the contents of an archive), readelf (for displaying detailed
82 information about binary files), size (for listing the section sizes
83 of an object or archive file), strings (for listing printable strings
84 from files), strip (for discarding symbols), and addr2line (for
85 converting addresses to file and line).
86
87 %package devel
88 Summary: BFD and opcodes static libraries and header files
89 Group: System/Libraries
90 Conflicts: binutils < 2.17.50.0.3-4
91 Requires(post): /sbin/install-info
92 Requires(preun): /sbin/install-info
93 Requires: zlib-devel
94
95 %description devel
96 This package contains BFD and opcodes static libraries and associated
97 header files.  Only *.a libraries are included, because BFD doesn't
98 have a stable ABI.  Developers starting new projects are strongly encouraged
99 to consider using libelf instead of BFD.
100
101 %prep
102 %setup -q -n binutils-%{version}
103 %patch01 -p0 -b .libtool-lib64~
104 # Causes build churn --cvm
105 #%patch04 -p0 -b .version~
106 %patch05 -p0 -b .set-long-long~
107 %patch06 -p0 -b .copy-osabi~
108 %patch07 -p0 -b .sec-merge-emit~
109 %patch08 -p0 -b .build-id~
110 %patch09 -p1 -b .branchupdates
111 %patch10 -p1 -b .pr10144
112 %patch11 -p1 -b .fixbug13534_1
113 %patch12 -p1 -b .fixbug13534_2
114 %patch13 -p1 -b .fixbug13534_3
115 %patch14 -p1 -b .fixbug13534_4
116 %patch15 -p1 -b .fixbug13534_5
117
118 # We cannot run autotools as there is an exact requirement of autoconf-2.59.
119
120 # On ppc64 we might use 64KiB pages
121 sed -i -e '/#define.*ELF_COMMONPAGESIZE/s/0x1000$/0x10000/' bfd/elf*ppc.c
122 # LTP sucks
123 perl -pi -e 's/i\[3-7\]86/i[34567]86/g' */conf*
124 sed -i -e 's/%''{release}/%{release}/g' bfd/Makefile{.am,.in}
125 sed -i -e '/^libopcodes_la_\(DEPENDENCIES\|LIBADD\)/s,$, ../bfd/libbfd.la,' opcodes/Makefile.{am,in}
126 # Build libbfd.so and libopcodes.so with -Bsymbolic-functions if possible.
127 if gcc %{optflags} -v --help 2>&1 | grep -q -- -Bsymbolic-functions; then
128 sed -i -e 's/^libbfd_la_LDFLAGS = /&-Wl,-Bsymbolic-functions /' bfd/Makefile.{am,in}
129 sed -i -e 's/^libopcodes_la_LDFLAGS = /&-Wl,-Bsymbolic-functions /' opcodes/Makefile.{am,in}
130 fi
131 # $PACKAGE is used for the gettext catalog name.
132 sed -i -e 's/^ PACKAGE=/ PACKAGE=%{?cross}/' */configure
133 # Undo the name change to run the testsuite.
134 for tool in binutils gas ld
135 do
136   sed -i -e "2aDEJATOOL = $tool" $tool/Makefile.am
137   sed -i -e "s/^DEJATOOL = .*/DEJATOOL = $tool/" $tool/Makefile.in
138 done
139 touch */configure
140
141 %build
142 echo target is %{binutils_target}
143 export CFLAGS="$RPM_OPT_FLAGS"
144 CARGS=
145
146 case %{binutils_target} in i?86*)
147   CARGS="$CARGS --enable-64-bit-bfd"
148   ;;
149 esac
150
151 %if 0%{?_with_debug:1}
152 CFLAGS="$CFLAGS -O0 -ggdb2"
153 %define enable_shared 0
154 %endif
155
156 # We could optimize the cross builds size by --enable-shared but the produced
157 # binaries may be less convenient in the embedded environment.
158 %if %{accelerator_crossbuild}
159 export CFLAGS="$CFLAGS -Wl,-rpath,/emul/ia32-linux/usr/lib:/emul/ia32-linux/lib:/usr/lib:/lib"
160 %endif
161 %configure \
162   --build=%{_target_platform} --host=%{_target_platform} \
163   --target=%{binutils_target} \
164 %if !%{isnative} 
165 %if !%{accelerator_crossbuild}
166   --enable-targets=%{_host} \
167   --with-sysroot=%{_prefix}/%{binutils_target}/sys-root \
168   --program-prefix=%{cross} \
169 %else
170   --with-sysroot=/ \
171   --program-prefix="" \
172 %endif
173 %endif
174 %if %{enable_shared}
175   --enable-shared \
176 %else
177   --disable-shared \
178 %endif
179   $CARGS \
180   --disable-werror \
181   --enable-lto \
182   --with-bugurl=http://bugzilla.tizen.com
183 make %{_smp_mflags} tooldir=%{_prefix} all
184 make %{_smp_mflags} tooldir=%{_prefix} info
185
186 # Do not use %%check as it is run after %%install where libbfd.so is rebuild
187 # with -fvisibility=hidden no longer being usable in its shared form.
188 %if !%{run_testsuite}
189 echo ====================TESTSUITE DISABLED=========================
190 %else
191 make -k check < /dev/null || :
192 echo ====================TESTING=========================
193 cat {gas/testsuite/gas,ld/ld,binutils/binutils}.sum
194 echo ====================TESTING END=====================
195 for file in {gas/testsuite/gas,ld/ld,binutils/binutils}.{sum,log}
196 do
197   ln $file binutils-%{_target_platform}-$(basename $file) || :
198 done
199 tar cjf binutils-%{_target_platform}.tar.bz2 binutils-%{_target_platform}-*.{sum,log}
200 uuencode binutils-%{_target_platform}.tar.bz2 binutils-%{_target_platform}.tar.bz2
201 rm -f binutils-%{_target_platform}.tar.bz2 binutils-%{_target_platform}-*.{sum,log}
202 %endif
203
204 %install
205 rm -rf %{buildroot}
206 make install DESTDIR=%{buildroot}
207 %if %{isnative}
208 make prefix=%{buildroot}%{_prefix} infodir=%{buildroot}%{_infodir} install-info
209
210 # Rebuild libiberty.a with -fPIC.
211 # Future: Remove it together with its header file, projects should bundle it.
212 make -C libiberty clean
213 make CFLAGS="-g -fPIC $RPM_OPT_FLAGS" -C libiberty
214
215 # Rebuild libbfd.a with -fPIC.
216 # Without the hidden visibility the 3rd party shared libraries would export
217 # the bfd non-stable ABI.
218 make -C bfd clean
219 make CFLAGS="-g -fPIC $RPM_OPT_FLAGS -fvisibility=hidden" -C bfd
220
221 install -m 644 bfd/libbfd.a %{buildroot}%{_prefix}/%{_lib}
222 install -m 644 libiberty/libiberty.a %{buildroot}%{_prefix}/%{_lib}
223 install -m 644 include/libiberty.h %{buildroot}%{_prefix}/include
224 # Remove Windows/Novell only man pages
225 rm -f %{buildroot}%{_mandir}/man1/{dlltool,nlmconv,windres}*
226
227 %if %{enable_shared}
228 chmod +x %{buildroot}%{_prefix}/%{_lib}/lib*.so*
229 %endif
230
231 # Prevent programs to link against libbfd and libopcodes dynamically,
232 # they are changing far too often
233 rm -f %{buildroot}%{_prefix}/%{_lib}/lib{bfd,opcodes}.so
234
235 # Remove libtool files, which reference the .so libs
236 rm -f %{buildroot}%{_prefix}/%{_lib}/lib{bfd,opcodes}.la
237
238 %if "%{__isa_bits}" == "64"
239 # Sanity check --enable-64-bit-bfd really works.
240 grep '^#define BFD_ARCH_SIZE 64$' %{buildroot}%{_prefix}/include/bfd.h
241 %endif
242 # Fix multilib conflicts of generated values by __WORDSIZE-based expressions.
243 %ifarch %{ix86} x86_64 
244 sed -i -e '/^#include "ansidecl.h"/{p;s~^.*$~#include <bits/wordsize.h>~;}' \
245     -e 's/^#define BFD_DEFAULT_TARGET_SIZE \(32\|64\) *$/#define BFD_DEFAULT_TARGET_SIZE __WORDSIZE/' \
246     -e 's/^#define BFD_HOST_64BIT_LONG [01] *$/#define BFD_HOST_64BIT_LONG (__WORDSIZE == 64)/' \
247     -e 's/^#define BFD_HOST_64_BIT \(long \)\?long *$/#if __WORDSIZE == 32\
248 #define BFD_HOST_64_BIT long long\
249 #else\
250 #define BFD_HOST_64_BIT long\
251 #endif/' \
252     -e 's/^#define BFD_HOST_U_64_BIT unsigned \(long \)\?long *$/#define BFD_HOST_U_64_BIT unsigned BFD_HOST_64_BIT/' \
253     %{buildroot}%{_prefix}/include/bfd.h
254 %endif
255 touch -r bfd/bfd-in2.h %{buildroot}%{_prefix}/include/bfd.h
256
257 # Generate .so linker scripts for dependencies; imported from glibc/Makerules:
258
259 # This fragment of linker script gives the OUTPUT_FORMAT statement
260 # for the configuration we are building.
261 OUTPUT_FORMAT="\
262 /* Ensure this .so library will not be used by a link for a different format
263    on a multi-architecture system.  */
264 $(gcc $CFLAGS $LDFLAGS -shared -x c /dev/null -o /dev/null -Wl,--verbose -v 2>&1 | sed -n -f "%{SOURCE2}")"
265
266 tee %{buildroot}%{_prefix}/%{_lib}/libbfd.so <<EOH
267 /* GNU ld script */
268
269 $OUTPUT_FORMAT
270
271 /* The libz dependency is unexpected by legacy build scripts.  */
272 INPUT ( %{_libdir}/libbfd.a -liberty -lz )
273 EOH
274
275 tee %{buildroot}%{_prefix}/%{_lib}/libopcodes.so <<EOH
276 /* GNU ld script */
277
278 $OUTPUT_FORMAT
279
280 INPUT ( %{_libdir}/libopcodes.a -lbfd )
281 EOH
282
283 %else # !%{isnative}
284 # For cross-binutils we drop the documentation.
285 rm -rf %{buildroot}%{_infodir}
286 # We keep these as one can have native + cross binutils of different versions.
287 #rm -rf %{buildroot}%{_prefix}/share/locale
288 #rm -rf %{buildroot}%{_mandir}
289 rm -rf %{buildroot}%{_prefix}/%{_lib}/libiberty.a
290 %endif # !%{isnative}
291
292 # This one comes from gcc
293 rm -f %{buildroot}%{_infodir}/dir
294 rm -rf %{buildroot}%{_prefix}/%{binutils_target}
295
296 %find_lang %{?cross}binutils
297 %find_lang %{?cross}opcodes
298 %find_lang %{?cross}bfd
299 %find_lang %{?cross}gas
300 %find_lang %{?cross}ld
301 %find_lang %{?cross}gprof
302 cat %{?cross}opcodes.lang >> %{?cross}binutils.lang
303 cat %{?cross}bfd.lang >> %{?cross}binutils.lang
304 cat %{?cross}gas.lang >> %{?cross}binutils.lang
305 cat %{?cross}ld.lang >> %{?cross}binutils.lang
306 cat %{?cross}gprof.lang >> %{?cross}binutils.lang
307
308 %clean
309 rm -rf %{buildroot}
310
311 %if %{isnative}
312 %post
313 /sbin/ldconfig
314 %install_info --info-dir=%{_infodir} %{_infodir}/as.info
315 %install_info --info-dir=%{_infodir} %{_infodir}/binutils.info
316 %install_info --info-dir=%{_infodir} %{_infodir}/gprof.info
317 %install_info --info-dir=%{_infodir} %{_infodir}/ld.info
318 %install_info --info-dir=%{_infodir} %{_infodir}/standards.info
319 %install_info --info-dir=%{_infodir} %{_infodir}/configure.info
320 exit 0
321
322 %preun
323 if [ $1 = 0 ] ;then
324   %install_info --delete --info-dir=%{_infodir} %{_infodir}/as.info
325   %install_info --delete --info-dir=%{_infodir} %{_infodir}/binutils.info
326   %install_info --delete --info-dir=%{_infodir} %{_infodir}/gprof.info
327   %install_info --delete --info-dir=%{_infodir} %{_infodir}/ld.info
328   %install_info --delete --info-dir=%{_infodir} %{_infodir}/standards.info
329   %install_info --delete --info-dir=%{_infodir} %{_infodir}/configure.info
330 fi
331 exit 0
332
333 %postun -p /sbin/ldconfig
334
335 %post devel
336 %install_info --info-dir=%{_infodir} %{_infodir}/bfd.info
337
338 %preun devel
339 if [ $1 = 0 ] ;then
340   %install_info --delete --info-dir=%{_infodir} %{_infodir}/bfd.info
341 fi
342 %endif # %{isnative}
343
344 %files -f %{?cross}binutils.lang
345 %defattr(-,root,root,-)
346 %doc README
347 %{_prefix}/bin/*
348 %{_mandir}/man1/*
349 %if %{enable_shared}
350 %{_prefix}/%{_lib}/lib*.so
351 %exclude %{_prefix}/%{_lib}/libbfd.so
352 %exclude %{_prefix}/%{_lib}/libopcodes.so
353 %endif
354 %if %{isnative}
355 %{_infodir}/[^b]*info*
356 %{_infodir}/binutils*info*
357
358 %files devel
359 %defattr(-,root,root,-)
360 %{_prefix}/include/*
361 %{_prefix}/%{_lib}/libbfd.so
362 %{_prefix}/%{_lib}/libopcodes.so
363 %{_prefix}/%{_lib}/lib*.a
364 %{_infodir}/bfd*info*
365 %endif # %{isnative}
366
367 %changelog
368 * Tue Feb  7 2012 Carsten Munk <carsten.munk@gmail.com> - 2.22
369 - Pull some patches relevant to MIPS from branch update, and
370   fix for PR10144
371 * Mon Dec 12 2011 Ray Donnelly <mingw.android@gmail.com> - 2.22
372 - Updated to binutils 2.22
373 * Tue Jun 28 2011 Junfeng Dong <junfeng.dong@intel.com> - 2.21.51.0.8
374 - Add patch binutils-2.21.51.0.8-pr12778.patch to fix dbus failure on arm.
375 * Tue May  3 2011 Junfeng Dong <junfeng.dong@intel.com> - 2.21.51.0.8
376 - Update to latest version 2.21.51.0.8.
377 - Clean unused patch files.
378 - Drop binutils.spec.diff.
379 * Sun Apr 24 2011 Jan-Simon Möller <jsmoeller@linuxfoundation.org> - 1.0
380 - Add baselibs.conf to src.rpm
381 * Thu Mar 10 2011 Junfeng Dong <junfeng.dong@intel.com> -2.21
382 - Update to 2.21. The changes include:
383 - Drop the following patch which have been merged into 2.21 already.
384   binutils-2.20.51.0.2-ifunc-ld-s.patch, binutils-2.20.51.0.2-lwp.patch
385   binutils-2.20.51.0.2-tag-div-use.patch
386 - Drop binutils-2.20.51.0.2-build-id.patch because of the code evolvement.
387 - Recreate binutils-2.20.51.0.2-libtool-lib64.patch for 2.21 and rename
388   the new patch as binutils-2.21-libtool-lib64.patch.
389 * Fri Jan  7 2011 Carsten Munk <carsten@maemo.org> - 2.20.51.0.2
390 - Add armv7hl, armv7nhl cross-binutils- packages. Part of fix for BMC#11463
391 * Fri Dec 31 2010 Carsten Munk <carsten@maemo.org> - 2.20.51.0.2
392 - Add support for Tag_MPextension_use and Tag_DIV_use. Fixes BMC#11431
393 * Wed Dec 29 2010 Austin Zhang <austin.zhang@intel.com> - 2.20.51.0.2
394 - Bugfixing:
395   BMC#10336 - Error when installing binutils with --excludedocs in .ks
396 * Tue May 25 2010 Austin Zhang <austin.zhang@intel.com> - 2.20.51.0.2
397 - enable LTO (link time optimization)
398 * Mon May  3 2010 Jan-Simon Möller <jansimon.moeller@linuxfoundation.org> - 2.20.51.0.2
399 - Add precheckin.sh, README.packager
400 - add cross-binutils-* packages (cross-compiler)
401 * Thu Mar  4 2010 Anas Nashif <anas.nashif@intel.com> - 2.20.51.0.2
402 - Use %%{_target_platform} as the build target
403 * Sat Dec 12 2009 Arjan van de Ven <arjan@linux.intel.com> - 2.20.51.0.2
404 - add the LD_AS_NEEDED env variable back, and get us closer to upstream
405 * Fri Nov 27 2009 Austin Zhang <austin.zhang@intel.com> - 2.20.51.0.2
406 - Update to 2.20.51.0.2
407 * Sat Aug 22 2009 Anas Nashif <anas.nashif@intel.com> - 2.19.51.0.14
408 - Update to 2.19.51.0.14
409 * Wed May  6 2009 Arjan van de Ven <arjan@linux.intel.com> 2.19
410 - Add LD_AS_NEEDED environment variable
411 * Tue Jan 13 2009 Anas Nashif <anas.nashif@intel.com> 2.19
412 - Fixed source tag
413 * Thu Jan  8 2009 Anas Nashif <anas.nashif@intel.com> 2.19
414 - Update to 2.19
415 * Tue Dec 16 2008 Anas Nashif <anas.nashif@intel.com> 2.18.50.0.6
416 - Fixed rpmlint errors in Summary tag
417 * Thu Dec 11 2008 Anas Nashif <anas.nashif@intel.com> 2.18.50.0.6
418 - Do not check for ia64
419 * Thu Sep 18 2008 Austin Zhang <austin.zhang@intel.com> 2.18.50.0.6
420 - add check for the info file before installation