packaging: bump version to 2.42
[platform/upstream/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 %ifarch riscv64
19 %define ARCH riscv64
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 %{!?cross:
31 %define binutils_run_tests 1
32 }
33 %endif
34
35 %if 0%{?dump_configure}
36 %define binutils_dump_configure 1
37 %endif
38
39 # Enable this when testing on device to:
40 # 1. Enable macro to turn on testsuite building ('binutils_run_tests 1')
41 # 2. Keep 'build-dir/' folder in build stage as we do not want to rebuild all
42 # binutils again on device after invoking rpmbuild --short-circuit -bc ...
43 # 3. Skip configure and make commands and go directly to 'make check'
44 %if 0%{?run_tests_on_device}
45 %define binutils_run_tests 1
46 %define binutils_keep_build_dir 1
47 %define binutils_skip_configure 1
48 %define binutils_skip_make 1
49 %endif
50
51 # Exit right after 'make ..' step to keep all object files produced by binutils build
52 %if 0%{?exit_on_make_finish}
53 %define binutils_exit_on_make_finish 1
54 %endif
55
56 Name:           binutils%{?cross:-%{cross}}
57 BuildRequires:  binutils-libs
58 BuildRequires:  makeinfo
59 BuildRequires:  bison
60 BuildRequires:  flex
61 BuildRequires:  ncurses-devel
62 BuildRequires:  zlib-devel
63 BuildRequires:  gcc-c++
64 %if 0%{?binutils_run_tests}
65 BuildRequires:  dejagnu
66 BuildRequires:  glibc-devel-static
67 %endif
68 %if 0%{?binutils_dump_configure}
69 BuildRequires: configure-dumper
70 %endif
71 Version:        2.42
72 Release:        0
73 Url:            http://www.gnu.org/software/binutils/
74 Summary:        GNU Binutils
75 License:        GFDL-1.3 and GPL-3.0+
76 Group:          Development/Building
77 %{?cross:ExcludeArch: %{cross}}
78 Source:         binutils-%{version}.tar.bz2
79 Source1001:     binutils.manifest
80
81 %description
82 C compiler utilities: ar, as, gprof, ld, nm, objcopy, objdump, ranlib,
83 size, strings, and strip. These utilities are needed whenever you want
84 to compile a program or kernel.
85
86 %package libs
87 Summary:        Shared library files for binutils
88 License:        GPL-2.0+
89
90 %description libs
91 It contains the binutils shared libraries that applications can link
92 to at runtime.
93
94 %ifnarch riscv64
95 %package gold
96 Summary:        The gold linker
97 License:        GPL-3.0+
98 Group:          Development/Building
99
100 %description gold
101 gold is an ELF linker.  It is intended to have complete support for ELF
102 and to run as fast as possible on modern systems.  For normal use it is
103 a drop-in replacement for the older GNU linker.
104 %endif
105
106 %package devel
107 Summary:        GNU binutils (BFD development files)
108 License:        GPL-3.0+
109 Group:          Development/Building
110 Requires: zlib-devel
111
112 %description devel
113 This package includes header files and static libraries necessary to
114 build programs which use the GNU BFD library, which is part of
115 binutils.
116
117 %{?binutils_run_tests:
118 %package testresults
119 Summary:       Testsuite results
120 License:       Public Domain
121 Group:         Development/Building
122 %description testresults
123 Results from running the binutils tests.
124 }
125
126 %{?binutils_dump_configure:
127 %package configure-dump
128 Summary:       GNU Binutils configure dump
129 License:       GPL-3.0+
130 Group:         Development/Languages
131 %description configure-dump
132 This package contains dump of configure variables of Binutils
133 }
134
135 %prep
136 %setup -q -n binutils-%{version}
137 cp %{SOURCE1001} .
138
139
140 %build
141 RPM_OPT_FLAGS="$RPM_OPT_FLAGS -Wno-error %{?cross:-DIGNORE_BROKEN_PLUGINS}"
142 export CFLAGS="${RPM_OPT_FLAGS}"
143 export CXXFLAGS="${RPM_OPT_FLAGS}"
144
145 %{!?binutils_keep_build_dir:
146 rm -rf build-dir
147 }
148 # Remove gdb and sim since they have separate gdb package
149 rm -rf gdb gdbserver gdbsupport sim
150
151 mkdir -p build-dir
152 cd build-dir
153
154 %{!?binutils_skip_configure:
155 %{?binutils_dump_configure:patch_configure.pl ..}   # Add debug prints into configure
156 ../configure \
157         --prefix=%{_prefix} --libdir=%{_libdir} \
158         --infodir=%{_infodir} --mandir=%{_mandir} \
159         --with-bugurl=http://bugs.tizen.org/ \
160         --with-sysroot=/ \
161 %ifarch riscv64
162         --with-lib-path="=%{_libdir}" \
163 %endif
164         --disable-nls \
165         --with-separate-debug-dir=%{_prefix}/lib/debug \
166         --with-pic \
167         --build=%{host_arch} --target=%{target_arch} \
168         --host=%{host_arch} \
169 %{?cross: \
170         --enable-targets=%{target_arch} \
171         --enable-64-bit-bfd \
172 } \
173 %{!?cross: \
174         --enable-targets=aarch64-tizen-linux,armv7l-tizen-linux,armv7hl-tizen-linux,armv8l-tizen-linux,i686-tizen-linux,x86_64-tizen-linux,riscv64-tizen-linux \
175 } \
176         --enable-plugins \
177 %ifnarch riscv64
178         --enable-gold \
179 %endif
180         --enable-shared \
181         --enable-new-dtags \
182         --enable-relro=no \
183         --disable-gprofng \
184 %ifarch %ix86
185         --disable-separate-code
186 %endif
187
188 }
189
190 %{!?binutils_skip_make:
191 make %{?_smp_mflags}
192 %{?binutils_dump_configure:
193  dump_configure.pl .. . \
194                    --project binutils \
195                    --project-version %{version} \
196                    --out_db binutils-%{version}-%{release}-%_project-%_repository.db
197  }
198 }
199
200 %{?binutils_exit_on_make_finish:
201 exit 1
202 }
203
204 %{?binutils_run_tests:
205 echo "Run testsuite"
206 # asan needs a whole shadow address space
207 ulimit -v unlimited || true
208 make -k check %{?_smp_mflags} || true
209 mkdir ../testresults
210 for tool in $(find -name '*.sum' -exec basename {} \; | sort -u | sed -e 's/.sum//'); do
211 ../contrib/dg-extract-results.sh -t $tool $(find -name '*.sum') | tee -a ../testresults/test_summary.txt
212 done
213 }
214
215 %install
216 cd build-dir
217 make DESTDIR=$RPM_BUILD_ROOT install
218
219 export LINKERS="ld ld.bfd"
220 %ifnarch riscv64
221 # There's neither native gold nor cross-gold for riscv64 yet
222 %{!?riscv64:export LINKERS="ld ld.bfd ld.gold"}
223 %else
224 %endif
225
226 # Copy instead of hardlinks
227 for binary in ar as ${LINKERS} nm obj{dump,copy} ranlib strip
228 do
229   rm %{buildroot}%{_prefix}/%{target_arch}/bin/$binary
230 %{!?cross:
231   cp %{buildroot}%{_bindir}/$binary %{buildroot}%{_prefix}/%{target_arch}/bin/$binary
232 }
233 %{?cross:
234   cp %{buildroot}%{_bindir}/%{target_arch}-$binary %{buildroot}%{_prefix}/%{target_arch}/bin/$binary
235 }
236 done
237
238 install -m 644 libiberty/pic/libiberty.a %{buildroot}%{_prefix}/%{_lib}
239 install -m 644 ../include/libiberty.h %{buildroot}%{_prefix}/include
240
241 %{?binutils_run_tests:
242   find . \( -name "*.sum" -o -name "*.log" -a \! -name "config.log" \) -exec tar -rf testresults.tar {} \;
243   mkdir -p ../testresults && tar -xf testresults.tar -C ../testresults
244   find ../testresults/ -type f -exec chmod 644 {} \;
245 }
246
247 # Remove unwanted files to shut up rpm
248 %{remove_docs}
249 rm -rf %{buildroot}%{_bindir}/gcore
250 rm -rf %{buildroot}%{_libdir}/lib{bfd,ctf,ctf-nobfd,opcodes,inproctrace,sframe}.la
251 %{?cross:
252 rm -rf %{buildroot}%{_prefix}/%{target_arch}/lib/ldscripts
253 rm -rf %{buildroot}%{_prefix}/%{host_arch}
254 rm -rf %{buildroot}%{_includedir}
255 rm -rf %{buildroot}%{_prefix}/lib*
256 rm -rf %{buildroot}%{_datadir}
257 }
258
259 %{?binutils_dump_configure:
260   install -D -m 0644 binutils-%{version}-%{release}-%_project-%_repository.db %{buildroot}%{_datadir}/binutils-%{version}-%{release}-%_project-%_repository.db
261 }
262
263 %files
264 %manifest binutils.manifest
265 %defattr(-,root,root)
266 %{_bindir}/*
267 %{_prefix}/%{target_arch}/bin/*
268 %{!?cross:
269 %exclude %{_bindir}/ld.gold
270 %exclude %{_prefix}/%{target_arch}/bin/ld.gold
271 %{_prefix}/%{host_arch}/lib/ldscripts
272
273 %files libs
274 %{_libdir}/*.so*
275 %{_libdir}/bfd-plugins/*.so
276
277 %files devel
278 %manifest binutils.manifest
279 %defattr(-,root,root)
280 %{_includedir}/*.h
281 %{_libdir}/*.a
282
283 %ifnarch riscv64
284 %files gold
285 %manifest binutils.manifest
286 %defattr(-,root,root)
287 %{_bindir}/ld.gold
288 %{_prefix}/%{target_arch}/bin/ld.gold
289 %endif
290 }
291
292 %{?binutils_run_tests:
293 %files testresults
294 %defattr(-,root,root)
295 %doc testresults/test_summary.txt
296 %doc testresults/*
297 }
298
299 %{?binutils_dump_configure:
300 %files configure-dump
301 %manifest binutils.manifest
302 %{_datadir}/binutils-%{version}-%{release}-%_project-%_repository.db
303 }
304
305 %changelog