1 |
|
2 |
%define lib_major 2 |
3 |
%define lib_name_orig %{package_prefix}%mklibname binutils |
4 |
%define lib_name %{lib_name_orig}%{lib_major} |
5 |
%define dev_name %mklibname binutils -d |
6 |
|
7 |
%define rpm_ver 2.32 |
8 |
%define tar_ver 2.32 |
9 |
%define rel 1 |
10 |
|
11 |
# Define if building a cross-binutils |
12 |
%define build_cross 0 |
13 |
%{expand: %{?cross: %%global build_cross 1}} |
14 |
|
15 |
%if %{build_cross} |
16 |
%define target_cpu %{cross} |
17 |
%define target_platform %{target_cpu}-%_real_vendor-linux%{gnuext} |
18 |
%define program_prefix %{target_platform}- |
19 |
%define package_prefix cross-%{target_cpu}- |
20 |
%else |
21 |
%define target_cpu %{_target_cpu} |
22 |
%define target_platform %{_target_platform} |
23 |
%define program_prefix %{nil} |
24 |
%define package_prefix %{nil} |
25 |
%endif |
26 |
|
27 |
%define arch %(echo %{target_cpu}|sed -e "s/\(i.86\|athlon\)/i386/" -e "s/amd64/x86_64/") |
28 |
%define isarch() %(case " %* " in (*" %{arch} "*) echo 1;; (*) echo 0;; esac) |
29 |
|
30 |
%if %{build_cross} |
31 |
%if %isarch %arm |
32 |
%define gnuext -gnueabi |
33 |
%else |
34 |
%define gnuext -gnu |
35 |
%endif |
36 |
%endif |
37 |
|
38 |
# List of targets where gold can be enabled |
39 |
%define gold_arches %{ix86} x86_64 %{arm} aarch64 |
40 |
|
41 |
Summary: GNU Binary Utility Development Utilities |
42 |
Name: %{package_prefix}binutils |
43 |
# (tmb) NOTE! Fedora does use a faked 2.23.88.*.* versioning to handle the version |
44 |
# downgrade but I dont see the point as Epoch is created for just this purpose |
45 |
Epoch: 1 |
46 |
Version: %{rpm_ver} |
47 |
Release: %mkrel %{rel} |
48 |
License: GPLv3+ |
49 |
Group: Development/Other |
50 |
URL: http://sources.redhat.com/binutils/ |
51 |
Source0: http://ftp.gnu.org/gnu/binutils/binutils-%{tar_ver}.tar.xz |
52 |
Source1: build_cross_binutils.sh |
53 |
Source2: binutils-2.19.50.0.1-output-format.sed |
54 |
Source3: binutils-git.sh |
55 |
%if "%{name}" == "binutils" |
56 |
Requires(post): info-install |
57 |
Requires(preun): info-install |
58 |
Provides: %{lib_name} = %{epoch}:%{version}-%{release} |
59 |
%endif |
60 |
# (tmb) force build with gcc 5.5.0 |
61 |
BuildRequires: gcc >= 5.5.0-1 |
62 |
BuildRequires: autoconf |
63 |
BuildRequires: automake |
64 |
BuildRequires: bison |
65 |
BuildRequires: flex |
66 |
BuildRequires: gettext |
67 |
BuildRequires: texinfo-tex |
68 |
BuildRequires: dejagnu |
69 |
BuildRequires: pkgconfig(zlib) |
70 |
# make check'ing requires libdl.a |
71 |
BuildRequires: glibc-static-devel |
72 |
# gold make check'ing requires libstdc++.a |
73 |
BuildRequires: libstdc++-static-devel |
74 |
|
75 |
# upstream 2.32 branch |
76 |
# Created with binutils-git.sh |
77 |
# (tmb) disble development mode |
78 |
#Patch101: binutils-bfd-disable-development-mode.patch |
79 |
Patch100: 0100-Updated-Swedish-translation-for-the-opcodes-sub-dire.patch |
80 |
Patch101: 0101-Arm-Backport-hlt-to-all-architectures.patch |
81 |
Patch102: 0102-x86-64-Restore-PIC-check-for-PCREL-reloc-against-pro.patch |
82 |
Patch103: 0103-gas-Pass-max_bytes-to-TC_FRAG_INIT.patch |
83 |
|
84 |
# Fedora patches: |
85 |
Patch01: binutils-2.20.51.0.2-libtool-lib64.patch |
86 |
# We don't want this one! |
87 |
# (tmb disabled) Patch02: binutils-2.25-version.patch |
88 |
# Local patch - export demangle.h with the binutils-devel rpm. |
89 |
Patch03: binutils-2.32-export-demangle.h.patch |
90 |
# Disable checks that config.h has been included before system headers. BZ #845084 |
91 |
Patch04: binutils-2.22.52.0.4-no-config-h-check.patch |
92 |
# Import H.J.Lu's Kernel LTO patch. |
93 |
# (tmb disabled) Patch05: binutils-2.26-lto.patch |
94 |
# Include the filename concerned in readelf error messages. |
95 |
Patch06: binutils-2.29-filename-in-error-messages.patch |
96 |
# Revert PR 23161 as it breaks builds |
97 |
Patch11: binutils-do-not-provide-shared-section-symbols.patch |
98 |
# ignore gold dups, still not fixed upstream |
99 |
Patch16: binutils-2.28-ignore-gold-duplicates.patch |
100 |
|
101 |
# Mageia patches |
102 |
# TODO: should really clean up this patch again now... |
103 |
Patch51: binutils-2.32-linux32.patch |
104 |
Patch52: binutils-2.31.1-skip-gold-check.patch |
105 |
|
106 |
# security fixes |
107 |
|
108 |
%description |
109 |
Binutils is a collection of binary utilities, including: |
110 |
|
111 |
* ar: creating modifying and extracting from archives |
112 |
* nm: for listing symbols from object files |
113 |
* objcopy: for copying and translating object files |
114 |
* objdump: for displaying information from object files |
115 |
* ranlib: for generating an index for the contents of an archive |
116 |
* size: for listing the section sizes of an object or archive file |
117 |
* strings: for listing printable strings from files |
118 |
* strip: for discarding symbols (a filter for demangling encoded C++ symbols |
119 |
* addr2line: for converting addresses to file and line |
120 |
* nlmconv: for converting object code into an NLM |
121 |
|
122 |
Install binutils if you need to perform any of these types of actions on |
123 |
binary files. Most programmers will want to install binutils. |
124 |
|
125 |
%package -n %{dev_name} |
126 |
Summary: Main library for %{name} |
127 |
Group: Development/Other |
128 |
Provides: %{name}-devel = %{epoch}:%{version}-%{release} |
129 |
Provides: %{lib_name}-devel = %{epoch}:%{version}-%{release} |
130 |
Requires: zlib-devel |
131 |
|
132 |
%description -n %{dev_name} |
133 |
This package contains BFD and opcodes static libraries and associated |
134 |
header files. Only *.a libraries are included, because BFD doesn't |
135 |
have a stable ABI. Developers starting new projects are strongly encouraged |
136 |
to consider using libelf instead of BFD. |
137 |
|
138 |
%prep |
139 |
%setup -q -n binutils-%{tar_ver} |
140 |
%autopatch -p1 |
141 |
|
142 |
%build |
143 |
# Additional targets |
144 |
ADDITIONAL_TARGETS="" |
145 |
case %{target_cpu} in |
146 |
i*86 | athlon*) |
147 |
ADDITIONAL_TARGETS="x86_64-%{_target_vendor}-%{_target_os}" |
148 |
;; |
149 |
esac |
150 |
if [[ -n "$ADDITIONAL_TARGETS" ]]; then |
151 |
TARGET_CONFIG="$TARGET_CONFIG --enable-targets=$ADDITIONAL_TARGETS" |
152 |
fi |
153 |
|
154 |
case %{target_cpu} in |
155 |
i*86 | athlon* | aarch64*) |
156 |
TARGET_CONFIG="$TARGET_CONFIG --enable-64-bit-bfd" |
157 |
;; |
158 |
esac |
159 |
|
160 |
case %{target_cpu} in x86_64*|i?86*|arm*|aarch64*) |
161 |
TARGET_CONFIG="$TARGET_CONFIG --enable-targets=x86_64-pep" |
162 |
;; |
163 |
esac |
164 |
|
165 |
%if "%{name}" != "binutils" |
166 |
%define _program_prefix %{program_prefix} |
167 |
TARGET_CONFIG="$TARGET_CONFIG --target=%{target_platform}" |
168 |
%endif |
169 |
|
170 |
# Don't build shared libraries in cross binutils |
171 |
%if "%{name}" == "binutils" |
172 |
TARGET_CONFIG="$TARGET_CONFIG --enable-shared --with-pic" |
173 |
%endif |
174 |
|
175 |
# Binutils comes with its own custom libtool |
176 |
# [gb] FIXME: but system libtool also works and has relink fix |
177 |
%define __libtoolize /bin/true |
178 |
|
179 |
# Build main binaries |
180 |
rm -rf objs |
181 |
mkdir objs |
182 |
pushd objs |
183 |
CONFIGURE_TOP=.. %configure2_5x $TARGET_CONFIG --with-bugurl=https://bugs.mageia.org/ \ |
184 |
--enable-gold \ |
185 |
--enable-plugins \ |
186 |
--enable-relro=yes |
187 |
# There seems to be some problems with builds of gold randomly failing whenever |
188 |
# going through the build system, so let's try workaround this by trying to do |
189 |
# make once again when it happens... |
190 |
%make_build tooldir=%{_prefix} || make tooldir=%{_prefix} |
191 |
popd |
192 |
|
193 |
%check |
194 |
# All Tests must pass on x86 and x86_64 |
195 |
# rtp: some ld-arm tests are failing. |
196 |
# they're fixed in 2.21 but didn't find the fixes |
197 |
echo ====================TESTING========================= |
198 |
%if %isarch i386 x86_64 |
199 |
%make_build -C objs check LDFLAGS="" || : |
200 |
# random build failures with gold seems to happen during check as well... |
201 |
make -k -C objs gold-check LDFLAGS="" || : |
202 |
%else |
203 |
%make_build -C objs -k check LDFLAGS="" || : |
204 |
%endif |
205 |
echo ====================TESTING END===================== |
206 |
|
207 |
logfile="%{name}-%{version}-%{release}.log" |
208 |
rm -f $logfile; find . -name "*.sum" | xargs cat >> $logfile |
209 |
|
210 |
%install |
211 |
mkdir -p $RPM_BUILD_ROOT%{_prefix} |
212 |
%make_install -C objs |
213 |
|
214 |
rm -f $RPM_BUILD_ROOT%{_mandir}/man1/{dlltool,nlmconv,windres}* |
215 |
rm -f $RPM_BUILD_ROOT%{_infodir}/dir |
216 |
rm -f $RPM_BUILD_ROOT%{_libdir}/*.la |
217 |
rm -f $RPM_BUILD_ROOT%{_libdir}/lib{bfd,opcodes}.so |
218 |
|
219 |
%if "%{name}" == "binutils" |
220 |
make -C objs prefix=$RPM_BUILD_ROOT%{_prefix} infodir=$RPM_BUILD_ROOT%{_infodir} install-info |
221 |
install -m 644 include/libiberty.h $RPM_BUILD_ROOT%{_includedir}/ |
222 |
%if %isarch %mips |
223 |
install -m 644 objs/libiberty/libiberty.a $RPM_BUILD_ROOT%{_libdir}/ |
224 |
# Ship with the PIC libiberty |
225 |
%else |
226 |
install -m 644 objs/libiberty/pic/libiberty.a $RPM_BUILD_ROOT%{_libdir}/ |
227 |
%endif |
228 |
rm -rf $RPM_BUILD_ROOT%{_prefix}/%{_target_platform}/ |
229 |
|
230 |
# Sanity check --enable-64-bit-bfd really works. |
231 |
%if %isarch i*86 athlon* |
232 |
grep '^#define BFD_ARCH_SIZE 64$' %{buildroot}%{_prefix}/include/bfd.h |
233 |
%endif |
234 |
|
235 |
# Fix multilib conflicts of generated values by __WORDSIZE-based expressions. |
236 |
%if %isarch %{ix86} x86_64 |
237 |
sed -i -e '/^#include "ansidecl.h"/{p;s~^.*$~#include <bits/wordsize.h>~;}' \ |
238 |
-e 's/^#define BFD_DEFAULT_TARGET_SIZE \(32\|64\) *$/#define BFD_DEFAULT_TARGET_SIZE __WORDSIZE/' \ |
239 |
-e 's/^#define BFD_HOST_64BIT_LONG [01] *$/#define BFD_HOST_64BIT_LONG (__WORDSIZE == 64)/' \ |
240 |
-e 's/^#define BFD_HOST_64_BIT \(long \)\?long *$/#if __WORDSIZE == 32\ |
241 |
#define BFD_HOST_64_BIT long long\ |
242 |
#else\ |
243 |
#define BFD_HOST_64_BIT long\ |
244 |
#endif/' \ |
245 |
-e 's/^#define BFD_HOST_U_64_BIT unsigned \(long \)\?long *$/#define BFD_HOST_U_64_BIT unsigned BFD_HOST_64_BIT/' \ |
246 |
%{buildroot}%{_prefix}/include/bfd.h |
247 |
%endif |
248 |
touch -r bfd/bfd-in2.h %{buildroot}%{_prefix}/include/bfd.h |
249 |
|
250 |
# Generate .so linker scripts for dependencies; imported from glibc/Makerules: |
251 |
|
252 |
# This fragment of linker script gives the OUTPUT_FORMAT statement |
253 |
# for the configuration we are building. |
254 |
OUTPUT_FORMAT="\ |
255 |
/* Ensure this .so library will not be used by a link for a different format |
256 |
on a multi-architecture system. */ |
257 |
$(gcc $CFLAGS $LDFLAGS -shared -x c /dev/null -o /dev/null -Wl,--verbose -v 2>&1 | sed -n -f "%{SOURCE2}")" |
258 |
|
259 |
tee %{buildroot}%{_libdir}/libbfd.so <<EOH |
260 |
/* GNU ld script */ |
261 |
|
262 |
$OUTPUT_FORMAT |
263 |
|
264 |
/* The libz dependency is unexpected by legacy build scripts. */ |
265 |
INPUT ( %{_libdir}/libbfd.a -liberty -lz ) |
266 |
EOH |
267 |
|
268 |
tee %{buildroot}%{_libdir}/libopcodes.so <<EOH |
269 |
/* GNU ld script */ |
270 |
|
271 |
$OUTPUT_FORMAT |
272 |
|
273 |
INPUT ( %{_libdir}/libopcodes.a -lbfd -lz ) |
274 |
EOH |
275 |
|
276 |
%else |
277 |
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a |
278 |
rm -rf $RPM_BUILD_ROOT%{_infodir} |
279 |
rm -rf $RPM_BUILD_ROOT%{_datadir}/locale/ |
280 |
rm -f $RPM_BUILD_ROOT%{_prefix}/%{_target_platform}/%{target_cpu}-linux/lib/*.la |
281 |
%endif |
282 |
|
283 |
%find_lang binutils |
284 |
%find_lang gas |
285 |
%find_lang ld |
286 |
%find_lang gold |
287 |
%find_lang gprof |
288 |
cat gas.lang >> binutils.lang |
289 |
cat ld.lang >> binutils.lang |
290 |
cat gold.lang>> binutils.lang |
291 |
cat gprof.lang >> binutils.lang |
292 |
|
293 |
%find_lang opcodes |
294 |
%find_lang bfd |
295 |
cat opcodes.lang >> binutils.lang |
296 |
cat bfd.lang >> binutils.lang |
297 |
|
298 |
%if "%{name}" == "binutils" |
299 |
%post |
300 |
%_install_info as.info |
301 |
%_install_info bfd.info |
302 |
%_install_info binutils.info |
303 |
%_install_info gasp.info |
304 |
%_install_info gprof.info |
305 |
%_install_info ld.info |
306 |
%_install_info standards.info |
307 |
%endif |
308 |
|
309 |
%if "%{name}" == "binutils" |
310 |
%preun |
311 |
%_remove_install_info as.info |
312 |
%_remove_install_info bfd.info |
313 |
%_remove_install_info binutils.info |
314 |
%_remove_install_info gasp.info |
315 |
%_remove_install_info gprof.info |
316 |
%_remove_install_info ld.info |
317 |
%_remove_install_info standards.info |
318 |
%endif |
319 |
|
320 |
%files -f binutils.lang |
321 |
%{_bindir}/%{program_prefix}addr2line |
322 |
%{_bindir}/%{program_prefix}ar |
323 |
%{_bindir}/%{program_prefix}as |
324 |
%{_bindir}/%{program_prefix}c++filt |
325 |
%{_bindir}/%{program_prefix}dwp |
326 |
%{_bindir}/%{program_prefix}elfedit |
327 |
%{_bindir}/%{program_prefix}gprof |
328 |
%{_bindir}/%{program_prefix}ld |
329 |
%{_bindir}/%{program_prefix}ld.bfd |
330 |
%if %isarch %{gold_arches} |
331 |
%{_bindir}/%{program_prefix}ld.gold |
332 |
%endif |
333 |
%{_bindir}/%{program_prefix}nm |
334 |
%{_bindir}/%{program_prefix}objcopy |
335 |
%{_bindir}/%{program_prefix}objdump |
336 |
%{_bindir}/%{program_prefix}ranlib |
337 |
%{_bindir}/%{program_prefix}readelf |
338 |
%{_bindir}/%{program_prefix}size |
339 |
%{_bindir}/%{program_prefix}strings |
340 |
%{_bindir}/%{program_prefix}strip |
341 |
%{_mandir}/man1/* |
342 |
%if "%{name}" == "binutils" |
343 |
%{_infodir}/*info* |
344 |
%{_libdir}/libbfd-%{version}*.so |
345 |
%{_libdir}/libopcodes-%{version}*.so |
346 |
%else |
347 |
%{_prefix}/%{target_platform}/bin/* |
348 |
%{_prefix}/%{target_platform}/lib/ldscripts |
349 |
%endif |
350 |
|
351 |
%if "%{name}" == "binutils" |
352 |
%files -n %{dev_name} |
353 |
%{_includedir}/*.h |
354 |
%{_libdir}/libbfd.a |
355 |
%{_libdir}/libbfd.so |
356 |
%{_libdir}/libopcodes.a |
357 |
%{_libdir}/libopcodes.so |
358 |
%{_libdir}/libiberty.a |
359 |
%endif |