packaging: unlimit stack size to fix argument list too long error
[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
10 BuildRequires:  zlib-devel-static
11 Requires(pre):  update-alternatives
12 Version:        2.24.51
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:       binutils = %{version}-%{release}
65 %if 0%{!?cross:1}
66 %define gold_archs %ix86 %arm aarch64 x86_64 ppc ppc64 %sparc
67 %endif
68
69 %description gold
70 gold is an ELF linker.  It is intended to have complete support for ELF
71 and to run as fast as possible on modern systems.  For normal use it is
72 a drop-in replacement for the older GNU linker.
73
74
75 %package devel
76 Summary:        GNU binutils (BFD development files)
77 License:        GPL-3.0+
78 Group:          Development/Building
79 Requires:       binutils = %{version}-%{release}
80 Requires:       zlib-devel
81 Provides:       binutils:/usr/include/bfd.h
82
83 %description devel
84 This package includes header files and static libraries necessary to
85 build programs which use the GNU BFD library, which is part of
86 binutils.
87
88
89 %ifarch %arm
90 %define HOST %{_target_cpu}-tizen-linux-gnueabi
91 %else
92 %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
93 %endif 
94 %define DIST %(echo '%distribution' | sed 's/ (.*)//')
95
96 %prep
97 echo "make check will return with %{make_check_handling} in case of testsuite failures."
98 %setup -q -n binutils-%{version}
99 cp %{SOURCE1001} .
100
101 %if 0%{!?cross:1}
102 %ifarch %arm
103 ulimit -Hs unlimited
104 ulimit -s unlimited
105 %endif
106 %endif
107
108 sed -i -e '/BFD_VERSION_DATE/s/$/-%(echo %release | sed 's/\.[0-9]*$//')/' bfd/version.h
109 %build
110 RPM_OPT_FLAGS="$RPM_OPT_FLAGS -Wno-error"
111 RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS |sed -e 's/atom/i686/g'`
112 %if 0%{!?cross:1}
113 # Building native binutils
114 echo "Building native binutils." 
115 %if %build_multitarget
116 EXTRA_TARGETS="%(printf ,%%s-tizen-linux %target_list)"
117 EXTRA_TARGETS="$EXTRA_TARGETS,powerpc-macos,powerpc-macos10,spu-elf,x86_64-pep"
118 %else
119 EXTRA_TARGETS=
120 %ifarch sparc
121 EXTRA_TARGETS="$EXTRA_TARGETS,sparc64-tizen-linux"
122 %endif
123 %ifarch ppc
124 EXTRA_TARGETS="$EXTRA_TARGETS,powerpc64-tizen-linux"
125 %endif
126 %ifarch s390
127 EXTRA_TARGETS="$EXTRA_TARGETS,s390x-tizen-linux"
128 %endif
129 %ifarch s390x
130 EXTRA_TARGETS="$EXTRA_TARGETS,s390-tizen-linux"
131 %endif
132 %ifarch %ix86
133 EXTRA_TARGETS="$EXTRA_TARGETS,x86_64-tizen-linux"
134 %endif
135 %ifarch ppc ppc64
136 EXTRA_TARGETS="$EXTRA_TARGETS,spu-elf"
137 %endif
138 %ifarch %arm
139 EXTRA_TARGETS="$EXTRA_TARGETS,arm-tizen-linux-gnueabi"
140 %endif
141 %ifarch aarch64
142 EXTRA_TARGETS="$EXTRA_TARGETS,aarch64-tizen-linux"
143 %endif
144 %endif
145 %define common_flags CFLAGS="${RPM_OPT_FLAGS}" CXXFLAGS="${RPM_OPT_FLAGS}" \\\
146         --prefix=%{_prefix} --libdir=%{_libdir} \\\
147         --infodir=%{_infodir} --mandir=%{_mandir} \\\
148         --with-bugurl=http://bugs.opensuse.org/ \\\
149         --with-pkgversion="GNU Binutils; %{DIST}" \\\
150         --disable-nls \\\
151         --with-separate-debug-dir=%{_prefix}/lib/debug \\\
152         --with-pic --build=%{HOST} 
153 mkdir build-dir
154 cd build-dir
155
156 %ifarch %arm
157 export CONFIG_SHELL="/bin/bash"
158 export SHELL="/bin/bash"
159 %endif
160
161 ../configure %common_flags \
162         ${EXTRA_TARGETS:+--enable-targets="${EXTRA_TARGETS#,}"} \
163         --enable-plugins \
164 %ifarch %gold_archs
165         --enable-gold \
166 %endif
167         --enable-shared
168 make %{?_smp_mflags} all-bfd TARGET-bfd=headers
169 # force reconfiguring (???)
170 rm bfd/Makefile
171 make %{?_smp_mflags}
172
173 %else
174 # building cross-TARGET-binutils
175 echo "Building cross binutils." 
176 mkdir build-dir
177 cd build-dir
178 EXTRA_TARGETS=
179 %if "%{TARGET}" == "sparc"
180 EXTRA_TARGETS="$EXTRA_TARGETS,sparc64-tizen-linux"
181 %endif
182 %if "%{TARGET}" == "powerpc"
183 EXTRA_TARGETS="$EXTRA_TARGETS,powerpc64-tizen-linux"
184 %endif
185 %if "%{TARGET}" == "s390"
186 EXTRA_TARGETS="$EXTRA_TARGETS,s390x-tizen-linux"
187 %endif
188 %if "%{TARGET}" == "s390x"
189 EXTRA_TARGETS="$EXTRA_TARGETS,s390-tizen-linux"
190 %endif
191 %if "%{TARGET}" == "i586"
192 EXTRA_TARGETS="$EXTRA_TARGETS,x86_64-tizen-linux"
193 %endif
194 %if "%{TARGET}" == "hppa"
195 EXTRA_TARGETS="$EXTRA_TARGETS,hppa64-tizen-linux"
196 %endif
197 %if "%{TARGET}" == "arm"
198 EXTRA_TARGETS="$EXTRA_TARGETS,arm-tizen-linux-gnueabi"
199 %endif
200 %if "%{TARGET}" == "aarch64"
201 EXTRA_TARGETS="$EXTRA_TARGETS,aarch64-tizen-linux"
202 %endif
203 %if "%{TARGET}" == "avr" || "%{TARGET}" == "spu"
204 TARGET_OS=%{TARGET}
205 %else
206 %if "%{TARGET}" == "arm"
207 TARGET_OS=%{TARGET}-tizen-linux-gnueabi
208 %else
209 TARGET_OS=%{TARGET}-tizen-linux
210 %endif
211 %endif
212 ../configure CFLAGS="${RPM_OPT_FLAGS}" \
213   --prefix=%{_prefix} \
214   --with-bugurl=http://bugs.opensuse.org/ \
215   --with-pkgversion="GNU Binutils; %{DIST}" \
216   --disable-nls \
217   --build=%{HOST} --target=$TARGET_OS \
218 %if "%{TARGET}" == "spu"
219   --with-sysroot=/usr/spu \
220 %else
221   --with-sysroot=%{_prefix}/$TARGET_OS/sys-root \
222 %endif
223   ${EXTRA_TARGETS:+--enable-targets="${EXTRA_TARGETS#,}"}
224 make %{?_smp_mflags} all-bfd TARGET-bfd=headers
225 # force reconfiguring
226 rm bfd/Makefile
227 make %{?_smp_mflags}
228 %if "%{TARGET}" == "avr"
229 # build an extra nesC version because nesC requires $'s in identifiers
230 cp -a gas gas-nesc
231 echo '#include "tc-%{TARGET}-nesc.h"' > gas-nesc/targ-cpu.h
232 make -C gas-nesc clean
233 make -C gas-nesc %{?_smp_mflags}
234 %endif
235 %endif
236
237 %check
238 unset LD_AS_NEEDED
239 cd build-dir
240 %if 0%{?cross:1}
241 make -k check CFLAGS="-O2 -g" CXXFLAGS="-O2 -g" || %{make_check_handling}
242 %else
243 make -k check CFLAGS="$RPM_OPT_FLAGS -Wno-unused -Wno-unprototyped-calls" || :
244 %endif
245
246 %install
247 cd build-dir
248 %if 0%{!?cross:1}
249 # installing native binutils
250 %ifarch %gold_archs
251 make DESTDIR=$RPM_BUILD_ROOT install-gold
252 ln -sf ld.gold $RPM_BUILD_ROOT%{_bindir}/gold
253 %endif
254 make DESTDIR=$RPM_BUILD_ROOT install-info install
255 make -C gas/doc DESTDIR=$RPM_BUILD_ROOT install-info-am install-am
256 make DESTDIR=$RPM_BUILD_ROOT install-bfd install-opcodes
257
258 if [ ! -f "%buildroot/%_bindir/ld.bfd" ]; then
259   mv "%buildroot/%_bindir"/{ld,ld.bfd};
260 else
261   rm -f "%buildroot/%_bindir/ld";
262 fi
263 mkdir -p "%buildroot/%_sysconfdir/alternatives";
264 ln -s "%_bindir/ld" "%buildroot/%_sysconfdir/alternatives/ld";
265 ln -s "%_sysconfdir/alternatives/ld" "%buildroot/%_bindir/ld";
266 rm -rf $RPM_BUILD_ROOT%{_prefix}/%{HOST}/bin
267 mkdir -p $RPM_BUILD_ROOT%{_prefix}/%{HOST}/bin
268 ln -sf ../../bin/{ar,as,ld,nm,ranlib,strip} $RPM_BUILD_ROOT%{_prefix}/%{HOST}/bin
269
270 mv $RPM_BUILD_ROOT%{_prefix}/%{HOST}/lib/ldscripts $RPM_BUILD_ROOT%{_libdir}
271 ln -sf ../../%{_lib}/ldscripts $RPM_BUILD_ROOT%{_prefix}/%{HOST}/lib/ldscripts
272
273 # Install header files
274 make -C libiberty install_to_libdir target_header_dir=/usr/include DESTDIR=$RPM_BUILD_ROOT
275 # We want the PIC libiberty.a
276 install -m 644 libiberty/pic/libiberty.a $RPM_BUILD_ROOT%{_libdir}
277 #
278 chmod a+x $RPM_BUILD_ROOT%{_libdir}/libbfd-*
279 chmod a+x $RPM_BUILD_ROOT%{_libdir}/libopcodes-*
280 # No shared linking outside binutils
281 rm $RPM_BUILD_ROOT%{_libdir}/lib{bfd,opcodes}.so
282 rm $RPM_BUILD_ROOT%{_libdir}/lib{bfd,opcodes}.la
283 # Remove unwanted files to shut up rpm
284 rm $RPM_BUILD_ROOT%{_mandir}/man1/dlltool.1 $RPM_BUILD_ROOT%{_mandir}/man1/windres.1 $RPM_BUILD_ROOT%{_mandir}/man1/windmc.1
285 cd ..
286 #%find_lang binutils
287 #%find_lang bfd binutils.lang
288 #%find_lang gas binutils.lang
289 #%find_lang ld binutils.lang
290 #%find_lang opcodes binutils.lang
291 #%find_lang gprof binutils.lang
292 %ifarch %gold_archs
293 #%find_lang gold binutils-gold.lang
294 %endif
295 mkdir -p $RPM_BUILD_ROOT%{_docdir}/%{name}
296 install -m 644 binutils/NEWS $RPM_BUILD_ROOT%{_docdir}/%{name}/NEWS-binutils
297 install -m 644 gas/NEWS $RPM_BUILD_ROOT%{_docdir}/%{name}/NEWS-gas
298 install -m 644 ld/NEWS $RPM_BUILD_ROOT%{_docdir}/%{name}/NEWS-ld
299 %else
300 # installing cross-TARGET-binutils and TARGET-binutils
301 make DESTDIR=$RPM_BUILD_ROOT install
302 # Replace hard links by symlinks, so that rpmlint doesn't complain
303 T=$(basename %buildroot/usr/%{TARGET}*)
304 for f in %buildroot/usr/$T/bin/* ; do
305    ln -sf /usr/bin/$T-$(basename $f) $f
306 done
307 %if "%{TARGET}" == "avr"
308 install -c gas-nesc/as-new $RPM_BUILD_ROOT%{_prefix}/bin/%{TARGET}-nesc-as
309 ln -sf ../../bin/%{TARGET}-nesc-as $RPM_BUILD_ROOT%{_prefix}/%{TARGET}/bin/nesc-as
310 %endif
311 rm -rf $RPM_BUILD_ROOT%{_mandir}
312 rm -rf $RPM_BUILD_ROOT%{_infodir}
313 rm -rf $RPM_BUILD_ROOT%{_prefix}/lib*
314 rm -rf $RPM_BUILD_ROOT%{_prefix}/include
315 rm -f $RPM_BUILD_ROOT%{_prefix}/bin/*-c++filt
316 > ../binutils.lang
317 %endif
318 cd $RPM_BUILD_DIR/binutils-%version
319
320
321 %if 0%{!?cross:1}
322 %docs_package
323 %post
324 "%_sbindir/update-alternatives" --install \
325     "%_bindir/ld" ld "%_bindir/ld.bfd" 1
326
327 %post gold
328 "%_sbindir/update-alternatives" --install \
329     "%_bindir/ld" ld "%_bindir/ld.gold" 2
330
331
332 %preun
333 if [ "$1" = 0 ]; then
334     "%_sbindir/update-alternatives" --remove ld "%_bindir/ld.bfd";
335 fi;
336
337 %preun gold
338 if [ "$1" = 0 ]; then
339     "%_sbindir/update-alternatives" --remove ld "%_bindir/ld.gold";
340 fi;
341
342 %endif
343
344 %files 
345 %manifest %{name}.manifest
346 %defattr(-,root,root)
347 %if 0%{!?cross:1}
348 %{_docdir}/%{name}
349 %{_prefix}/%{HOST}/bin/*
350 %{_prefix}/%{HOST}/lib/ldscripts
351 %ghost %_sysconfdir/alternatives/ld
352 %{_libdir}/ldscripts
353 %{_bindir}/*
354 %ifarch %gold_archs
355 %exclude %{_bindir}/gold
356 %exclude %{_bindir}/ld.gold
357 %endif
358 %doc %{_infodir}/*.gz
359 %{_libdir}/lib*-%{version}*.so
360 %else
361 %{_prefix}/%{TARGET}*
362 %{_prefix}/bin/*
363 %endif
364
365 %ifarch %gold_archs
366 %files gold 
367 %manifest %{name}.manifest
368 %defattr(-,root,root)
369 %{_bindir}/gold
370 %{_bindir}/ld.gold
371 %endif
372
373 %if 0%{!?cross:1}
374 %files devel
375 %manifest %{name}.manifest
376 %defattr(-,root,root)
377 %{_prefix}/include/*.h
378 %{_libdir}/lib*.*a
379 %endif
380
381 %changelog