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