# CodeSourcery releases are identified by a date, a release number,
# and a package number for downloading from their web site
%global cs_date 2014.05
%global cs_rel 28
%global cs_pkgnum 12773
%global processor_arch arm
%global target %{processor_arch}-none-eabi
%global gcc_ver 5.1.0
%global gcc_short_ver 5.1
# we need newlib to compile complete gcc, but we need gcc to compile newlib,
# so compile minimal gcc first
%global bootstrap 1
Name: %{target}-gcc-cs
Epoch: 1
Version: 5.1.0
Release: 1%{?dist}
Summary: GNU GCC for cross-compilation for %{target} target
Group: Development/Tools
# Most of the sources are licensed under GPLv3+ with these exceptions:
# LGPLv2+ libquadmath/ libjava/libltdl/ gcc/testsuite/objc.dg/gnu-encoding/generate-random
# libgcc/soft-fp/ libffi/msvcc.sh
# LGPLv3+ gcc/prefix.c
# BSD libgo/go/regexp/testdata/testregex.cz zlib/example.c libffi/
# libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/helpers/DatatypeLibraryLoader.java
# GPLv2+ libitm/testsuite/libitm.c/memset-1.c libjava/
# Public Domain libjava/classpath/external/sax/org/xml/sax/ext/EntityResolver2.java
# libjava/classpath/external/sax/org/xml/sax/ext/DeclHandler.java
# BSL zlib/contrib/dotzlib/DotZLib/GZipStream.cs
License: GPLv2+ and GPLv3+ and LGPLv2+ and BSD
URL: http://www.codesourcery.com/sgpp/lite/%{processor_arch}
#we don't use orignal tarball, because it's HUGE
#Source0: gcc-%{cs_date}-%{cs_rel}.tar.bz2
Source0: gcc-%{gcc_ver}.tar.bz2
#Source0 origin:
#wget https://sourcery.mentor.com/GNUToolchain/package%{cs_pkgnum}/public/%{target}/%{processor_arch}-%{cs_date}-%{cs_rel}-%{target}.src.tar.bz2
#tar jxvf %{processor_arg}-%{cs_date}-%{cs_rel}-%{target}.src.tar.bz2
Source1: README.fedora
Source2: bootstrapexplain
Patch1: enable-with-multilib-list-for-arm.patch
BuildRequires: %{target}-binutils >= 2.21, zlib-devel gmp-devel mpfr-devel libmpc-devel flex autogen
%if ! %{bootstrap}
BuildRequires: %{target}-newlib
%endif
Requires: %{target}-binutils >= 2.21
Provides: %{target}-gcc = %{gcc_ver}
%description
This is a Cross Compiling version of GNU GCC, which can be used to
compile for the %{target} platform, instead of for the
native %{_arch} platform.
This package is based on the CodeSourcery %{cs_date}-%{cs_rel} release,
which includes improved ARM target support compared to the corresponding
GNU GCC release.
%package c++
Summary: Cross Compiling GNU GCC targeted at %{target}
Group: Development/Languages
Requires: %{name} = %{epoch}:%{version}-%{release}
Provides: %{target}-gcc-c++ = %{gcc_ver}
%description c++
This package contains the Cross Compiling version of g++, which can be used to
compile c++ code for the %{target} platform, instead of for the native
%{_arch} platform.
This package is based on the CodeSourcery %{cs_date}-%{cs_rel} release,
which includes improved ARM target support compared to the corresponding
GNU GCC release.
%prep
%setup -q -c
pushd gcc-%{gcc_ver}
%patch1 -p2 -b .arm
contrib/gcc_update --touch
popd
cp -a %{SOURCE1} .
# Extract %%__os_install_post into os_install_post~
cat << \EOF > os_install_post~
%__os_install_post
EOF
# Generate customized brp-*scripts
cat os_install_post~ | while read a x y; do
case $a in
# Prevent brp-strip* from trying to handle foreign binaries
*/brp-strip*)
b=$(basename $a)
sed -e 's,find "*$RPM_BUILD_ROOT"*,find "$RPM_BUILD_ROOT%_bindir" "$RPM_BUILD_ROOT%_libexecdir",' $a > $b
chmod a+x $b
;;
esac
done
sed -e 's,^[ ]*/usr/lib/rpm.*/brp-strip,./brp-strip,' \
< os_install_post~ > os_install_post
%build
mkdir -p gcc-%{target}
pushd gcc-%{target}
CC="%{__cc} ${RPM_OPT_FLAGS} -fno-stack-protector" \
../gcc-%{gcc_ver}/configure --prefix=%{_prefix} --mandir=%{_mandir} \
--with-pkgversion="Fedora %{version}-%{release}" \
--with-bugurl="https://bugzilla.redhat.com/" \
--infodir=%{_infodir} --target=%{target} \
--enable-interwork --enable-multilib \
--with-python-dir=share/gcc-%{target} \
--with-multilib-list=armv6-m,armv7-m,armv7e-m,armv7-r \
--enable-plugins \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-libssp \
--disable-libstdcxx-pch \
--disable-libstdc++-v3 \
--disable-nls \
--disable-shared \
--disable-threads \
--disable-tls \
%if %{bootstrap}
--enable-languages=c --with-newlib --disable-nls --disable-shared --disable-threads --with-gnu-as --with-gnu-ld --with-gmp --with-mpfr --with-mpc --without-headers --with-system-zlib
%else
--enable-languages=c,c++ --with-newlib --disable-nls --disable-shared --disable-threads --with-gnu-as --with-gnu-ld --with-gmp --with-mpfr --with-mpc --with-headers=/usr/%{target}/include --with-system-zlib
%endif
# --enable-lto \
%if %{bootstrap}
make all-gcc INHIBIT_LIBC_CFLAGS='-DUSE_TM_CLONE_REGISTRY=0'
%else
make INHIBIT_LIBC_CFLAGS='-DUSE_TM_CLONE_REGISTRY=0'
%endif
popd
%install
pushd gcc-%{target}
%if %{bootstrap}
make install-gcc DESTDIR=$RPM_BUILD_ROOT
install -p -m 0755 -D %{SOURCE2} $RPM_BUILD_ROOT/%{_bindir}/%{target}-g++
install -p -m 0755 -D %{SOURCE2} $RPM_BUILD_ROOT/%{_bindir}/%{target}-c++
%else
make install DESTDIR=$RPM_BUILD_ROOT
%endif
popd
# we don't want these as we are a cross version
rm -r $RPM_BUILD_ROOT%{_infodir}
rm -r $RPM_BUILD_ROOT%{_mandir}/man7
rm -f $RPM_BUILD_ROOT%{_prefix}/lib/libiberty.a
# and these aren't usefull for embedded targets
rm -r $RPM_BUILD_ROOT%{_prefix}/lib*/gcc/%{target}/%{gcc_ver}/install-tools ||:
rm -r $RPM_BUILD_ROOT%{_libexecdir}/gcc/%{target}/%{gcc_ver}/install-tools ||:
rm -f $RPM_BUILD_ROOT%{_libexecdir}/gcc/%{target}/%{gcc_ver}/*.la
mkdir -p $RPM_BUILD_ROOT/usr/%{target}/share/gcc-%{gcc_ver}/
mv $RPM_BUILD_ROOT/%{_datadir}/gcc-%{gcc_ver}/* $RPM_BUILD_ROOT/usr/%{target}/share/gcc-%{gcc_ver}/ ||:
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc-%{gcc_ver} ||:
%global __os_install_post . ./os_install_post
%check
%if %{bootstrap}
exit 0
%endif
pushd gcc-%{target}
#BuildRequires: autoge may be needed
make check
popd
%files
%defattr(-,root,root,-)
%doc gcc-%{gcc_ver}/COPYING*
%doc gcc-%{gcc_ver}/README README.fedora
%{_bindir}/%{target}-*
%dir %{_prefix}/lib/gcc
%dir %{_prefix}/lib/gcc/%{target}
%{_prefix}/lib/gcc/%{target}/%{gcc_ver}
%dir %{_libexecdir}/gcc
%dir %{_libexecdir}/gcc/%{target}
%{_libexecdir}/gcc/%{target}/%{gcc_ver}
%{_mandir}/man1/%{target}-*.1.gz
%if ! %{bootstrap}
#/usr/%{target}/lib/
%exclude %{_bindir}/%{target}-?++
%exclude %{_libexecdir}/gcc/%{target}/%{gcc_ver}/cc1plus
%exclude %{_mandir}/man1/%{target}-g++.1.gz
%endif
%files c++
%defattr(-,root,root,-)
%{_bindir}/%{target}-?++
%if ! %{bootstrap}
%{_libexecdir}/gcc/%{target}/%{gcc_ver}/cc1plus
#/usr/%{target}/include/c++/
#%dir /usr/%{target}/share/gcc-%{gcc_ver}/python/
#/usr/%{target}/share/gcc-%{gcc_ver}/python/libstdcxx/
%{_mandir}/man1/%{target}-g++.1.gz
%endif
%changelog
* Sun May 31 2015 Michal Hlavinka <mhlavink@redhat.com> - 1:5.1.0-3
- updated to gcc 5.1.0, bootstrap build
* Wed Apr 15 2015 Michal Hlavinka <mhlavink@redhat.com> - 1:4.9.2-3
- regular build
* Wed Apr 15 2015 Michal Hlavinka <mhlavink@redhat.com> - 1:4.9.2-2
- add epoch number
* Tue Apr 14 2015 Michal Hlavinka <mhlavink@redhat.com> - 1:4.9.2-1
- update to gcc 4.9.2
- fix library compatiblity
- BOOTSTRAP version, not for regular use
* Tue Sep 02 2014 Michal Hlavinka <mhlavink@redhat.com> - 2014.05.28-2
- update workaround that prevents stripping of arm libraries
* Thu Aug 21 2014 Michal Hlavinka <mhlavink@redhat.com> - 2014.05.28-1
- updated to 2014.05-28
* Fri Aug 15 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2013.11.24-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2013.11.24-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
* Thu Jan 16 2014 Michal Hlavinka <mhlavink@redhat.com> - 2013.11.24-2
- complete build with newlib
* Tue Jan 14 2014 Michal Hlavinka <mhlavink@redhat.com> - 2013.11.24-1
- updated to 2013.11-24
* Fri Oct 11 2013 Michal Hlavinka <mhlavink@redhat.com> - 2013.05.23-2
- replace arm*-g++ with explanation script that this is just unsupported
package used for bootstrapping
* Sun Aug 25 2013 Michal Hlavinka <mhlavink@redhat.com> - 2013.05.23-1
- updated to 2013.05-23 release (gcc 4.7.3)
* Wed Aug 14 2013 Michal Hlavinka <mhlavink@redhat.com> - 2012.09.63-3
- fix aarch64 support (#925023)
* Sat Aug 03 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2012.09.63-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
* Tue Feb 19 2013 Michal Hlavinka <mhlavink@redhat.com> - 2012.09.63-1
- initial package