add packaging
[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 Version:        2.22
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 %if 0%{!?cross:1}
102 # Building native binutils
103 echo "Building native binutils." 
104 %if %build_multitarget
105 EXTRA_TARGETS="%(printf ,%%s-tizen-linux %target_list)"
106 EXTRA_TARGETS="$EXTRA_TARGETS,powerpc-macos,powerpc-macos10,spu-elf,x86_64-pep"
107 %else
108 EXTRA_TARGETS=
109 %ifarch sparc
110 EXTRA_TARGETS="$EXTRA_TARGETS,sparc64-tizen-linux"
111 %endif
112 %ifarch ppc
113 EXTRA_TARGETS="$EXTRA_TARGETS,powerpc64-tizen-linux"
114 %endif
115 %ifarch s390
116 EXTRA_TARGETS="$EXTRA_TARGETS,s390x-tizen-linux"
117 %endif
118 %ifarch s390x
119 EXTRA_TARGETS="$EXTRA_TARGETS,s390-tizen-linux"
120 %endif
121 %ifarch %ix86
122 EXTRA_TARGETS="$EXTRA_TARGETS,x86_64-tizen-linux"
123 %endif
124 %ifarch ppc ppc64
125 EXTRA_TARGETS="$EXTRA_TARGETS,spu-elf"
126 %endif
127 %ifarch %arm
128 EXTRA_TARGETS="$EXTRA_TARGETS,arm-tizen-linux-gnueabi"
129 %endif
130 %endif
131 %define common_flags CFLAGS="${RPM_OPT_FLAGS}" CXXFLAGS="${RPM_OPT_FLAGS}" \\\
132         --prefix=%{_prefix} --libdir=%{_libdir} \\\
133         --infodir=%{_infodir} --mandir=%{_mandir} \\\
134         --with-bugurl=http://bugs.opensuse.org/ \\\
135         --with-pkgversion="GNU Binutils; %{DIST}" \\\
136         --disable-nls \\\
137         --with-separate-debug-dir=%{_prefix}/lib/debug \\\
138         --with-pic --build=%{HOST} 
139 mkdir build-dir
140 cd build-dir
141 ../configure %common_flags \
142         ${EXTRA_TARGETS:+--enable-targets="${EXTRA_TARGETS#,}"} \
143         --enable-plugins \
144 %ifarch %gold_archs
145         --enable-gold \
146 %endif
147         --enable-shared
148 make %{?_smp_mflags} all-bfd TARGET-bfd=headers
149 # force reconfiguring (???)
150 rm bfd/Makefile
151 make %{?_smp_mflags}
152
153 %else
154 # building cross-TARGET-binutils
155 echo "Building cross binutils." 
156 mkdir build-dir
157 cd build-dir
158 EXTRA_TARGETS=
159 %if "%{TARGET}" == "sparc"
160 EXTRA_TARGETS="$EXTRA_TARGETS,sparc64-tizen-linux"
161 %endif
162 %if "%{TARGET}" == "powerpc"
163 EXTRA_TARGETS="$EXTRA_TARGETS,powerpc64-tizen-linux"
164 %endif
165 %if "%{TARGET}" == "s390"
166 EXTRA_TARGETS="$EXTRA_TARGETS,s390x-tizen-linux"
167 %endif
168 %if "%{TARGET}" == "s390x"
169 EXTRA_TARGETS="$EXTRA_TARGETS,s390-tizen-linux"
170 %endif
171 %if "%{TARGET}" == "i586"
172 EXTRA_TARGETS="$EXTRA_TARGETS,x86_64-tizen-linux"
173 %endif
174 %if "%{TARGET}" == "hppa"
175 EXTRA_TARGETS="$EXTRA_TARGETS,hppa64-tizen-linux"
176 %endif
177 %if "%{TARGET}" == "arm"
178 EXTRA_TARGETS="$EXTRA_TARGETS,arm-tizen-linux-gnueabi"
179 %endif
180 %if "%{TARGET}" == "avr" || "%{TARGET}" == "spu"
181 TARGET_OS=%{TARGET}
182 %else
183 %if "%{TARGET}" == "arm"
184 TARGET_OS=%{TARGET}-tizen-linux-gnueabi
185 %else
186 TARGET_OS=%{TARGET}-tizen-linux
187 %endif
188 %endif
189 ../configure CFLAGS="${RPM_OPT_FLAGS}" \
190   --prefix=%{_prefix} \
191   --with-bugurl=http://bugs.opensuse.org/ \
192   --with-pkgversion="GNU Binutils; %{DIST}" \
193   --disable-nls \
194   --build=%{HOST} --target=$TARGET_OS \
195 %if "%{TARGET}" == "spu"
196   --with-sysroot=/usr/spu \
197 %else
198   --with-sysroot=%{_prefix}/$TARGET_OS/sys-root \
199 %endif
200   ${EXTRA_TARGETS:+--enable-targets="${EXTRA_TARGETS#,}"}
201 make %{?_smp_mflags} all-bfd TARGET-bfd=headers
202 # force reconfiguring
203 rm bfd/Makefile
204 make %{?_smp_mflags}
205 %if "%{TARGET}" == "avr"
206 # build an extra nesC version because nesC requires $'s in identifiers
207 cp -a gas gas-nesc
208 echo '#include "tc-%{TARGET}-nesc.h"' > gas-nesc/targ-cpu.h
209 make -C gas-nesc clean
210 make -C gas-nesc %{?_smp_mflags}
211 %endif
212 %endif
213
214 %check
215 unset LD_AS_NEEDED
216 cd build-dir
217 %if 0%{?cross:1}
218 make -k check CFLAGS="-O2 -g" CXXFLAGS="-O2 -g" || %{make_check_handling}
219 %else
220 make -k check CFLAGS="$RPM_OPT_FLAGS -Wno-unused -Wno-unprototyped-calls" || :
221 %endif
222
223 %install
224 cd build-dir
225 %if 0%{!?cross:1}
226 # installing native binutils
227 %ifarch %gold_archs
228 make DESTDIR=$RPM_BUILD_ROOT install-gold
229 ln -sf ld.gold $RPM_BUILD_ROOT%{_bindir}/gold
230 %endif
231 make DESTDIR=$RPM_BUILD_ROOT install-info install
232 make -C gas/doc DESTDIR=$RPM_BUILD_ROOT install-info-am install-am
233 make DESTDIR=$RPM_BUILD_ROOT install-bfd install-opcodes
234 # we could eventually use alternatives for /usr/bin/ld
235 if test -f $RPM_BUILD_ROOT%{_bindir}/ld.bfd; then
236   rm $RPM_BUILD_ROOT%{_bindir}/ld
237   ln -sf ld.bfd $RPM_BUILD_ROOT%{_bindir}/ld;
238 fi
239 rm -rf $RPM_BUILD_ROOT%{_prefix}/%{HOST}/bin
240 mkdir -p $RPM_BUILD_ROOT%{_prefix}/%{HOST}/bin
241 ln -sf ../../bin/{ar,as,ld,nm,ranlib,strip} $RPM_BUILD_ROOT%{_prefix}/%{HOST}/bin
242 #mv $RPM_BUILD_ROOT%{_prefix}/%{HOST}/lib/ldscripts $RPM_BUILD_ROOT%{_libdir}
243 #ln -sf ../../%{_lib}/ldscripts $RPM_BUILD_ROOT%{_prefix}/%{HOST}/lib/ldscripts
244 # Install header files
245 make -C libiberty install_to_libdir target_header_dir=/usr/include DESTDIR=$RPM_BUILD_ROOT
246 # We want the PIC libiberty.a
247 install -m 644 libiberty/pic/libiberty.a $RPM_BUILD_ROOT%{_libdir}
248 #
249 chmod a+x $RPM_BUILD_ROOT%{_libdir}/libbfd-*
250 chmod a+x $RPM_BUILD_ROOT%{_libdir}/libopcodes-*
251 # No shared linking outside binutils
252 rm $RPM_BUILD_ROOT%{_libdir}/lib{bfd,opcodes}.so
253 rm $RPM_BUILD_ROOT%{_libdir}/lib{bfd,opcodes}.la
254 # Remove unwanted files to shut up rpm
255 rm $RPM_BUILD_ROOT%{_infodir}/configure* $RPM_BUILD_ROOT%{_infodir}/standards.info*
256 rm $RPM_BUILD_ROOT%{_mandir}/man1/dlltool.1 $RPM_BUILD_ROOT%{_mandir}/man1/windres.1 $RPM_BUILD_ROOT%{_mandir}/man1/windmc.1
257 cd ..
258 #%find_lang binutils
259 #%find_lang bfd binutils.lang
260 #%find_lang gas binutils.lang
261 #%find_lang ld binutils.lang
262 #%find_lang opcodes binutils.lang
263 #%find_lang gprof binutils.lang
264 %ifarch %gold_archs
265 #%find_lang gold binutils-gold.lang
266 %endif
267 mkdir -p $RPM_BUILD_ROOT%{_docdir}/%{name}
268 install -m 644 binutils/NEWS $RPM_BUILD_ROOT%{_docdir}/%{name}/NEWS-binutils
269 install -m 644 gas/NEWS $RPM_BUILD_ROOT%{_docdir}/%{name}/NEWS-gas
270 install -m 644 ld/NEWS $RPM_BUILD_ROOT%{_docdir}/%{name}/NEWS-ld
271 %else
272 # installing cross-TARGET-binutils and TARGET-binutils
273 make DESTDIR=$RPM_BUILD_ROOT install
274 # Replace hard links by symlinks, so that rpmlint doesn't complain
275 T=$(basename %buildroot/usr/%{TARGET}*)
276 for f in %buildroot/usr/$T/bin/* ; do
277    ln -sf /usr/bin/$T-$(basename $f) $f
278 done
279 %if "%{TARGET}" == "avr"
280 install -c gas-nesc/as-new $RPM_BUILD_ROOT%{_prefix}/bin/%{TARGET}-nesc-as
281 ln -sf ../../bin/%{TARGET}-nesc-as $RPM_BUILD_ROOT%{_prefix}/%{TARGET}/bin/nesc-as
282 %endif
283 rm -rf $RPM_BUILD_ROOT%{_mandir}
284 rm -rf $RPM_BUILD_ROOT%{_infodir}
285 rm -rf $RPM_BUILD_ROOT%{_prefix}/lib*
286 rm -rf $RPM_BUILD_ROOT%{_prefix}/include
287 rm -f $RPM_BUILD_ROOT%{_prefix}/bin/*-c++filt
288 > ../binutils.lang
289 %endif
290 cd $RPM_BUILD_DIR/binutils-%version
291
292 %clean
293 rm -rf $RPM_BUILD_ROOT
294
295 %if 0%{!?cross:1}
296 %docs_package
297 %endif
298
299 %files 
300 %defattr(-,root,root)
301 %if 0%{!?cross:1}
302 %{_docdir}/%{name}
303 %{_prefix}/%{HOST}/bin/*
304 %{_prefix}/%{HOST}/lib/ldscripts
305 #%{_libdir}/ldscripts
306 %{_bindir}/*
307 %ifarch %gold_archs
308 %exclude %{_bindir}/gold
309 %exclude %{_bindir}/ld.gold
310 %endif
311 %doc %{_infodir}/*.gz
312 %{_libdir}/lib*-%{version}*.so
313 %else
314 %{_prefix}/%{TARGET}*
315 %{_prefix}/bin/*
316 %endif
317
318 %ifarch %gold_archs
319 %files gold 
320 %defattr(-,root,root)
321 %doc gold/NEWS gold/README
322 %{_bindir}/gold
323 %{_bindir}/ld.gold
324 %endif
325
326 %if 0%{!?cross:1}
327 %files devel
328 %defattr(-,root,root)
329 %{_prefix}/include/*.h
330 %{_libdir}/lib*.*a
331 %endif
332
333 %changelog