Blob Blame History Raw
%define target arm-gp2x-linux
%define glibcversion 2.3.6
%define bootstrap 0

Name:           %{target}-gcc
Version:        4.1.2
Release:        11%{?dist}
Summary:        Cross Compiling GNU GCC targeted at %{target}
Group:          Development/Languages
License:        GPLv2+
URL:            http://gcc.gnu.org/
Source0:        ftp://ftp.gnu.org/gnu/gcc/gcc-%{version}/gcc-core-%{version}.tar.bz2
%if !%{bootstrap}
Source1:        ftp://ftp.gnu.org/gnu/gcc/gcc-%{version}/gcc-g++-%{version}.tar.bz2
%else
Source1:        ftp://ftp.gnu.org/gnu/glibc/glibc-%{glibcversion}.tar.bz2
Source2:        ftp://ftp.gnu.org/gnu/glibc/glibc-linuxthreads-%{glibcversion}.tar.bz2
%endif
Source3:        README.fedora
Patch0:         arm-linux-soft-float.patch
Patch1:         gcc40-cross-build-fixes.patch
Patch2:         gcc-4.1.2-gcc_eh.patch
Patch3:         gcc-4.1.2-compile-fix.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n)
BuildRequires:  %{target}-binutils zlib-devel gawk
Requires:       %{target}-binutils
%if %{bootstrap}
BuildRequires:  %{target}-kernel-headers
%else
BuildRequires:  %{target}-glibc
Requires:       %{target}-glibc
%endif

%description
This is a Cross Compiling version of GNU GCC, which can be used to
compile programs for the %{target} platform, instead of for the
native %{_arch} platform.


%if !%{bootstrap}

%package c++
Summary:        Cross Compiling GNU G++ targeted at %{target}
Group:          Development/Languages
Requires:       %{name} = %{version}-%{release}

%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.

%endif


%prep
%setup -q -c -a 1
cp -a %{SOURCE3} .
pushd gcc-%{version}
%patch0 -p1
%patch1 -p1
%if !%{bootstrap}
%patch2 -p1
%endif
%patch3 -p1
sed -i 's/VERSUFFIX ""/VERSUFFIX " (Fedora GP2X %{version}-%{release})"/' \
  gcc/version.c
contrib/gcc_update --touch
popd

# 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 

# glibc headers
%if %{bootstrap}
pushd glibc-%{glibcversion}
tar -xf %{SOURCE2}
popd

# fix-includes doesn't like symlinks so copy the kernel headers over
mkdir -p %{_builddir}/%{name}-%{version}/sysroot/%{_includedir}
cp -a /usr/%{target}/include/asm /usr/%{target}/include/linux \
  %{_builddir}/%{name}-%{version}/sysroot/%{_includedir}

mkdir -p build-%{target}-glibc-headers
pushd build-%{target}-glibc-headers
../glibc-%{glibcversion}/configure \
  --prefix=%{_builddir}/%{name}-%{version}/sysroot/%{_prefix} \
  --with-headers=%{_builddir}/%{name}-%{version}/sysroot/%{_includedir} \
  --build=`uname -m` --host=%{target} --enable-add-ons=linuxthreads \
  --without-fp --disable-profile --without-selinux
make install-headers
popd
touch %{_builddir}/%{name}-%{version}/sysroot/%{_includedir}/gnu/stubs.h
cp build-%{target}-glibc-headers/bits/stdio_lim.h \
  %{_builddir}/%{name}-%{version}/sysroot/%{_includedir}/bits
%endif


%build
%if %{bootstrap}
%define languages 'c'
%else
%define languages 'c,c++'
%endif
mkdir -p build-%{target}-gcc
pushd build-%{target}-gcc
CC="%{__cc} ${RPM_OPT_FLAGS}" \
../gcc-%{version}/configure --prefix=%{_prefix} \
  --mandir=%{_mandir} --infodir=%{_infodir} \
%if %{bootstrap}
  --with-build-sysroot=%{_builddir}/%{name}-%{version}/sysroot \
%endif
  --target=%{target} --enable-languages=%{languages} --enable-threads=posix \
  --disable-libmudflap --disable-libssp --disable-multilib --disable-shared \
  --disable-nls --enable-long-long --enable-symvers=gnu --enable-c99 \
  --with-cpu=arm920t --enable-cxx-flags=-mcpu=arm920t --with-float=soft \
  --disable-libstdcxx-pch --enable-__cxa_atexit --with-system-zlib \
  --enable-version-specific-runtime-libs
# In general, building GCC is not smp-safe
make
popd


%install
rm -rf $RPM_BUILD_ROOT
pushd build-%{target}-gcc
make install DESTDIR=$RPM_BUILD_ROOT
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    $RPM_BUILD_ROOT/usr/lib/libiberty.a
# and these aren't usefull for embedded targets
rm -r $RPM_BUILD_ROOT/usr/lib/gcc/%{target}/%{version}/install-tools
rm -r $RPM_BUILD_ROOT%{_libexecdir}/gcc/%{target}/%{version}/install-tools
%if !%{bootstrap}
rm    $RPM_BUILD_ROOT%{_prefix}/%{target}/lib/libiberty.a
rm    $RPM_BUILD_ROOT/usr/lib/gcc/%{target}/%{version}/*.la
%endif

%define __os_install_post . ./os_install_post


%clean
rm -rf $RPM_BUILD_ROOT


%files
%defattr(-,root,root,-)
%doc gcc-%{version}/COPYING gcc-%{version}/COPYING.LIB
%doc gcc-%{version}/README README.fedora
%{_bindir}/%{target}-*
%{_prefix}/lib/gcc/%{target}/
%{_libexecdir}/gcc/%{target}/
%{_mandir}/man1/%{target}-*.1.gz

%if !%{bootstrap}

%exclude %{_bindir}/%{target}-?++
%exclude /usr/lib/gcc/%{target}/%{version}/lib*c++.a
%exclude /usr/lib/gcc/%{target}/%{version}/include/c++
%exclude %{_libexecdir}/gcc/%{target}/%{version}/cc1plus
%exclude %{_mandir}/man1/%{target}-g++.1.gz


%files c++
%defattr(-,root,root,-)
%{_bindir}/%{target}-?++
/usr/lib/gcc/%{target}/%{version}/lib*c++.a
/usr/lib/gcc/%{target}/%{version}/include/c++
%{_libexecdir}/gcc/%{target}/%{version}/cc1plus
%{_mandir}/man1/%{target}-g++.1.gz

%endif


%changelog
* Fri Jul 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.1.2-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild

* Mon Feb 23 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.1.2-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild

* Thu Oct  2 2008 Hans de Goede <hdegoede@redhat.com> 4.1.2-8
- Fix FTBFS (rh 464988)

* Tue Feb 19 2008 Fedora Release Engineering <rel-eng@fedoraproject.org> - 4.1.2-8
- Autorebuild for GCC 4.3

* Tue Aug 21 2007 Hans de Goede <j.w.r.degoede@hhs.nl> 4.1.2-7
- Rebuild for buildId

* Fri Aug  3 2007 Kevin Kofler <Kevin@tigcc.ticalc.org> 4.1.2-6
- Disable bootstrap
- Add "GP2X" to VERSUFFIX
- Link C++ against -lgcc_eh to fix undefined references
- Specify GPL version in License tag

* Thu May 31 2007 Hans de Goede <j.w.r.degoede@hhs.nl> 4.1.2-5
- Merge in avr-gcc cross compile changes

* Thu May 31 2007 Koos Termeulen koostermeulen@gmail.com 4.1.2-4
- Moved kernel-headers to separate package
- Added bootstrap option to define whether we want a bootstrapped gcc or not

* Thu May 10 2007 Koos Termeulen koostermeulen@gmail.com 4.1.2-3
- Added "linux-2.6.21-headers" and "glibc-2.3.5-headers" for bootstrapping gcc
- Glibc-2.3.5 is used because the arm is not supported in version 2.5

* Thu Apr 26 2007 Koos Termeulen koostermeulen@gmail.com 4.1.2-2
- Correction in description
- Changes in ./configure
- Don't remove the devel-files from package
- Removed CFLAGS because it didn't work properly

* Thu Apr 20 2007 Koos Termeulen koostermeulen@gmail.com 4.1.2-1
- Initial release