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