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