File cross-arm-none-eabi-binutils.spec of Package cross-arm-none-eabi-binutils

#
# spec file for package cross-arm-none-eabi-binutils
#
# Copyright (c) 2022 SUSE LLC
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#

%global binutils_ver   2.39
%global processor_arch arm
%global target         %{processor_arch}-none-eabi
%global cross_target   cross-%{target}

%define DIST %(echo '%distribution' | sed 's/ (.*)//')

%define bootstrap 0

Name:           %{cross_target}-binutils
Version:        2.39
Release:        1
Summary:        GNU Binutils for cross-compilation for %{target} target
Group:          Development/Tools/Building
# Most of the sources are licensed under GPLv3+ with these exceptions:
# LGPLv2+ bfd/hosts/x86-64linux.h, include/demangle.h, include/xregex2.h,
# GPLv2+  gprof/cg_print.h
# BSD     gprof/cg_arcs.h, gprof/utils.c, ld/elf-hints-local.h,
# Public Domain libiberty/memmove.c
License:        GPL-2.0+ and GPL-3.0+ and LGPL-2.0+ and BSD-2-Clause and BSD-3-Clause
URL:            https://www.gnu.org/software/binutils/
Source0:        https://ftp.gnu.org/gnu/binutils/binutils-%{version}.tar.bz2
BuildRequires:  gcc-c++
BuildRequires:  makeinfo
BuildRequires:  flex
BuildRequires:  bison
BuildRequires:  ppl-devel
BuildRequires:  chrpath
Provides:       %{target}-binutils = %{binutils_ver}

%description
This is a cross-compilation version of GNU Binutils, which can be used to
assemble and link binaries for the %{target} platform.

%prep
%setup -q -n binutils-%{version}

%define _sysroot %{_prefix}/%{target} 

%build
./configure CFLAGS="$RPM_OPT_FLAGS" \
            --target=%{target} \
            --enable-interwork \
            --enable-multilib \
            --enable-plugins \
            --enable-gold \
            --disable-nls \
            --disable-shared \
            --disable-threads \
            --disable-werror \
            --with-gcc \
            --with-gnu-as \
            --with-gnu-ld \
            --prefix=%{_prefix} \
            --with-sysroot=%{_sysroot} \
            --mandir=%{_mandir} \
            --infodir=%{_infodir} \
            --without-doc \
            --with-docdir=share/doc/%{name} \
            --with-bugurl="http://bugs.opensuse.org/" \
            --with-pkgversion="GNU Binutils; %{DIST}" \
            --with-separate-debug-dir=%{_sysroot}/lib/debug
%make_build

%check
#make check 

%install
%make_install

# we don't want these as this is a cross-compiler
rm -rf %{buildroot}%{_infodir} ||:
rm -rf %{buildroot}%{_mandir} ||:
rm -rf %{buildroot}%{_includedir} ||:
rm -f %{buildroot}%{_libdir}/libiberty.a ||:
rm -f %{buildroot}/usr/lib/libarm-none-eabi-sim.a ||:
rm -f %{buildroot}/usr/lib/bfd-plugins/libdep.a

# Replace hard links by symlinks, so that rpmlint doesn't complain
T=$(basename %buildroot/usr/%{target})
for f in %buildroot/usr/$T/bin/* ; do
    chrpath -d $f || :
    ln -sf /usr/bin/$T-$(basename $f) $f
done

%if %{bootstrap}
mkdir -p %{buildroot}%{_sysroot}/usr/include
%endif

%files
%license COPYING*
%dir %{_sysroot}
%dir %{_sysroot}/bin
%dir %{_sysroot}/lib
%{_sysroot}/bin/*
%{_sysroot}/lib/*
%{_bindir}/%{target}-*

%if %{bootstrap}
%dir %{_sysroot}/usr
%dir %{_sysroot}/usr/include
%endif

%changelog
openSUSE Build Service is sponsored by