File gcc.spec of Package gcc

%define targetarch @BUILD_FLAVOR@

Summary: GNU compiler suite to build programs for %{targetarch}
%if 0%{bootstrap1}%{bootstrap0}
Name: cross-%{targetarch}-gcc-bootstrap%{bootstrap1}
%else
Name: cross-%{targetarch}-gcc
%endif
Version: 15.2.0
Release: 0
License: GPL-2.0-or-later
Group: Development/Cross
URL: http://ftp.gnu.org/gnu/gcc
BuildRequires:	cross-%{targetarch}-binutils mpfr-devel gmp-devel mpc-devel
%{lua:
    if string.find(rpm.expand("%{targetarch}"), "-linux-") then
	rpm.define("clib glibc")
	rpm.define("glibc_based 1")
    elseif string.find(rpm.expand("%{targetarch}"), "avr-") then
	rpm.define("clib avr-libc")
	rpm.define("avrlibc_based 1")
    elseif string.find(rpm.expand("%{targetarch}"), "-none-") then
	rpm.define("clib newlib")
	rpm.define("newlib_based 1")
    else
	rpm.define("clib unknown")
	end }

# (Doubling percent signs in the following lines, to pacify rpm)
# The above should have been "%%if  %%{!?glibc_based: 0} ..." and so on,
# but OBS parses this first, without lua, and then misses the BuildRequires.

%if 0%{bootstrap1}%{bootstrap0}
%if 0%{bootstrap0}
%else
BuildRequires:	cross-%{targetarch}-glibc-headers
BuildRequires:	cross-%{targetarch}-libc-bootstrap0
%endif
%else
BuildRequires:	cross-%{targetarch}-libc-bootstrap1
%endif

BuildRequires:	gcc gcc-c++
BuildRequires:  python3-base

Patch1:	compile-fixes
Patch2:	fix-includes-fixed
Patch4:	tinyAVR2.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
Requires:  cross-%{targetarch}-binutils
AutoReqProv: off
Source0: http://ftp.gnu.org/gnu/gcc/gcc-%{version}/gcc-%{version}.tar.xz
Source1: crosstools-rpmlintrc
%if "%{targetarch}" == ""
ExclusiveArch:	do_not_build
%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root



%description 
GNU compiler suite to build programs for %{targetarch}.

%prep
%setup -q -n gcc-%{version}
%patch -P 1 -p1
%patch -P 2 -p1
mkdir build

%build
%if 0%{?suse_version} < 1700
export PATH=%{cross_prefix}/bin:$PATH
%endif

cd build
case %{targetarch} in
 aarch64-*linux)
  conf_add=" --disable-multilib "
  ;;
 arm-none-*)
  conf_add=""
  conf_disables_bootstrap=""
  ;;
 ppc-*)
  conf_add=" --with-cpu=823 --with-float=soft --enable-secureplt "
  conf_disables_bootstrap="--with-float=soft"
  ;;
 mips-*)
  conf_add="--with-float=soft "
  conf_disables_bootstrap="--with-float=soft"
  ;;
 riscv64-*elf)
  conf_add=" --with-multilib-generator=rv64ima-lp64--f*c "
  conf_add=""
  ;;
 riscv*-*linux)
  # --with-multilib-list='riscv64-...-lp64' ?
  conf_add=" --disable-multilib "
  conf_add=""
  ;;
esac

%if 0%{bootstrap0}
configure_disables="--disable-libmudflap --disable-nls --disable-c-mbchar --disable-shared --disable-libssp --with-newlib $conf_disables_bootstrap"
%endif

# pthread_deps_disable="--disable-libgomp --disable-libatomic --disable-libitm --disable-libmpx --disable-libsanitizer"

case %{targetarch} in
 *-none-*)
#  conf_add="$conf_add --with-newlib --disable-libstdcxx --disable-libssp --without-headers "
   conf_add="$conf_add --with-newlib "
   configure_disables="$configure_disables --disable-nls --disable-ssp --disable-c-mbchar --disable-shared "
  ;;
 *)
#   conf_add="$conf_add $pthread_deps_disable"
  ;;
esac


export CFLAGS="$RPM_OPT_FLAGS -O3 -fPIE"
export CXXFLAGS=$CFLAGS

# --with-build-sysroot=%{cross_prefix}/%{targetarch}/%{sysroot} \

../configure --prefix=%{cross_prefix} --enable-bootstrap=no \
    --build=`arch`-suse-linux --target=%{targetarch} \
    --enable-languages=c,c++ \
    --with-sysroot=%{cross_prefix}/%{targetarch}/%{sysroot} \
    $conf_add $configure_disables
%if 0%{bootstrap0}
make all-host %_smp_mflags
make all-target-libgcc %_smp_mflags
%else
make %_smp_mflags
%endif

%install
export PATH=%{cross_prefix}/bin:$PATH
%if 0%{bootstrap0}
make -C build DESTDIR=$RPM_BUILD_ROOT install-strip-host install-target-libgcc
%else
make -C build DESTDIR=$RPM_BUILD_ROOT install
%endif
rm -rf $RPM_BUILD_ROOT%{cross_prefix}/info $RPM_BUILD_ROOT%{cross_prefix}/lib*/libiberty.a 
rm -rf $RPM_BUILD_ROOT%{cross_prefix}/man $RPM_BUILD_ROOT%{cross_prefix}/share/locale
rm -rf $RPM_BUILD_ROOT%{cross_prefix}/share/info/dir

%files
%defattr(-,root,root,-)
%if "%{cross_prefix}" != "/usr"
%dir %{cross_prefix}
%endif
%{cross_prefix}/*

%changelog
openSUSE Build Service is sponsored by