Revert "skip rpaths"
[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 rm -f %buildroot/%_bindir/gcore*
264
265 if [ ! -f "%buildroot/%_bindir/ld.bfd" ]; then
266   mv "%buildroot/%_bindir"/{ld,ld.bfd};
267 else
268   rm -f "%buildroot/%_bindir/ld";
269 fi
270 mkdir -p "%buildroot/%_sysconfdir/alternatives";
271 ln -s "%_bindir/ld" "%buildroot/%_sysconfdir/alternatives/ld";
272 ln -s "%_sysconfdir/alternatives/ld" "%buildroot/%_bindir/ld";
273 rm -rf $RPM_BUILD_ROOT%{_prefix}/%{HOST}/bin
274 mkdir -p $RPM_BUILD_ROOT%{_prefix}/%{HOST}/bin
275 ln -sf ../../bin/{ar,as,ld,nm,ranlib,strip} $RPM_BUILD_ROOT%{_prefix}/%{HOST}/bin
276 %ifarch %gold_archs
277 ln -sf ../../bin/ld.gold $RPM_BUILD_ROOT%{_prefix}/%{HOST}/bin
278 %endif
279
280 mv $RPM_BUILD_ROOT%{_prefix}/%{HOST}/lib/ldscripts $RPM_BUILD_ROOT%{_libdir}
281 ln -sf ../../%{_lib}/ldscripts $RPM_BUILD_ROOT%{_prefix}/%{HOST}/lib/ldscripts
282
283 # Install header files
284 make -C libiberty install_to_libdir target_header_dir=/usr/include DESTDIR=$RPM_BUILD_ROOT
285 # We want the PIC libiberty.a
286 install -m 644 libiberty/pic/libiberty.a $RPM_BUILD_ROOT%{_libdir}
287 #
288 chmod a+x $RPM_BUILD_ROOT%{_libdir}/libbfd-*
289 chmod a+x $RPM_BUILD_ROOT%{_libdir}/libopcodes-*
290 # No shared linking outside binutils
291 rm -f $RPM_BUILD_ROOT%{_libdir}/lib{bfd,opcodes,inproctrace}.so
292 rm -f $RPM_BUILD_ROOT%{_libdir}/lib{bfd,opcodes}.la
293 # Remove unwanted files to shut up rpm
294 rm -f $RPM_BUILD_ROOT%{_mandir}/man1/dlltool.1 $RPM_BUILD_ROOT%{_mandir}/man1/windres.1 $RPM_BUILD_ROOT%{_mandir}/man1/windmc.1
295 cd ..
296 #%find_lang binutils
297 #%find_lang bfd binutils.lang
298 #%find_lang gas binutils.lang
299 #%find_lang ld binutils.lang
300 #%find_lang opcodes binutils.lang
301 #%find_lang gprof binutils.lang
302 %ifarch %gold_archs
303 #%find_lang gold binutils-gold.lang
304 %endif
305 mkdir -p $RPM_BUILD_ROOT%{_docdir}/%{name}
306 install -m 644 binutils/NEWS $RPM_BUILD_ROOT%{_docdir}/%{name}/NEWS-binutils
307 install -m 644 gas/NEWS $RPM_BUILD_ROOT%{_docdir}/%{name}/NEWS-gas
308 install -m 644 ld/NEWS $RPM_BUILD_ROOT%{_docdir}/%{name}/NEWS-ld
309 %else
310 # installing cross-TARGET-binutils and TARGET-binutils
311 make DESTDIR=$RPM_BUILD_ROOT install
312 # Replace hard links by symlinks, so that rpmlint doesn't complain
313 T=$(basename %buildroot/usr/%{TARGET}*)
314 for f in %buildroot/usr/$T/bin/* ; do
315    ln -sf /usr/bin/$T-$(basename $f) $f
316 done
317 %if "%{TARGET}" == "avr"
318 install -c gas-nesc/as-new $RPM_BUILD_ROOT%{_prefix}/bin/%{TARGET}-nesc-as
319 ln -sf ../../bin/%{TARGET}-nesc-as $RPM_BUILD_ROOT%{_prefix}/%{TARGET}/bin/nesc-as
320 %endif
321 rm -rf $RPM_BUILD_ROOT%{_mandir}
322 rm -rf $RPM_BUILD_ROOT%{_infodir}
323 rm -rf $RPM_BUILD_ROOT%{_prefix}/lib*
324 rm -rf $RPM_BUILD_ROOT%{_prefix}/include
325 rm -f $RPM_BUILD_ROOT%{_prefix}/bin/*-c++filt
326
327 # We have gdb in separate package
328 rm -f $RPM_BUILD_ROOT%{_bindir}/gdb*
329 rm -f $RPM_BUILD_ROOT%{_bindir}/gcore*
330 rm -rf $RPM_BUILD_ROOT%{_datadir}/gdb
331
332 > ../binutils.lang
333 %endif
334 cd $RPM_BUILD_DIR/binutils-%version
335
336
337 %if 0%{!?cross:1}
338 %docs_package
339 %post
340 "%_sbindir/update-alternatives" --install \
341     "%_bindir/ld" ld "%_bindir/ld.bfd" 1
342
343 %post gold
344 "%_sbindir/update-alternatives" --install \
345     "%_bindir/ld" ld "%_bindir/ld.gold" 2
346
347
348 %preun
349 if [ "$1" = 0 ]; then
350     "%_sbindir/update-alternatives" --remove ld "%_bindir/ld.bfd";
351 fi;
352
353 %preun gold
354 if [ "$1" = 0 ]; then
355     "%_sbindir/update-alternatives" --remove ld "%_bindir/ld.gold";
356 fi;
357
358 %endif
359
360 %files 
361 %manifest %{name}.manifest
362 %defattr(-,root,root)
363 %if 0%{!?cross:1}
364 %{_docdir}/%{name}
365 %{_prefix}/%{HOST}/bin/*
366 %{_prefix}/%{HOST}/lib/ldscripts
367 %ghost %_sysconfdir/alternatives/ld
368 %{_libdir}/ldscripts
369 %{_bindir}/*
370 %ifarch %gold_archs
371 %exclude %{_bindir}/*gold
372 %endif
373 %doc %{_infodir}/*.gz
374 %{_libdir}/lib*-%{version}*.so
375 %else
376 %{_prefix}/%{TARGET}*
377 %{_prefix}/bin/*
378 %endif
379
380 %ifarch %gold_archs
381 %files gold 
382 %manifest %{name}.manifest
383 %defattr(-,root,root)
384 %{_bindir}/*gold
385 %if 0%{?cross:1}
386 %if "%{TARGET}" == "arm"
387 %{_prefix}/%{TARGET}-tizen-linux-gnueabi/bin/*gold
388 %else
389 %{_prefix}/%{TARGET}-tizen-linux/bin/*gold
390 %endif
391 %else
392 %{_prefix}/%{HOST}/bin/*gold
393 %endif
394 %endif
395
396 %if 0%{!?cross:1}
397 %files devel
398 %manifest %{name}.manifest
399 %defattr(-,root,root)
400 %{_prefix}/include/*.h
401 %{_prefix}/include/gdb/*.h
402 %{_libdir}/lib*.*a
403 %{_datadir}/gdb/*
404 %endif
405
406 %changelog