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