d0966f2
%global processor_arch arm
d0966f2
%global target         %{processor_arch}-none-eabi
1b87518
%global gcc_ver        7.1.0
1b87518
%global gcc_short_ver  7.1
d0966f2
d0966f2
# we need newlib to compile complete gcc, but we need gcc to compile newlib,
d0966f2
# so compile minimal gcc first
1b87518
%global bootstrap      1
d0966f2
d0966f2
Name:           %{target}-gcc-cs
eadfa1b
Epoch:          1
1b87518
Version:        %{gcc_ver}
1b87518
Release:        1%{?dist}
d0966f2
Summary:        GNU GCC for cross-compilation for %{target} target
d0966f2
Group:          Development/Tools
d0966f2
d0966f2
# Most of the sources are licensed under GPLv3+ with these exceptions:
d0966f2
# LGPLv2+ libquadmath/ libjava/libltdl/ gcc/testsuite/objc.dg/gnu-encoding/generate-random 
d0966f2
#         libgcc/soft-fp/ libffi/msvcc.sh
d0966f2
# LGPLv3+ gcc/prefix.c
d0966f2
# BSD libgo/go/regexp/testdata/testregex.cz zlib/example.c libffi/ 
d0966f2
#     libjava/classpath/external/relaxngDatatype/org/relaxng/datatype/helpers/DatatypeLibraryLoader.java
d0966f2
# GPLv2+ libitm/testsuite/libitm.c/memset-1.c libjava/
d0966f2
# Public Domain libjava/classpath/external/sax/org/xml/sax/ext/EntityResolver2.java
d0966f2
#               libjava/classpath/external/sax/org/xml/sax/ext/DeclHandler.java
d0966f2
# BSL zlib/contrib/dotzlib/DotZLib/GZipStream.cs
d0966f2
License:        GPLv2+ and GPLv3+ and LGPLv2+ and BSD
d0966f2
URL:            http://www.codesourcery.com/sgpp/lite/%{processor_arch}
d0966f2
eadfa1b
Source0:        gcc-%{gcc_ver}.tar.bz2
d0966f2
d0966f2
Source1:        README.fedora
5b96676
Source2:        bootstrapexplain
d0966f2
2157acd
BuildRequires:  %{target}-binutils >= 2.21, zlib-devel gmp-devel mpfr-devel libmpc-devel flex autogen
2157acd
%if ! %{bootstrap}
2157acd
BuildRequires:  %{target}-newlib
2157acd
%endif
d0966f2
Requires:       %{target}-binutils >= 2.21
d0966f2
Provides:       %{target}-gcc = %{gcc_ver}
d0966f2
d0966f2
%description
d0966f2
This is a Cross Compiling version of GNU GCC, which can be used to
d0966f2
compile for the %{target} platform, instead of for the
d0966f2
native %{_arch} platform.
d0966f2
d0966f2
This package is based on the CodeSourcery %{cs_date}-%{cs_rel} release,
d0966f2
which includes improved ARM target support compared to the corresponding 
d0966f2
GNU GCC release.
d0966f2
d0966f2
%package c++
d0966f2
Summary:        Cross Compiling GNU GCC targeted at %{target}
d0966f2
Group:          Development/Languages
64af657
Requires:       %{name} = %{epoch}:%{version}-%{release}
d0966f2
Provides:       %{target}-gcc-c++ = %{gcc_ver}
d0966f2
d0966f2
%description c++
d0966f2
This package contains the Cross Compiling version of g++, which can be used to
d0966f2
compile c++ code for the %{target} platform, instead of for the native 
d0966f2
%{_arch} platform.
d0966f2
d0966f2
%prep
d0966f2
%setup -q -c
eadfa1b
pushd gcc-%{gcc_ver}
d0966f2
d0966f2
contrib/gcc_update --touch
d0966f2
popd
d0966f2
cp -a %{SOURCE1} .
d0966f2
d0966f2
# Extract %%__os_install_post into os_install_post~
d0966f2
cat << \EOF > os_install_post~
d0966f2
%__os_install_post
d0966f2
EOF
d0966f2
d0966f2
# Generate customized brp-*scripts
d0966f2
cat os_install_post~ | while read a x y; do
d0966f2
case $a in
d0966f2
# Prevent brp-strip* from trying to handle foreign binaries
d0966f2
*/brp-strip*)
d0966f2
  b=$(basename $a)
b2dfd61
  sed -e 's,find "*$RPM_BUILD_ROOT"*,find "$RPM_BUILD_ROOT%_bindir" "$RPM_BUILD_ROOT%_libexecdir",' $a > $b
d0966f2
  chmod a+x $b
d0966f2
  ;;
d0966f2
esac
d0966f2
done
d0966f2
d0966f2
sed -e 's,^[ ]*/usr/lib/rpm.*/brp-strip,./brp-strip,' \
d0966f2
< os_install_post~ > os_install_post 
d0966f2
d0966f2
d0966f2
%build
0df9ee8
mkdir -p gcc-%{target} gcc-nano-%{target}
0df9ee8
0df9ee8
#### normal version
0df9ee8
d0966f2
pushd gcc-%{target}
0df9ee8
7a7914d
CC="%{__cc} ${RPM_OPT_FLAGS}  -fno-stack-protector" \
eadfa1b
../gcc-%{gcc_ver}/configure --prefix=%{_prefix} --mandir=%{_mandir} \
d0966f2
  --with-pkgversion="Fedora %{version}-%{release}" \
d0966f2
  --with-bugurl="https://bugzilla.redhat.com/" \
d0966f2
  --infodir=%{_infodir} --target=%{target} \
0a76a3b
  --enable-interwork --enable-multilib \
1b87518
  --with-python-dir=share/%{target}/gcc-%{version}/python \
1b87518
  --with-multilib-list=rmprofile \
1b87518
  --enable-plugins \
1b87518
  --disable-decimal-float \
1b87518
  --disable-libffi \
1b87518
  --disable-libgomp \
1b87518
  --disable-libmudflap \
1b87518
  --disable-libquadmath \
1b87518
  --disable-libssp \
1b87518
  --disable-libstdcxx-pch \
1b87518
  --disable-nls \
1b87518
  --disable-shared \
1b87518
  --disable-threads \
1b87518
  --disable-tls \
d0966f2
%if %{bootstrap}
8413d64
   --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
d0966f2
%else
1b87518
   --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=yes --with-system-zlib --with-sysroot=/usr/%{target}
d0966f2
%endif
d0966f2
d0966f2
%if %{bootstrap}
eadfa1b
make all-gcc  INHIBIT_LIBC_CFLAGS='-DUSE_TM_CLONE_REGISTRY=0'
d0966f2
%else
0df9ee8
make INHIBIT_LIBC_CFLAGS='-DUSE_TM_CLONE_REGISTRY=0'
d0966f2
%endif
d0966f2
popd
d0966f2
0df9ee8
######### nano version build part (only relevant if not bootstrap)
0df9ee8
%if %{bootstrap}
0df9ee8
%else
0df9ee8
0df9ee8
mkdir -p gcc-nano-%{target}
0df9ee8
pushd gcc-nano-%{target}
0df9ee8
0df9ee8
export CFLAGS_FOR_TARGET="$CFLAGS_FOR_TARGET -fno-exceptions -Os "
0df9ee8
export CXXFLAGS_FOR_TARGET="$CXXFLAGS_FOR_TARGET -fno-exceptions -Os "
0df9ee8
0df9ee8
CC="%{__cc} ${RPM_OPT_FLAGS}  -fno-stack-protector " \
0df9ee8
../gcc-%{gcc_ver}/configure --prefix=%{_prefix} --mandir=%{_mandir} \
0df9ee8
  --with-pkgversion="Fedora %{version}-%{release}" \
0df9ee8
  --with-bugurl="https://bugzilla.redhat.com/" \
0df9ee8
  --infodir=%{_infodir} --target=%{target} \
0df9ee8
  --enable-interwork --enable-multilib \
1b87518
  --with-python-dir=share/%{target}/gcc-%{version}/python \
1b87518
  --with-multilib-list=rmprofile \
1b87518
  --enable-plugins \
1b87518
  --disable-decimal-float \
1b87518
  --disable-libffi \
1b87518
  --disable-libgomp \
1b87518
  --disable-libmudflap \
1b87518
  --disable-libquadmath \
1b87518
  --disable-libssp \
1b87518
  --disable-libstdcxx-pch \
1b87518
  --disable-nls \
1b87518
  --disable-shared \
1b87518
  --disable-threads \
1b87518
  --disable-tls \
1b87518
  --with-sysroot=/usr/%{target} \
1b87518
 --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=yes --with-system-zlib
0df9ee8
make INHIBIT_LIBC_CFLAGS='-DUSE_TM_CLONE_REGISTRY=0'
0df9ee8
popd
0df9ee8
%endif
0df9ee8
d0966f2
d0966f2
%install
d0966f2
pushd gcc-%{target}
d0966f2
%if %{bootstrap}
d0966f2
make install-gcc DESTDIR=$RPM_BUILD_ROOT
5b96676
install -p -m 0755 -D %{SOURCE2} $RPM_BUILD_ROOT/%{_bindir}/%{target}-g++
5b96676
install -p -m 0755 -D %{SOURCE2} $RPM_BUILD_ROOT/%{_bindir}/%{target}-c++
d0966f2
%else
d0966f2
make install DESTDIR=$RPM_BUILD_ROOT
d0966f2
%endif
d0966f2
popd
0df9ee8
0df9ee8
##### nano version (only relevant non-bootstrap)
0df9ee8
0df9ee8
%if %{bootstrap}
0df9ee8
%else
0df9ee8
# everybody needs to end up built with the One True DESTDIR
0df9ee8
# to arrange for that, move the non-nano DESTDIR out of the way
0df9ee8
# temporarily, and make an empty one for the nano build to
0df9ee8
# populate.  Later we'll pick just the bits from the nano one
0df9ee8
# into the non-nano one, and switch the non-nano one to be
0df9ee8
# the One True DESTDIR again.
0df9ee8
#
0df9ee8
# Without this sleight-of-hand we get rpmbuild errors noticing that
0df9ee8
# the DESTDIR the nano bits were built with is not the One True
0df9ee8
# DESTDIR.
0df9ee8
0df9ee8
rm -rf $RPM_BUILD_ROOT-non-nano
0df9ee8
mv $RPM_BUILD_ROOT $RPM_BUILD_ROOT-non-nano
0df9ee8
pushd gcc-nano-%{target}
0df9ee8
0df9ee8
make install DESTDIR=$RPM_BUILD_ROOT
0df9ee8
popd
0df9ee8
pushd $RPM_BUILD_ROOT
0df9ee8
for i in libstdc++.a libsupc++.a ; do
0df9ee8
	find . -name "$i" | while read line ; do
0df9ee8
		R=`echo $line | sed "s/\.a/_nano\.a/g"`
0df9ee8
		echo "$RPM_BUILD_ROOT/$line -> $RPM_BUILD_ROOT-non-nano/$R"
0df9ee8
		cp $line $RPM_BUILD_ROOT-non-nano/$R
0df9ee8
	done 
0df9ee8
done
0df9ee8
popd
0df9ee8
0df9ee8
# junk the nano DESTDIR now we picked out the bits we needed into
0df9ee8
# the non-nano destdir
0df9ee8
rm -rf $RPM_BUILD_ROOT
0df9ee8
0df9ee8
# put the "non-nano + picked nano bits" destdir back at the
0df9ee8
# One True DESTDIR location.  Even though it has bits from two different
0df9ee8
# builds, all the bits feel they were installed to DESTDIR
0df9ee8
mv $RPM_BUILD_ROOT-non-nano $RPM_BUILD_ROOT
0df9ee8
0df9ee8
%endif
0df9ee8
### end of nano version install magic
0df9ee8
0df9ee8
d0966f2
# we don't want these as we are a cross version
d0966f2
rm -r $RPM_BUILD_ROOT%{_infodir}
d0966f2
rm -r $RPM_BUILD_ROOT%{_mandir}/man7
eadfa1b
rm -f $RPM_BUILD_ROOT%{_prefix}/lib/libiberty.a
ad3ab31
rm -f $RPM_BUILD_ROOT%{_libdir}/libcc1* ||:
ad3ab31
# these directories are often empty
ad3ab31
rmdir $RPM_BUILD_ROOT/usr/%{target}/share/gcc-%{gcc_ver} ||:
ad3ab31
rmdir $RPM_BUILD_ROOT/usr/%{target}/share ||:
d0966f2
# and these aren't usefull for embedded targets
d0966f2
rm -r $RPM_BUILD_ROOT%{_prefix}/lib*/gcc/%{target}/%{gcc_ver}/install-tools ||:
d0966f2
rm -r $RPM_BUILD_ROOT%{_libexecdir}/gcc/%{target}/%{gcc_ver}/install-tools ||:
d0966f2
rm -f $RPM_BUILD_ROOT%{_libexecdir}/gcc/%{target}/%{gcc_ver}/*.la
d0966f2
eadfa1b
eadfa1b
mkdir -p $RPM_BUILD_ROOT/usr/%{target}/share/gcc-%{gcc_ver}/
eadfa1b
mv $RPM_BUILD_ROOT/%{_datadir}/gcc-%{gcc_ver}/* $RPM_BUILD_ROOT/usr/%{target}/share/gcc-%{gcc_ver}/ ||:
eadfa1b
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc-%{gcc_ver} ||:
eadfa1b
d0966f2
%global __os_install_post . ./os_install_post
d0966f2
d0966f2
d0966f2
%check
d0966f2
%if %{bootstrap}
d0966f2
exit 0
d0966f2
%endif
1b87518
1b87518
%ifarch ppc64
1b87518
# test does not work, upstream ignores it, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57591
1b87518
exit 0
1b87518
%endif
1b87518
5b96676
pushd gcc-%{target}
5b96676
#BuildRequires: autoge may be needed
d0966f2
make check
5b96676
popd
d0966f2
d0966f2
%files
d0966f2
%defattr(-,root,root,-)
eadfa1b
%doc gcc-%{gcc_ver}/COPYING*
eadfa1b
%doc gcc-%{gcc_ver}/README README.fedora
d0966f2
%{_bindir}/%{target}-*
eadfa1b
%dir %{_prefix}/lib/gcc
eadfa1b
%dir %{_prefix}/lib/gcc/%{target}
eadfa1b
%{_prefix}/lib/gcc/%{target}/%{gcc_ver}
d0966f2
%dir %{_libexecdir}/gcc
d0966f2
%dir %{_libexecdir}/gcc/%{target}
d0966f2
%{_libexecdir}/gcc/%{target}/%{gcc_ver}
d0966f2
%{_mandir}/man1/%{target}-*.1.gz
d0966f2
%if ! %{bootstrap}
7229352
/usr/%{target}/lib/
1b87518
%dir /usr/share/%{target}/gcc-%{gcc_ver}/python/
d0966f2
%exclude %{_bindir}/%{target}-?++
d0966f2
%exclude %{_libexecdir}/gcc/%{target}/%{gcc_ver}/cc1plus
d0966f2
%exclude %{_mandir}/man1/%{target}-g++.1.gz
d0966f2
%endif
d0966f2
d0966f2
%files c++
d0966f2
%defattr(-,root,root,-)
d0966f2
%{_bindir}/%{target}-?++
5b96676
%if ! %{bootstrap}
d0966f2
%{_libexecdir}/gcc/%{target}/%{gcc_ver}/cc1plus
28678b2
/usr/%{target}/include/c++/
1b87518
/usr/share/%{target}/gcc-%{gcc_ver}/python/libstdcxx/
d0966f2
%{_mandir}/man1/%{target}-g++.1.gz
d0966f2
%endif
d0966f2
d0966f2
%changelog
1b87518
* Fri Jun 30 2017 Michal Hlavinka <mhlavink@redhat.com> - 1:7.1.0-1
1b87518
- bootstrap build for 7.1.0
1b87518
1b87518
* Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1:6.2.0-3
1b87518
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
1b87518
b0dfdcc
* Sun Nov 13 2016 Michal Hlavinka <mhlavink@redhat.com> - 1:6.2.0-2
b0dfdcc
- propper build for 6.2.0
b0dfdcc
94ff585
* Sun Nov 13 2016 Michal Hlavinka <mhlavink@redhat.com> - 1:6.2.0-1
94ff585
- bootstrap build for 6.2.0
94ff585
4d1dd23
* Fri Jul 08 2016 Michal Hlavinka <mhlavink@redhat.com> - 1:6.1.0-2
4d1dd23
- proper build of new version
4d1dd23
770dd8e
* Tue Jun 28 2016 Michal Hlavinka <mhlavink@redhat.com> - 1:6.1.0-1
770dd8e
- bootstrap build for gcc 6.1.0
770dd8e
150f90a
* Wed Feb 03 2016 Fedora Release Engineering <releng@fedoraproject.org> - 1:5.2.0-4
150f90a
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
150f90a
0df9ee8
* Thu Nov 12 2015 Michal Hlavinka <mhlavink@redhat.com> - 1:5.2.0-3
0df9ee8
- build nano libstdc++ (credits: Andy Green)
0df9ee8
7229352
* Thu Sep 03 2015 Michal Hlavinka <mhlavink@redhat.com> - 1:5.2.0-2
7229352
- regular build of 5.2.0
7229352
536eaf9
* Wed Sep 02 2015 Michal Hlavinka <mhlavink@redhat.com> - 1:5.2.0-1
536eaf9
- bootstrap build of 5.2.0 update
536eaf9
07baa46
* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1:5.1.0-2
07baa46
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
07baa46
7a7914d
* Sun May 31 2015 Michal Hlavinka <mhlavink@redhat.com> - 1:5.1.0-3
7a7914d
- updated to gcc 5.1.0
7a7914d
ba68990
* Wed Apr 15 2015 Michal Hlavinka <mhlavink@redhat.com> - 1:4.9.2-3
ba68990
- regular build
ba68990
f270ad9
* Wed Apr 15 2015 Michal Hlavinka <mhlavink@redhat.com> - 1:4.9.2-2
f270ad9
- add epoch number
f270ad9
eadfa1b
* Tue Apr 14 2015 Michal Hlavinka <mhlavink@redhat.com> - 1:4.9.2-1
eadfa1b
- update to gcc 4.9.2
eadfa1b
- fix library compatiblity 
eadfa1b
- BOOTSTRAP version, not for regular use
eadfa1b
b2dfd61
* Tue Sep 02 2014 Michal Hlavinka <mhlavink@redhat.com> - 2014.05.28-2
b2dfd61
- update workaround that prevents stripping of arm libraries
b2dfd61
0a76a3b
* Thu Aug 21 2014 Michal Hlavinka <mhlavink@redhat.com> - 2014.05.28-1
0a76a3b
- updated to 2014.05-28
0a76a3b
3d642ba
* Fri Aug 15 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2013.11.24-4
3d642ba
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild
3d642ba
a213e30
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2013.11.24-3
a213e30
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
a213e30
2157acd
* Thu Jan 16 2014 Michal Hlavinka <mhlavink@redhat.com> - 2013.11.24-2
2157acd
- complete build with newlib
2157acd
4434c6f
* Tue Jan 14 2014 Michal Hlavinka <mhlavink@redhat.com> - 2013.11.24-1
4434c6f
- updated to 2013.11-24
4434c6f
5b96676
* Fri Oct 11 2013 Michal Hlavinka <mhlavink@redhat.com> - 2013.05.23-2
5b96676
- replace arm*-g++ with explanation script that this is just unsupported 
5b96676
  package used for bootstrapping
5b96676
4d616c1
* Sun Aug 25 2013 Michal Hlavinka <mhlavink@redhat.com> - 2013.05.23-1
4d616c1
- updated to 2013.05-23 release (gcc 4.7.3)
4d616c1
181b5ca
* Wed Aug 14 2013 Michal Hlavinka <mhlavink@redhat.com> - 2012.09.63-3
181b5ca
- fix aarch64 support (#925023)
181b5ca
50ef53d
* Sat Aug 03 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2012.09.63-2
50ef53d
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
50ef53d
d0966f2
* Tue Feb 19 2013 Michal Hlavinka <mhlavink@redhat.com> - 2012.09.63-1
d0966f2
- initial package
d0966f2