fixed optimzation for Atom
[external/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 Version:        2.23.1
12 Release:        0
13 #
14 # RUN_TESTS
15 %define run_tests %(test ! -f %_sourcedir/RUN_TESTS ; echo $?)
16 # check the vanilla binutils, with no patches applied
17 # TEST_VANILLA
18 %define test_vanilla %(test ! -f %_sourcedir/TEST_VANILLA ; echo $?)
19 #
20 # handle test suite failures
21 #
22 %ifarch alpha %arm hppa mips sh4 %sparc
23 %define make_check_handling     true
24 %else
25 # XXX check again
26 # XXX disabled because gold is seriously broken for now
27 %define make_check_handling     true
28 %endif
29 # let make check fail anyway if RUN_TESTS was requested
30 %if %{run_tests}
31 %define make_check_handling     false
32 %endif
33 # handle all binary object formats supported by SuSE (and a few more)
34 %ifarch %ix86 %arm ia64 ppc ppc64 s390 s390x x86_64
35 %define build_multitarget 1
36 %else
37 %define build_multitarget 0
38 %endif
39 %define target_list alpha armv5l armv7l armv8l hppa hppa64 i686 ia64 m68k mips powerpc powerpc64 s390 s390x sh4 sparc sparc64 x86_64
40 #
41 #
42 #
43 Url:            http://www.gnu.org/software/binutils/
44 %define binutils_version %(echo %version | sed 's/\\.[0-9]\\{8\\}$//')
45 Summary:        GNU Binutils
46 License:        GFDL-1.3 and GPL-3.0+
47 Group:          Development/Tools/Building
48 Source:         binutils-%{binutils_version}.tar.bz2
49 Source1:        pre_checkin.sh
50 Source3:        baselibs.conf
51
52 %description
53 C compiler utilities: ar, as, gprof, ld, nm, objcopy, objdump, ranlib,
54 size, strings, and strip. These utilities are needed whenever you want
55 to compile a program or kernel.
56
57
58 %package gold
59 Summary:        The gold linker
60 License:        GPL-3.0+
61 Group:          Development/Tools/Building
62 Requires:       binutils = %{version}-%{release}
63 %if 0%{!?cross:1}
64 %define gold_archs %ix86 %arm x86_64 ppc ppc64 %sparc
65 %endif
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/Libraries/C and C++
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-%{binutils_version}
97
98 sed -i -e '/BFD_VERSION_DATE/s/$/-%(echo %release | sed 's/\.[0-9]*$//')/' bfd/version.h
99 %build
100 RPM_OPT_FLAGS="$RPM_OPT_FLAGS -Wno-error"
101 RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS |sed -e 's/atom/i686/g'`
102 %if 0%{!?cross:1}
103 # Building native binutils
104 echo "Building native binutils." 
105 %if %build_multitarget
106 EXTRA_TARGETS="%(printf ,%%s-tizen-linux %target_list)"
107 EXTRA_TARGETS="$EXTRA_TARGETS,powerpc-macos,powerpc-macos10,spu-elf,x86_64-pep"
108 %else
109 EXTRA_TARGETS=
110 %ifarch sparc
111 EXTRA_TARGETS="$EXTRA_TARGETS,sparc64-tizen-linux"
112 %endif
113 %ifarch ppc
114 EXTRA_TARGETS="$EXTRA_TARGETS,powerpc64-tizen-linux"
115 %endif
116 %ifarch s390
117 EXTRA_TARGETS="$EXTRA_TARGETS,s390x-tizen-linux"
118 %endif
119 %ifarch s390x
120 EXTRA_TARGETS="$EXTRA_TARGETS,s390-tizen-linux"
121 %endif
122 %ifarch %ix86
123 EXTRA_TARGETS="$EXTRA_TARGETS,x86_64-tizen-linux"
124 %endif
125 %ifarch ppc ppc64
126 EXTRA_TARGETS="$EXTRA_TARGETS,spu-elf"
127 %endif
128 %ifarch %arm
129 EXTRA_TARGETS="$EXTRA_TARGETS,arm-tizen-linux-gnueabi"
130 %endif
131 %endif
132 %define common_flags CFLAGS="${RPM_OPT_FLAGS}" CXXFLAGS="${RPM_OPT_FLAGS}" \\\
133         --prefix=%{_prefix} --libdir=%{_libdir} \\\
134         --infodir=%{_infodir} --mandir=%{_mandir} \\\
135         --with-bugurl=http://bugs.opensuse.org/ \\\
136         --with-pkgversion="GNU Binutils; %{DIST}" \\\
137         --disable-nls \\\
138         --with-separate-debug-dir=%{_prefix}/lib/debug \\\
139         --with-pic --build=%{HOST} 
140 mkdir build-dir
141 cd build-dir
142 ../configure %common_flags \
143         ${EXTRA_TARGETS:+--enable-targets="${EXTRA_TARGETS#,}"} \
144         --enable-plugins \
145 %ifarch %gold_archs
146         --enable-gold \
147 %endif
148         --enable-shared
149 make %{?_smp_mflags} all-bfd TARGET-bfd=headers
150 # force reconfiguring (???)
151 rm bfd/Makefile
152 make %{?_smp_mflags}
153
154 %else
155 # building cross-TARGET-binutils
156 echo "Building cross binutils." 
157 mkdir build-dir
158 cd build-dir
159 EXTRA_TARGETS=
160 %if "%{TARGET}" == "sparc"
161 EXTRA_TARGETS="$EXTRA_TARGETS,sparc64-tizen-linux"
162 %endif
163 %if "%{TARGET}" == "powerpc"
164 EXTRA_TARGETS="$EXTRA_TARGETS,powerpc64-tizen-linux"
165 %endif
166 %if "%{TARGET}" == "s390"
167 EXTRA_TARGETS="$EXTRA_TARGETS,s390x-tizen-linux"
168 %endif
169 %if "%{TARGET}" == "s390x"
170 EXTRA_TARGETS="$EXTRA_TARGETS,s390-tizen-linux"
171 %endif
172 %if "%{TARGET}" == "i586"
173 EXTRA_TARGETS="$EXTRA_TARGETS,x86_64-tizen-linux"
174 %endif
175 %if "%{TARGET}" == "hppa"
176 EXTRA_TARGETS="$EXTRA_TARGETS,hppa64-tizen-linux"
177 %endif
178 %if "%{TARGET}" == "arm"
179 EXTRA_TARGETS="$EXTRA_TARGETS,arm-tizen-linux-gnueabi"
180 %endif
181 %if "%{TARGET}" == "avr" || "%{TARGET}" == "spu"
182 TARGET_OS=%{TARGET}
183 %else
184 %if "%{TARGET}" == "arm"
185 TARGET_OS=%{TARGET}-tizen-linux-gnueabi
186 %else
187 TARGET_OS=%{TARGET}-tizen-linux
188 %endif
189 %endif
190 ../configure CFLAGS="${RPM_OPT_FLAGS}" \
191   --prefix=%{_prefix} \
192   --with-bugurl=http://bugs.opensuse.org/ \
193   --with-pkgversion="GNU Binutils; %{DIST}" \
194   --disable-nls \
195   --build=%{HOST} --target=$TARGET_OS \
196 %if "%{TARGET}" == "spu"
197   --with-sysroot=/usr/spu \
198 %else
199   --with-sysroot=%{_prefix}/$TARGET_OS/sys-root \
200 %endif
201   ${EXTRA_TARGETS:+--enable-targets="${EXTRA_TARGETS#,}"}
202 make %{?_smp_mflags} all-bfd TARGET-bfd=headers
203 # force reconfiguring
204 rm bfd/Makefile
205 make %{?_smp_mflags}
206 %if "%{TARGET}" == "avr"
207 # build an extra nesC version because nesC requires $'s in identifiers
208 cp -a gas gas-nesc
209 echo '#include "tc-%{TARGET}-nesc.h"' > gas-nesc/targ-cpu.h
210 make -C gas-nesc clean
211 make -C gas-nesc %{?_smp_mflags}
212 %endif
213 %endif
214
215 %check
216 unset LD_AS_NEEDED
217 cd build-dir
218 %if 0%{?cross:1}
219 make -k check CFLAGS="-O2 -g" CXXFLAGS="-O2 -g" || %{make_check_handling}
220 %else
221 make -k check CFLAGS="$RPM_OPT_FLAGS -Wno-unused -Wno-unprototyped-calls" || :
222 %endif
223
224 %install
225 cd build-dir
226 %if 0%{!?cross:1}
227 # installing native binutils
228 %ifarch %gold_archs
229 make DESTDIR=$RPM_BUILD_ROOT install-gold
230 ln -sf ld.gold $RPM_BUILD_ROOT%{_bindir}/gold
231 %endif
232 make DESTDIR=$RPM_BUILD_ROOT install-info install
233 make -C gas/doc DESTDIR=$RPM_BUILD_ROOT install-info-am install-am
234 make DESTDIR=$RPM_BUILD_ROOT install-bfd install-opcodes
235 # we could eventually use alternatives for /usr/bin/ld
236 if test -f $RPM_BUILD_ROOT%{_bindir}/ld.bfd; then
237   rm $RPM_BUILD_ROOT%{_bindir}/ld
238   ln -sf ld.bfd $RPM_BUILD_ROOT%{_bindir}/ld;
239 fi
240 rm -rf $RPM_BUILD_ROOT%{_prefix}/%{HOST}/bin
241 mkdir -p $RPM_BUILD_ROOT%{_prefix}/%{HOST}/bin
242 ln -sf ../../bin/{ar,as,ld,nm,ranlib,strip} $RPM_BUILD_ROOT%{_prefix}/%{HOST}/bin
243 #mv $RPM_BUILD_ROOT%{_prefix}/%{HOST}/lib/ldscripts $RPM_BUILD_ROOT%{_libdir}
244 #ln -sf ../../%{_lib}/ldscripts $RPM_BUILD_ROOT%{_prefix}/%{HOST}/lib/ldscripts
245 # Install header files
246 make -C libiberty install_to_libdir target_header_dir=/usr/include DESTDIR=$RPM_BUILD_ROOT
247 # We want the PIC libiberty.a
248 install -m 644 libiberty/pic/libiberty.a $RPM_BUILD_ROOT%{_libdir}
249 #
250 chmod a+x $RPM_BUILD_ROOT%{_libdir}/libbfd-*
251 chmod a+x $RPM_BUILD_ROOT%{_libdir}/libopcodes-*
252 # No shared linking outside binutils
253 rm $RPM_BUILD_ROOT%{_libdir}/lib{bfd,opcodes}.so
254 rm $RPM_BUILD_ROOT%{_libdir}/lib{bfd,opcodes}.la
255 # Remove unwanted files to shut up rpm
256 rm $RPM_BUILD_ROOT%{_infodir}/configure* $RPM_BUILD_ROOT%{_infodir}/standards.info*
257 rm $RPM_BUILD_ROOT%{_mandir}/man1/dlltool.1 $RPM_BUILD_ROOT%{_mandir}/man1/windres.1 $RPM_BUILD_ROOT%{_mandir}/man1/windmc.1
258 cd ..
259 #%find_lang binutils
260 #%find_lang bfd binutils.lang
261 #%find_lang gas binutils.lang
262 #%find_lang ld binutils.lang
263 #%find_lang opcodes binutils.lang
264 #%find_lang gprof binutils.lang
265 %ifarch %gold_archs
266 #%find_lang gold binutils-gold.lang
267 %endif
268 mkdir -p $RPM_BUILD_ROOT%{_docdir}/%{name}
269 install -m 644 binutils/NEWS $RPM_BUILD_ROOT%{_docdir}/%{name}/NEWS-binutils
270 install -m 644 gas/NEWS $RPM_BUILD_ROOT%{_docdir}/%{name}/NEWS-gas
271 install -m 644 ld/NEWS $RPM_BUILD_ROOT%{_docdir}/%{name}/NEWS-ld
272 %else
273 # installing cross-TARGET-binutils and TARGET-binutils
274 make DESTDIR=$RPM_BUILD_ROOT install
275 # Replace hard links by symlinks, so that rpmlint doesn't complain
276 T=$(basename %buildroot/usr/%{TARGET}*)
277 for f in %buildroot/usr/$T/bin/* ; do
278    ln -sf /usr/bin/$T-$(basename $f) $f
279 done
280 %if "%{TARGET}" == "avr"
281 install -c gas-nesc/as-new $RPM_BUILD_ROOT%{_prefix}/bin/%{TARGET}-nesc-as
282 ln -sf ../../bin/%{TARGET}-nesc-as $RPM_BUILD_ROOT%{_prefix}/%{TARGET}/bin/nesc-as
283 %endif
284 rm -rf $RPM_BUILD_ROOT%{_mandir}
285 rm -rf $RPM_BUILD_ROOT%{_infodir}
286 rm -rf $RPM_BUILD_ROOT%{_prefix}/lib*
287 rm -rf $RPM_BUILD_ROOT%{_prefix}/include
288 rm -f $RPM_BUILD_ROOT%{_prefix}/bin/*-c++filt
289 > ../binutils.lang
290 %endif
291 cd $RPM_BUILD_DIR/binutils-%version
292
293 %clean
294 rm -rf $RPM_BUILD_ROOT
295
296 %if 0%{!?cross:1}
297 %docs_package
298 %endif
299
300 %files 
301 %defattr(-,root,root)
302 %if 0%{!?cross:1}
303 %{_docdir}/%{name}
304 %{_prefix}/%{HOST}/bin/*
305 %{_prefix}/%{HOST}/lib/ldscripts
306 #%{_libdir}/ldscripts
307 %{_bindir}/*
308 %ifarch %gold_archs
309 %exclude %{_bindir}/gold
310 %exclude %{_bindir}/ld.gold
311 %endif
312 %doc %{_infodir}/*.gz
313 %{_libdir}/lib*-%{version}*.so
314 %else
315 %{_prefix}/%{TARGET}*
316 %{_prefix}/bin/*
317 %endif
318
319 %ifarch %gold_archs
320 %files gold 
321 %defattr(-,root,root)
322 %doc gold/NEWS gold/README
323 %{_bindir}/gold
324 %{_bindir}/ld.gold
325 %endif
326
327 %if 0%{!?cross:1}
328 %files devel
329 %defattr(-,root,root)
330 %{_prefix}/include/*.h
331 %{_libdir}/lib*.*a
332 %endif
333
334 %changelog