0f1b7aee029759e907b8e200a9c9e900cfa670be
[platform/upstream/binutils.git] / packaging / cross-i386-binutils.spec
1 #
2 # spec file for package cross-i386-binutils
3 #
4 # Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
5 #
6 # All modifications and additions to the file contributed by third parties
7 # remain the property of their copyright owners, unless otherwise agreed
8 # upon. The license for this file, and modifications and additions to the
9 # file, is the same license as for the pristine package itself (unless the
10 # license for the pristine package is not an Open Source License, in which
11 # case the license is the MIT License). An "Open Source License" is a
12 # license that conforms to the Open Source Definition (Version 1.9)
13 # published by the Open Source Initiative.
14
15 # Please submit bugfixes or comments via http://bugs.opensuse.org/
16 #
17
18
19 Name:           cross-i386-binutils
20 ExcludeArch:    %ix86
21 %define cross 1
22 %define TARGET i586
23 BuildRequires:  bison
24 BuildRequires:  flex
25 BuildRequires:  gcc-c++
26 # for the testsuite
27 BuildRequires:  glibc-devel-static
28 # for some gold tests
29 BuildRequires:  bc
30 BuildRequires:  makeinfo
31 BuildRequires:  zlib-devel-static
32 Version:        2.22
33 Release:        0
34 #
35 # RUN_TESTS
36 %define run_tests %(test ! -f %_sourcedir/RUN_TESTS ; echo $?)
37 # check the vanilla binutils, with no patches applied
38 # TEST_VANILLA
39 %define test_vanilla %(test ! -f %_sourcedir/TEST_VANILLA ; echo $?)
40 #
41 # handle test suite failures
42 #
43 %ifarch alpha %arm hppa mips sh4 %sparc
44 %define make_check_handling     true
45 %else
46 # XXX check again
47 # XXX disabled because gold is seriously broken for now
48 %define make_check_handling     true
49 %endif
50 # let make check fail anyway if RUN_TESTS was requested
51 %if %{run_tests}
52 %define make_check_handling     false
53 %endif
54 # handle all binary object formats supported by SuSE (and a few more)
55 %ifarch %ix86 %arm ia64 ppc ppc64 s390 s390x x86_64
56 %define build_multitarget 1
57 %else
58 %define build_multitarget 0
59 %endif
60 %define target_list alpha armv5l armv7l armv8l hppa hppa64 i686 ia64 m68k mips powerpc powerpc64 s390 s390x sh4 sparc sparc64 x86_64
61 #
62 #
63 #
64 Url:            http://www.gnu.org/software/binutils/
65 %define binutils_version %(echo %version | sed 's/\\.[0-9]\\{8\\}$//')
66 Summary:        GNU Binutils
67 License:        GFDL-1.3 and GPL-3.0+
68 Group:          Development/Tools/Building
69 Source:         binutils-%{binutils_version}.tar.bz2
70 Source1:        pre_checkin.sh
71 Source2:        README.First-for.SuSE.packagers
72 Source3:        baselibs.conf
73 Patch3:         binutils-skip-rpaths.patch
74 Patch4:         s390-biarch.diff
75 Patch5:         x86-64-biarch.patch
76 Patch6:         unit-at-a-time.patch
77 Patch7:         ld-dtags.diff
78 Patch8:         ld-relro.diff
79 Patch9:         testsuite.diff
80 Patch10:        enable-targets-gold.diff
81 Patch11:        use-hashtype-both-by-default.diff
82 Patch14:        binutils-build-as-needed.diff
83 Patch15:        fixup-testcase-perturb.diff
84 Patch18:        gold-depend-on-opcodes.diff
85 Patch19:        bso12451.diff
86 Patch20:        bso13449.diff
87 Patch90:        cross-avr-nesc-as.patch
88 Patch92:        cross-avr-omit_section_dynsym.patch
89 Patch93:        avr-binutils-relocs.patch
90 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
91
92 %description
93 C compiler utilities: ar, as, gprof, ld, nm, objcopy, objdump, ranlib,
94 size, strings, and strip. These utilities are needed whenever you want
95 to compile a program or kernel.
96
97
98 %package gold
99 Summary:        The gold linker
100 License:        GPL-3.0+
101 Group:          Development/Tools/Building
102 Requires:       binutils = %{version}-%{release}
103 %if 0%{!?cross:1}
104 %define gold_archs %ix86 %arm x86_64 ppc ppc64 %sparc
105 %endif
106
107 %description gold
108 gold is an ELF linker.  It is intended to have complete support for ELF
109 and to run as fast as possible on modern systems.  For normal use it is
110 a drop-in replacement for the older GNU linker.
111
112
113 %package devel
114 Summary:        GNU binutils (BFD development files)
115 License:        GPL-3.0+
116 Group:          Development/Libraries/C and C++
117 Requires:       binutils = %{version}-%{release}
118 Requires:       zlib-devel
119 Provides:       binutils:/usr/include/bfd.h
120
121 %description devel
122 This package includes header files and static libraries necessary to
123 build programs which use the GNU BFD library, which is part of
124 binutils.
125
126
127 %ifarch %arm
128 %define HOST %{_target_cpu}-tizen-linux-gnueabi
129 %else
130 %define HOST %(echo %{_target_cpu} | sed -e "s/parisc/hppa/" -e "s/i.86/i586/" -e "s/ppc/powerpc/" -e "s/sparc64v.*/sparc64/" -e "s/sparcv.*/sparc/")-tizen-linux
131 %endif 
132 %define DIST %(echo '%distribution' | sed 's/ (.*)//')
133
134 %prep
135 echo "make check will return with %{make_check_handling} in case of testsuite failures."
136 %setup -q -n binutils-%{binutils_version}
137 %if !%{test_vanilla}
138 %patch3
139 %patch4
140 %patch5
141 %patch6
142 %patch7 -p1
143 %patch8
144 %patch9
145 %patch10
146 %patch11
147 %patch14
148 %patch15
149 %patch18
150 %patch19 -p1
151 %patch20 -p1
152 %if "%{TARGET}" == "avr"
153 cp gas/config/tc-avr.h gas/config/tc-avr-nesc.h
154 %patch90
155 %patch92
156 %patch93 -p1
157 %endif
158 #
159 # test_vanilla
160 %endif
161 sed -i -e '/BFD_VERSION_DATE/s/$/-%(echo %release | sed 's/\.[0-9]*$//')/' bfd/version.h
162
163 %build
164 RPM_OPT_FLAGS="$RPM_OPT_FLAGS -Wno-error"
165 %if 0%{!?cross:1}
166 # Building native binutils
167 echo "Building native binutils." 
168 %if %build_multitarget
169 EXTRA_TARGETS="%(printf ,%%s-tizen-linux %target_list)"
170 EXTRA_TARGETS="$EXTRA_TARGETS,powerpc-macos,powerpc-macos10,spu-elf,x86_64-pep"
171 %else
172 EXTRA_TARGETS=
173 %ifarch sparc
174 EXTRA_TARGETS="$EXTRA_TARGETS,sparc64-tizen-linux"
175 %endif
176 %ifarch ppc
177 EXTRA_TARGETS="$EXTRA_TARGETS,powerpc64-tizen-linux"
178 %endif
179 %ifarch s390
180 EXTRA_TARGETS="$EXTRA_TARGETS,s390x-tizen-linux"
181 %endif
182 %ifarch s390x
183 EXTRA_TARGETS="$EXTRA_TARGETS,s390-tizen-linux"
184 %endif
185 %ifarch %ix86
186 EXTRA_TARGETS="$EXTRA_TARGETS,x86_64-tizen-linux"
187 %endif
188 %ifarch ppc ppc64
189 EXTRA_TARGETS="$EXTRA_TARGETS,spu-elf"
190 %endif
191 %ifarch %arm
192 EXTRA_TARGETS="$EXTRA_TARGETS,arm-tizen-linux-gnueabi"
193 %endif
194 %endif
195 %define common_flags CFLAGS="${RPM_OPT_FLAGS}" CXXFLAGS="${RPM_OPT_FLAGS}" \\\
196         --prefix=%{_prefix} --libdir=%{_libdir} \\\
197         --infodir=%{_infodir} --mandir=%{_mandir} \\\
198         --with-bugurl=http://bugs.opensuse.org/ \\\
199         --with-pkgversion="GNU Binutils; %{DIST}" \\\
200         --disable-nls \\\
201         --with-separate-debug-dir=%{_prefix}/lib/debug \\\
202         --with-pic --build=%{HOST} 
203 mkdir build-dir
204 cd build-dir
205 ../configure %common_flags \
206         ${EXTRA_TARGETS:+--enable-targets="${EXTRA_TARGETS#,}"} \
207         --enable-plugins \
208 %ifarch %gold_archs
209         --enable-gold \
210 %endif
211         --enable-shared
212 make %{?_smp_mflags} all-bfd TARGET-bfd=headers
213 # force reconfiguring (???)
214 rm bfd/Makefile
215 make %{?_smp_mflags}
216
217 %else
218 # building cross-TARGET-binutils
219 echo "Building cross binutils." 
220 mkdir build-dir
221 cd build-dir
222 EXTRA_TARGETS=
223 %if "%{TARGET}" == "sparc"
224 EXTRA_TARGETS="$EXTRA_TARGETS,sparc64-tizen-linux"
225 %endif
226 %if "%{TARGET}" == "powerpc"
227 EXTRA_TARGETS="$EXTRA_TARGETS,powerpc64-tizen-linux"
228 %endif
229 %if "%{TARGET}" == "s390"
230 EXTRA_TARGETS="$EXTRA_TARGETS,s390x-tizen-linux"
231 %endif
232 %if "%{TARGET}" == "s390x"
233 EXTRA_TARGETS="$EXTRA_TARGETS,s390-tizen-linux"
234 %endif
235 %if "%{TARGET}" == "i586"
236 EXTRA_TARGETS="$EXTRA_TARGETS,x86_64-tizen-linux"
237 %endif
238 %if "%{TARGET}" == "hppa"
239 EXTRA_TARGETS="$EXTRA_TARGETS,hppa64-tizen-linux"
240 %endif
241 %if "%{TARGET}" == "arm"
242 EXTRA_TARGETS="$EXTRA_TARGETS,arm-tizen-linux-gnueabi"
243 %endif
244 %if "%{TARGET}" == "avr" || "%{TARGET}" == "spu"
245 TARGET_OS=%{TARGET}
246 %else
247 %if "%{TARGET}" == "arm"
248 TARGET_OS=%{TARGET}-tizen-linux-gnueabi
249 %else
250 TARGET_OS=%{TARGET}-tizen-linux
251 %endif
252 %endif
253 ../configure CFLAGS="${RPM_OPT_FLAGS}" \
254   --prefix=%{_prefix} \
255   --with-bugurl=http://bugs.opensuse.org/ \
256   --with-pkgversion="GNU Binutils; %{DIST}" \
257   --disable-nls \
258   --build=%{HOST} --target=$TARGET_OS \
259 %if "%{TARGET}" == "spu"
260   --with-sysroot=/usr/spu \
261 %else
262   --with-sysroot=%{_prefix}/$TARGET_OS/sys-root \
263 %endif
264   ${EXTRA_TARGETS:+--enable-targets="${EXTRA_TARGETS#,}"}
265 make %{?_smp_mflags} all-bfd TARGET-bfd=headers
266 # force reconfiguring
267 rm bfd/Makefile
268 make %{?_smp_mflags}
269 %if "%{TARGET}" == "avr"
270 # build an extra nesC version because nesC requires $'s in identifiers
271 cp -a gas gas-nesc
272 echo '#include "tc-%{TARGET}-nesc.h"' > gas-nesc/targ-cpu.h
273 make -C gas-nesc clean
274 make -C gas-nesc %{?_smp_mflags}
275 %endif
276 %endif
277
278 %check
279 unset LD_AS_NEEDED
280 cd build-dir
281 %if 0%{?cross:1}
282 make -k check CFLAGS="-O2 -g" CXXFLAGS="-O2 -g" || %{make_check_handling}
283 %else
284 make -k check CFLAGS="$RPM_OPT_FLAGS -Wno-unused -Wno-unprototyped-calls" || :
285 %endif
286
287 %install
288 cd build-dir
289 %if 0%{!?cross:1}
290 # installing native binutils
291 %ifarch %gold_archs
292 make DESTDIR=$RPM_BUILD_ROOT install-gold
293 ln -sf ld.gold $RPM_BUILD_ROOT%{_bindir}/gold
294 %endif
295 make DESTDIR=$RPM_BUILD_ROOT install-info install
296 make -C gas/doc DESTDIR=$RPM_BUILD_ROOT install-info-am install-am
297 make DESTDIR=$RPM_BUILD_ROOT install-bfd install-opcodes
298 # we could eventually use alternatives for /usr/bin/ld
299 if test -f $RPM_BUILD_ROOT%{_bindir}/ld.bfd; then
300   rm $RPM_BUILD_ROOT%{_bindir}/ld
301   ln -sf ld.bfd $RPM_BUILD_ROOT%{_bindir}/ld;
302 fi
303 rm -rf $RPM_BUILD_ROOT%{_prefix}/%{HOST}/bin
304 mkdir -p $RPM_BUILD_ROOT%{_prefix}/%{HOST}/bin
305 ln -sf ../../bin/{ar,as,ld,nm,ranlib,strip} $RPM_BUILD_ROOT%{_prefix}/%{HOST}/bin
306 #mv $RPM_BUILD_ROOT%{_prefix}/%{HOST}/lib/ldscripts $RPM_BUILD_ROOT%{_libdir}
307 #ln -sf ../../%{_lib}/ldscripts $RPM_BUILD_ROOT%{_prefix}/%{HOST}/lib/ldscripts
308 # Install header files
309 make -C libiberty install_to_libdir target_header_dir=/usr/include DESTDIR=$RPM_BUILD_ROOT
310 # We want the PIC libiberty.a
311 install -m 644 libiberty/pic/libiberty.a $RPM_BUILD_ROOT%{_libdir}
312 #
313 chmod a+x $RPM_BUILD_ROOT%{_libdir}/libbfd-*
314 chmod a+x $RPM_BUILD_ROOT%{_libdir}/libopcodes-*
315 # No shared linking outside binutils
316 rm $RPM_BUILD_ROOT%{_libdir}/lib{bfd,opcodes}.so
317 rm $RPM_BUILD_ROOT%{_libdir}/lib{bfd,opcodes}.la
318 # Remove unwanted files to shut up rpm
319 rm $RPM_BUILD_ROOT%{_infodir}/configure* $RPM_BUILD_ROOT%{_infodir}/standards.info*
320 rm $RPM_BUILD_ROOT%{_mandir}/man1/dlltool.1 $RPM_BUILD_ROOT%{_mandir}/man1/windres.1 $RPM_BUILD_ROOT%{_mandir}/man1/windmc.1
321 cd ..
322 #%find_lang binutils
323 #%find_lang bfd binutils.lang
324 #%find_lang gas binutils.lang
325 #%find_lang ld binutils.lang
326 #%find_lang opcodes binutils.lang
327 #%find_lang gprof binutils.lang
328 %ifarch %gold_archs
329 #%find_lang gold binutils-gold.lang
330 %endif
331 mkdir -p $RPM_BUILD_ROOT%{_docdir}/%{name}
332 install -m 644 binutils/NEWS $RPM_BUILD_ROOT%{_docdir}/%{name}/NEWS-binutils
333 install -m 644 gas/NEWS $RPM_BUILD_ROOT%{_docdir}/%{name}/NEWS-gas
334 install -m 644 ld/NEWS $RPM_BUILD_ROOT%{_docdir}/%{name}/NEWS-ld
335 %else
336 # installing cross-TARGET-binutils and TARGET-binutils
337 make DESTDIR=$RPM_BUILD_ROOT install
338 # Replace hard links by symlinks, so that rpmlint doesn't complain
339 T=$(basename %buildroot/usr/%{TARGET}*)
340 for f in %buildroot/usr/$T/bin/* ; do
341    ln -sf /usr/bin/$T-$(basename $f) $f
342 done
343 %if "%{TARGET}" == "avr"
344 install -c gas-nesc/as-new $RPM_BUILD_ROOT%{_prefix}/bin/%{TARGET}-nesc-as
345 ln -sf ../../bin/%{TARGET}-nesc-as $RPM_BUILD_ROOT%{_prefix}/%{TARGET}/bin/nesc-as
346 %endif
347 rm -rf $RPM_BUILD_ROOT%{_mandir}
348 rm -rf $RPM_BUILD_ROOT%{_infodir}
349 rm -rf $RPM_BUILD_ROOT%{_prefix}/lib*
350 rm -rf $RPM_BUILD_ROOT%{_prefix}/include
351 rm -f $RPM_BUILD_ROOT%{_prefix}/bin/*-c++filt
352 > ../binutils.lang
353 %endif
354 cd $RPM_BUILD_DIR/binutils-%version
355
356 %clean
357 rm -rf $RPM_BUILD_ROOT
358
359 %if 0%{!?cross:1}
360 %docs_package
361 %endif
362
363 %files 
364 %defattr(-,root,root)
365 %if 0%{!?cross:1}
366 %{_docdir}/%{name}
367 %{_prefix}/%{HOST}/bin/*
368 %{_prefix}/%{HOST}/lib/ldscripts
369 #%{_libdir}/ldscripts
370 %{_bindir}/*
371 %ifarch %gold_archs
372 %exclude %{_bindir}/gold
373 %exclude %{_bindir}/ld.gold
374 %endif
375 %doc %{_infodir}/*.gz
376 %{_libdir}/lib*-%{version}*.so
377 %else
378 %{_prefix}/%{TARGET}*
379 %{_prefix}/bin/*
380 %endif
381
382 %ifarch %gold_archs
383 %files gold 
384 %defattr(-,root,root)
385 %doc gold/NEWS gold/README
386 %{_bindir}/gold
387 %{_bindir}/ld.gold
388 %endif
389
390 %if 0%{!?cross:1}
391 %files devel
392 %defattr(-,root,root)
393 %{_prefix}/include/*.h
394 %{_libdir}/lib*.*a
395 %endif
396
397 %changelog