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