File cross-arm-binutils.spec of Package cross-arm-binutils
%define realname binutils
%define realver 2.40
%define srcext tar.bz2
%define prefix %_prefix
%define cross_cpu arm
%define cross_target %{cross_cpu}-none-eabihf
%define build_target %{cross_target}
%define platform_dir %{prefix}/%{build_target}
%define platform_ld %{build_target}-ld
# Common info
Name: %{?cross_target:cross-%{cross_cpu}-}%{realname}
Version: %{realver}
Release: %{?extraver:0.}1%{?dist}
License: GFDL-1.3 and GPL-3.0+
Group: Development/Tools/Building
URL: http://www.gnu.org/software/binutils/
Summary: GNU binutils
# Install-time parameters
Requires: /usr/sbin/update-alternatives
# Build-time parameters
BuildRequires: binutils gcc cpp bison flex gettext zlib-devel
BuildRequires: gcc-c++ libstdc++-devel
BuildRequires: pkgconfig(libzstd) >= 1.4.0
%if 0%{?suse_version}
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRoot: %{_tmppath}/%{name}-root
Source: http://ftp.gnu.org/gnu/binutils/%{realname}-%{realver}%{?extraver}.%{srcext}
%description
These are the GNU binutils. These are utilities of use when dealing
with binary files, either object files or executables. These tools
consist of the linker (ld), the assembler (gas), and the profiler
(gprof) each of which have their own sub-directory named after them.
There is also a collection of other binary tools, including the
disassembler (objdump) in this directory. These tools make use of a
pair of libraries (bfd and opcodes) and a common set of header files
(include).
%package gold
Group: Development/Tools/Building
Summary: ELF linker
Requires: %{name} = %{version}
%description gold
gold is an ELF linker. It is intended to have complete support for
ELF and to run as fast as possible on modern systems. For normal use
it is a drop-in replacement for the older GNU linker.
# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{realver}%{?extraver}
# Do copying instead of hardlinking
sed -i '/DESTDIR/ s/ln /cp /' binutils/Makefile.in
sed -i '/DESTDIR/ s/ln /cp /' gas/Makefile.in
sed -i '/DESTDIR/ s/ln /cp /' gold/Makefile.in
sed -i '/DESTDIR/ s/ln /cp /' ld/Makefile.in
%build
_CFLAGS='%{optflags}'
_LDFLAGS='-Wl,--as-needed -Wl,--strip-all -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro'
%configure \
--program-prefix=%{build_target}- \
--libdir=%{platform_dir}/%{_lib} \
--target=%{build_target} \
--disable-static \
--enable-gold \
--enable-ld \
--enable-lto \
--enable-objc-gc \
--with-system-zlib \
\
--disable-plugins \
\
--enable-threads \
--with-lib-path=/%{_lib}:%{_libdir} \
\
--disable-nls \
\
CFLAGS="$_CFLAGS" \
CXXFLAGS="$_CFLAGS" \
LDFLAGS="$_LDFLAGS" \
|| cat config.log
%{__make} %{?_smp_mflags}
%install
%{__make} install DESTDIR=%{buildroot} target_header_dir=%{_includedir}
# Handle file duplicates
for binary in %{buildroot}%{platform_dir}/bin/*; do
%{__ln_s} -fn ../../bin/%{build_target}-${binary##*/} $binary
done
# Prepare alternatives
%{__install} -d -m755 %{buildroot}%{_sysconfdir}/alternatives/
touch %{buildroot}%{_sysconfdir}/alternatives/%{platform_ld}
%{__ln_s} -f %{_sysconfdir}/alternatives/%{platform_ld} %{buildroot}%{_bindir}/%{build_target}-ld
%{__ln_s} -f %{_sysconfdir}/alternatives/%{platform_ld} %{buildroot}%{platform_dir}/bin/ld
%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}
%files
%defattr(-,root,root)
%license COPYING*
%doc MAINTAINERS binutils/NEWS binutils/README
%{_bindir}/*
%{platform_dir}/
%doc %{_mandir}/man1/*
%ghost %{_sysconfdir}/alternatives/%{platform_ld}
%exclude %{platform_dir}/bin/ld.gold
%exclude %{_bindir}/%{build_target}-ld.gold
%exclude %{_infodir}
%files gold
%defattr(-,root,root)
%doc gold/README
%{_bindir}/%{build_target}-ld.gold
%ghost %{_sysconfdir}/alternatives/%{platform_ld}
%{platform_dir}/bin/ld
%{platform_dir}/bin/ld.gold
%post
/usr/sbin/update-alternatives \
--install %{platform_dir}/bin/ld %{platform_ld} %{_bindir}/%{platform_ld}.bfd 1
%postun
/usr/sbin/update-alternatives --auto %{platform_ld}
%post gold
/usr/sbin/update-alternatives \
--install %{platform_dir}/bin/ld %{platform_ld} %{_bindir}/%{platform_ld}.gold 2
%postun gold
/usr/sbin/update-alternatives --auto %{platform_ld}
%changelog