packaging: Enable testing infrastructure
[external/binutils.git] / packaging / binutils.spec
1 %ifarch armv7l
2 %define ARCH armv7l
3 %define ABI eabi
4 %endif
5 %ifarch armv7hl
6 %define ARCH armv7hl
7 %define ABI eabihf
8 %endif
9 %ifarch %ix86
10 %define ARCH i586
11 %endif
12 %ifarch x86_64
13 %define ARCH x86_64
14 %endif
15 %ifarch aarch64
16 %define ARCH aarch64
17 %endif
18
19 %define host_arch %{ARCH}-tizen-linux-gnu%{?ABI}
20
21 %define target_cpu %{?cross}%{!?cross:%{ARCH}}
22 %define target_abi %{?cross:%{?armv7l:eabi}%{?armv7hl:eabihf}}%{!?cross:%{?ABI}}
23
24 %define target_arch %{target_cpu}-tizen-linux-gnu%{?target_abi}
25
26 %if 0%{?run_tests}
27 %define binutils_run_tests 1
28 %endif
29
30 # Enable this when testing on device to:
31 # 1. Enable macro to turn on testsuite building ('binutils_run_tests 1')
32 # 2. Keep 'obj/' folder in build stage as we do not want to rebuild all binutils
33 # again on device after invoking rpmbuild --short-circuit -bc ...
34 # 3. Skip configure and make commands and go directly to 'make check'
35 %if 0%{?run_tests_on_device}
36 %define binutils_run_tests 1
37 %define binutils_keep_build_dir 1
38 %define binutils_skip_configure 1
39 %define binutils_skip_make 1
40 %endif
41
42 # Exit right after 'make ..' step to keep all object files produced by binutils build
43 %if 0%{?exit_on_make_finish}
44 %define binutils_exit_on_make_finish 1
45 %endif
46
47 Name:           binutils%{?cross:-%{cross}}
48 BuildRequires:  makeinfo
49 BuildRequires:  bison
50 BuildRequires:  flex
51 BuildRequires:  expat-devel
52 BuildRequires:  ncurses-devel
53 BuildRequires:  zlib-devel
54 BuildRequires:  gcc-c++
55 %if 0%{?binutils_run_tests}
56 BuildRequires:  dejagnu
57 BuildRequires:  glibc-devel-static
58 %endif
59 Version:        2.33.1
60 Release:        0
61 Url:            http://www.gnu.org/software/binutils/
62 Summary:        GNU Binutils
63 License:        GFDL-1.3 and GPL-3.0+
64 Group:          Development/Building
65 %{?cross:ExcludeArch: %{cross}}
66 Source:         binutils-%{version}.tar.bz2
67 Source1001:     binutils.manifest
68
69 %description
70 C compiler utilities: ar, as, gprof, ld, nm, objcopy, objdump, ranlib,
71 size, strings, and strip. These utilities are needed whenever you want
72 to compile a program or kernel.
73
74
75 %package gold
76 Summary:        The gold linker
77 License:        GPL-3.0+
78 Group:          Development/Building
79
80 %description gold
81 gold is an ELF linker.  It is intended to have complete support for ELF
82 and to run as fast as possible on modern systems.  For normal use it is
83 a drop-in replacement for the older GNU linker.
84
85
86 %package devel
87 Summary:        GNU binutils (BFD development files)
88 License:        GPL-3.0+
89 Group:          Development/Building
90 Requires: zlib-devel
91
92 %description devel
93 This package includes header files and static libraries necessary to
94 build programs which use the GNU BFD library, which is part of
95 binutils.
96
97 %{!?cross:
98 %package -n gdb
99 Summary:        A GNU source-level debugger for C, C++, Java and other languages
100 License:        GPL-3.0+
101 Group:          Development/Building
102 Requires:       python
103
104 %description -n gdb
105 GDB, the GNU debugger, allows you to debug programs written in C, C++,
106 Java, and other languages, by executing them in a controlled fashion
107 and printing their data.
108 }
109 %package -n gdb-server
110 Summary: A standalone server for GDB (the GNU source-level debugger)
111
112 %description -n gdb-server
113 GDB, the GNU debugger, allows you to debug programs written in C, C++,
114 Java, and other languages, by executing them in a controlled fashion
115 and printing their data.
116
117 This package provides a program that allows you to run GDB on a different machine than the one
118 which is running the program being debugged.
119
120 %{?binutils_run_tests:
121 %package testresults
122 Summary:       Testsuite results
123 License:       SUSE-Public-Domain
124 Group:         Development/Languages
125 %description testresults
126 Results from running the gcc and target library testsuites.
127 }
128
129
130 %prep
131 %setup -q -n binutils-%{version}
132 cp %{SOURCE1001} .
133
134
135 %build
136 RPM_OPT_FLAGS="$RPM_OPT_FLAGS -Wno-error %{?cross:-DIGNORE_BROKEN_PLUGINS}"
137 export CFLAGS="${RPM_OPT_FLAGS}"
138 export CXXFLAGS="${RPM_OPT_FLAGS}"
139
140 %{!?binutils_keep_build_dir:
141 rm -rf build-dir
142 }
143 mkdir build-dir
144 cd build-dir
145
146 %{!?binutils_skip_configure:
147 ../configure \
148         --prefix=%{_prefix} --libdir=%{_libdir} \
149         --infodir=%{_infodir} --mandir=%{_mandir} \
150         --with-bugurl=https://bugs.tizen.org/ \
151         --with-sysroot=/ \
152         --disable-nls \
153         --with-separate-debug-dir=%{_prefix}/lib/debug \
154         --with-pic \
155         --build=%{host_arch} --target=%{target_arch} \
156         --host=%{host_arch} \
157         %{?annobin_verification: --enable-annobin-verification=warn } \
158         %{?annobin_verification_strict: --enable-annobin-verification=strict } \
159 %{?cross: \
160         --enable-targets=%{target_arch} \
161         --enable-64-bit-bfd \
162 } \
163 %{!?cross: \
164         --enable-targets=aarch64-tizen-linux,armv7l-tizen-linux,armv7hl-tizen-linux,armv8l-tizen-linux,i686-tizen-linux,x86_64-tizen-linux \
165 } \
166         --enable-plugins \
167         --enable-gold \
168         --enable-shared \
169         --enable-new-dtags \
170         --with-gdb-datadir=%{_datadir}/gdb              \
171         --enable-gdb-build-warnings=,-Wno-unused        \
172         --with-separate-debug-dir=/usr/lib/debug        \
173         --disable-sim                                   \
174         --with-expat
175 }
176 %{!?binutils_skip_make:
177 make %{?_smp_mflags}
178 }
179
180 %{?binutils_exit_on_make_finish:
181  exit 1
182 }
183
184 %{?binutils_run_tests:
185   echo "Run testsuite"
186   # asan needs a whole shadow address space
187   ulimit -v unlimited || true
188   make -k check %{?_smp_mflags} || true
189   mkdir ../testresults
190   ../contrib/test_summary | tee ../testresults/test_summary.txt
191 }
192
193 %install
194 cd build-dir
195 make DESTDIR=$RPM_BUILD_ROOT install
196
197 # Copy instead of hardlinks
198 for binary in ar as ld{,.bfd,.gold} nm obj{dump,copy} ranlib strip
199 do
200   rm %{buildroot}%{_prefix}/%{target_arch}/bin/$binary
201 %{!?cross:
202   cp %{buildroot}%{_bindir}/$binary %{buildroot}%{_prefix}/%{target_arch}/bin/$binary
203 }
204 %{?cross:
205   cp %{buildroot}%{_bindir}/%{target_arch}-$binary %{buildroot}%{_prefix}/%{target_arch}/bin/$binary
206 }
207 done
208
209 install -m 644 libiberty/pic/libiberty.a %{buildroot}%{_prefix}/%{_lib}
210 install -m 644 ../include/libiberty.h %{buildroot}%{_prefix}/include
211
212 %{?binutils_run_tests:
213   find . \( -name "*.sum" -o -name "*.log" -a \! -name "config.log" \) -exec tar -rf testresults.tar {} \; 
214   mkdir -p ../testresults && tar -xf testresults.tar -C ../testresults 
215   find ../testresults/ -type f -exec chmod 644 {} \;
216 }
217
218 # Remove unwanted files to shut up rpm
219 %{remove_docs}
220 rm -rf %{buildroot}%{_libdir}/lib{bfd,opcodes,inproctrace}.{so,la}
221 %{?cross:
222 rm -rf %{buildroot}%{_prefix}/%{target_arch}/lib/ldscripts
223 rm -rf %{buildroot}%{_prefix}/%{host_arch}
224 rm -rf %{buildroot}%{_includedir}
225 rm -rf %{buildroot}%{_prefix}/lib*
226 rm -rf %{buildroot}%{_datadir}
227 }
228
229 %files
230 %manifest binutils.manifest
231 %defattr(-,root,root)
232 %{_bindir}/*
233 %{_prefix}/%{target_arch}/bin/*
234 %{!?cross:
235 %exclude %{_bindir}/gdb*
236 %exclude %{_bindir}/ld.gold
237 %exclude %{_prefix}/%{target_arch}/bin/ld.gold
238 %{_libdir}/*.so
239 %{_prefix}/%{host_arch}/lib/ldscripts
240
241 %files devel
242 %manifest binutils.manifest
243 %defattr(-,root,root)
244 %{_includedir}/*.h
245 %{_includedir}/gdb/*.h
246 %{_libdir}/*.a
247
248 %files gold
249 %manifest binutils.manifest
250 %defattr(-,root,root)
251 %{_bindir}/ld.gold
252 %{_prefix}/%{target_arch}/bin/ld.gold
253
254 %files -n gdb
255 %{_datadir}/gdb
256 %{_bindir}/gcore
257 %{_bindir}/gdb
258 %{_bindir}/gdb-add-index
259
260 %files -n gdb-server
261 %{_bindir}/gdbserver
262 }
263
264 %{?binutils_run_tests:
265 %files testresults
266 %defattr(-,root,root)
267 %doc testresults/test_summary.txt
268 %doc testresults/*
269 }
270
271 %changelog