File glibc.spec of Package glibc
%define targetarch @BUILD_FLAVOR@
Summary: Runtime C library for the %{targetarch} architecture
%if 0%{bootstrap}
Name: cross-%{targetarch}-libc-bootstrap
%else
Name: cross-%{targetarch}-glibc
%endif
Version: 2.40
Release: 0
License: GPL-2.0-or-later
Group: Development/Cross
URL: http://ftp.gnu.org/gnu/glibc
%if 0%{bootstrap}
BuildRequires: cross-%{targetarch}-gcc-bootstrap
Requires: cross-%{targetarch}-kernel-headers
%else
BuildRequires: cross-%{targetarch}-gcc
%endif
BuildRequires: cross-%{targetarch}-binutils cross-%{targetarch}-kernel-headers
BuildRequires: gcc gcc-c++ bison
BuildRequires: python3
Source0: http://ftp.gnu.org/gnu/glibc/glibc-%{version}.tar.xz
Source1: crosstools-rpmlintrc
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
AutoReqProv: off
BuildArch: noarch
Requires: cross-%{targetarch}-binutils
%if "%{targetarch}" == ""
ExclusiveArch: do_not_build
%endif
%description
This package contains the supporting C library to run programs on
%{targetarch}.
%prep
%setup -q -n glibc-%{version}
mkdir -p obj; cd obj
/bin/echo -e 'libc_cv_forced_unwind=${libc_cv_forced_unwind=yes}'>config.cache
/bin/echo -e 'libc_cv_c_cleanup=${libc_cv_c_cleanup=yes}' >> config.cache
%if 0%{bootstrap}
perl -pi -e 's,-lgcc_eh,,g;' Makeconfig
%endif
%build
export PATH=%{cross_prefix}/bin:$PATH
export CC=%{targetarch}-gcc
export CFLAGS="-O2 -fno-strict-aliasing -Wno-int-to-pointer-cast"
# perl -pi -e 's,-lgcc_eh,,g;' Makeconfig
# autoreconf -i
%if 0%{bootstrap}
configure_disables="--disable-profile --disable-debug --without-gd --disable-nscd"
%endif
cd obj
../configure -C --prefix=%{cross_prefix} --exec-prefix=%{cross_prefix}/%{targetarch}/%{sysroot} \
--build=`arch`-suse-linux --host=%{targetarch} \
--libdir=%{cross_prefix}/%{targetarch}/%{sysroot}/lib \
--includedir=%{cross_prefix}/%{targetarch}/%{sysroot}/include \
--with-headers=%{cross_prefix}/%{targetarch}/%{sysroot}/include \
--without-fp \
$configure_disables
make %_smp_mflags
%install
rm -rf $RPM_BUILD_ROOT
cd obj
make install_root=$RPM_BUILD_ROOT install
perl -pi -e "s,//lib/,%{cross_prefix}/%{targetarch}/lib/,g;" \
$RPM_BUILD_ROOT%{cross_prefix}/%{targetarch}/lib/lib{c,pthread}.so || true
mv $RPM_BUILD_ROOT%{cross_prefix}/%{targetarch}%{cross_prefix}/%{targetarch}/include \
$RPM_BUILD_ROOT%{cross_prefix}/%{targetarch}/%{sysroot}/. || true
rmdir -p $RPM_BUILD_ROOT%{cross_prefix}/%{targetarch}%{cross_prefix}/%{targetarch} || true
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}/etc $RPM_BUILD_ROOT%{cross_prefix}/share/i18n
rm -rf $RPM_BUILD_ROOT%{cross_prefix}/var $RPM_BUILD_ROOT%{cross_prefix}/share/info
ln -sfn . $RPM_BUILD_ROOT%{cross_prefix}/%{targetarch}/%{sysroot}/usr || true
perl -pi -e "s,%{cross_prefix}/%{targetarch}/?%{sysroot}/,/,g;" $RPM_BUILD_ROOT%{cross_prefix}/%{targetarch}/%{sysroot}/lib/lib{c,pthread}.so || true
%files
%defattr(-,root,root,-)
%if "%{cross_prefix}" != "/usr"
%dir %{cross_prefix}
%endif
%{cross_prefix}/%{targetarch}
%changelog