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