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