Index: contrib/crossrpms/rtems4.10/arm/rtems-4.10-arm-rtems4.10-gcc.spec
===================================================================
--- contrib/crossrpms/rtems4.10/arm/rtems-4.10-arm-rtems4.10-gcc.spec	(revision a2f4fc11ade9ed1189ebadc6066b38e7e262d435)
+++ contrib/crossrpms/rtems4.10/arm/rtems-4.10-arm-rtems4.10-gcc.spec	(revision 4a23fa971c09b01910e4d004a15bc047eb606616)
@@ -59,5 +59,5 @@
 Group:	      	Development/Tools
 Version:        %{gcc_rpmvers}
-Release:      	6%{?dist}
+Release:      	7%{?dist}
 License:      	GPL
 URL:		http://gcc.gnu.org
@@ -68,68 +68,152 @@
 BuildRequires:  %{_host_rpmprefix}gcc
 
+# FIXME: Disable lto for now, to avoid dependencies on libelf
+%bcond_with lto
+
+# FIXME: Disamble python gdb scripts
+# ATM, no idea how to package them
+%bcond_with pygdb
+
+# FIXME: Disable GCC-plugin
+# Bug in gcc-4.5-20100318, doesn't build them on x86_84 hosts.
+%bcond_with plugin
+
+# versions of libraries, we conditionally bundle if necessary
+%global mpc_version	0.8.1
+%global mpfr_version	2.4.1
+%global gmp_version	4.3.2
+%global libelf_version  0.8.13
+
+# versions of libraries these distros are known to ship
+%if 0%{?fc13}
+%global mpc_provided 0.8.1
+%global mpfr_provided 2.4.1
+%global gmp_provided 4.3.1
+%endif
+
+%if 0%{?fc12}
+%global mpc_provided 0.8
+%global mpfr_provided 2.4.1
+%global gmp_provided 4.3.1
+%endif
+
+%if 0%{?fc11}
+%global mpc_provided %{nil}
+%global mpfr_provided 2.4.1
+%global gmp_provided 4.2.4
+%endif
+
+%if 0%{?rhel5}
+%global mpc_provided %{nil}
+%global mpfr_provided %{nil}
+%global gmp_provided 4.1.4
+%endif
+
+%if 0%{?suse11_0}
+%global mpc_provided %{nil}
+%global mpfr_provided 2.3.1
+%global gmp_provided 4.2.2
+%endif
+
+%if 0%{?suse11_1}
+%global mpc_provided %{nil}
+%global mpfr_provided 2.3.2
+%global gmp_provided 4.2.3
+%endif
+
+%if 0%{?suse11_2}
+%global mpc_provided 0.7
+%global mpfr_provided 2.4.1
+%global gmp_provided 4.3.1
+%endif
+
+%if 0%{?cygwin}
+%global mpc_provided 0.8
+%global mpfr_provided 2.4.1
+%global gmp_provided 4.3.1
+%endif
+
+%if 0%{?mingw32}
+%global mpc_provided 0.8.1
+%global mpfr_provided 2.4.1
+%global gmp_provided 4.3.2
+%endif
+
+%if "%{gcc_version}" >= "4.2.0"
+%endif
+
 %if "%{gcc_version}" >= "4.3.0"
-%define _gmp_minvers		4.1
-%else
-%if "%{gcc_version}" >= "4.2.0"
-%endif
-%endif
-
-%if %{defined _gmp_minvers}
-BuildRequires: gmp-devel >= %{_gmp_minvers}
+%define gmp_required		4.1
+%define mpfr_required		2.3.1
+%endif
+
+%if "%{gcc_version}" >= "4.3.3"
+%define cloog_required 		0.15
+%endif
+
+%if "%{gcc_version}" >= "4.4.0"
+%define mpfr_required		2.3.2
+%endif
+
+%if "%{gcc_version}" >= "4.5.0"
+%define mpc_required 		0.8
+%if %{with lto}
+%define libelf_required 	0.8.12
+%endif
+%endif
+
+%if %{defined mpc_required}
+%if "%{mpc_provided}" >= "%{mpc_required}"
+%{?fedora:BuildRequires: libmpc-devel >= %{mpc_required}}
+%{?suse:BuildRequires: mpc-devel >= %{mpc_required}}
 %if "%{_build}" != "%{_host}"
-BuildRequires:  %{_host_rpmprefix}gmp-devel >= %{_gmp_minvers}
-%endif
-%endif
-
-%if "%{gcc_version}" >= "4.3.3"
-%define _cloog_minvers 0.15
-%endif
-
-%if %{defined _cloog_minvers}
-%{?fc11:BuildRequires: cloog-ppl-devel >= %_cloog_minvers}
-%{?fc12:BuildRequires: cloog-ppl-devel >= %_cloog_minvers}
-%{?fc13:BuildRequires: cloog-ppl-devel >= %_cloog_minvers}
-%{?suse11_2:BuildRequires: cloog-devel >= %_cloog_minvers, ppl-devel}
-%{?suse11_1:BuildRequires: cloog-devel >= %_cloog_minvers, ppl-devel}
-%endif
-
-%if "%{gcc_version}" >= "4.4.0"
-%define _mpfr_minvers	2.3.2
-%define mpfr_version	2.4.1
-%else
-%if "%{gcc_version}" >= "4.3.0"
-%define _mpfr_minvers	2.3.1
-%define mpfr_version	2.3.2
-%else
-%if "%{gcc_version}" >= "4.2.0"
-%endif
-%endif
-%endif
-
-%if %{defined _mpfr_minvers}
-# FIXME: This is an ugly cludge
-%{?fc11:%global mpfr_provided 2.4.1}
-%{?fc12:%global mpfr_provided 2.4.1}
-%{?fc13:%global mpfr_provided 2.4.1}
-%{?suse11_0:%global mpfr_provided 2.3.1}
-%{?suse11_1:%global mpfr_provided 2.3.2}
-%{?suse11_2:%global mpfr_provided 2.4.1}
-%{?cygwin:%global mpfr_provided 2.4.1}
-%{?mingw32:%global mpfr_provided %{nil}}
-
-%if %{defined mpfr_provided}
-%if "%{mpfr_provided}" < "%{_mpfr_minvers}"
+BuildRequires:  %{_host_rpmprefix}mpc-devel >= %{mpc_required}
+%endif
+%else
+%define _build_mpc 1
+%endif
+%endif
+
+%if %{defined gmp_required}
+%if "%{gmp_provided}" >= "%{gmp_required}"
+BuildRequires: gmp-devel >= %{gmp_required}
+%if "%{_build}" != "%{_host}"
+BuildRequires:  %{_host_rpmprefix}gmp-devel >= %{gmp_required}
+%endif
+%else
+%define _build_gmp 1
+%endif
+%endif
+
+%if %{defined libelf_required}
+%if "%{libelf_provided}" >= "%{libelf_required}"
+BuildRequires: libelf-devel >= %{libelf_required}
+%if "%{_build}" != "%{_host}"
+BuildRequires:  %{_host_rpmprefix}libelf-devel >= %{libelf_required}
+%endif
+%else
+%define _build_libelf 1
+%endif
+%endif
+
+
+%if %{defined cloog_required}
+%{?fc11:BuildRequires: cloog-ppl-devel >= %cloog_required}
+%{?fc12:BuildRequires: cloog-ppl-devel >= %cloog_required}
+%{?fc13:BuildRequires: cloog-ppl-devel >= %cloog_required}
+%{?suse11_2:BuildRequires: cloog-devel >= %cloog_required, ppl-devel}
+%{?suse11_1:BuildRequires: cloog-devel >= %cloog_required, ppl-devel}
+%endif
+
+
+%if %{defined mpfr_required}
+%if "%{mpfr_provided}" >= "%{mpfr_required}"
+BuildRequires: mpfr-devel >= %{mpfr_required}
+%if "%{_build}" != "%{_host}"
+BuildRequires:  %{_host_rpmprefix}mpfr-devel >= %{mpfr_required}
+%endif
+%else
 %define _build_mpfr 1
-%else
-%if "%{_build}" != "%{_host}"
-BuildRequires:  %{_host_rpmprefix}mpfr-devel >= %{_mpfr_minvers}
-%else
-BuildRequires: mpfr-devel >= %{_mpfr_minvers}
-%endif
-%endif
-%else
-%define _build_mpfr 1
-%endif
-
+%endif
 %endif
 
@@ -149,8 +233,15 @@
 Requires:	rtems-4.10-arm-rtems4.10-binutils
 Requires:	rtems-4.10-arm-rtems4.10-gcc-libgcc = %{gcc_rpmvers}-%{release}
-Requires:	rtems-4.10-arm-rtems4.10-newlib = %{newlib_version}-7%{?dist}
-
-
-%define _gcclibdir %{_prefix}/lib
+Requires:	rtems-4.10-arm-rtems4.10-newlib = %{newlib_version}-8%{?dist}
+
+%if "%{gcc_version}" >= "4.5.0"
+BuildRequires:  zlib-devel
+%if "%{_build}" != "%{_host}"
+BuildRequires:  %{_host_rpmprefix}zlib-devel
+%endif
+%else
+%endif
+
+%global _gcclibdir %{_prefix}/lib
 
 %if "%{gcc_version}" == "4.4.3"
@@ -174,10 +265,22 @@
 %if "%{newlib_version}" == "1.18.0"
 Source50:	ftp://sources.redhat.com/pub/newlib/newlib-%{newlib_pkgvers}.tar.gz
-Patch50:	ftp://ftp.rtems.org/pub/rtems/SOURCES/4.10/newlib-1.18.0-rtems4.10-20100310.diff
+Patch50:	ftp://ftp.rtems.org/pub/rtems/SOURCES/4.10/newlib-1.18.0-rtems4.10-20100328.diff
 %endif
 %{?_without_sources:NoSource:	50}
 
-%if "%{gcc_version}" >= "4.3.0"
+%if 0%{?_build_mpfr}
 Source60:    http://www.mpfr.org/mpfr-current/mpfr-%{mpfr_version}.tar.bz2
+%endif
+
+%if 0%{?_build_mpc}
+Source61:    http://www.multiprecision.org/mpc/download/mpc-%{mpc_version}.tar.gz
+%endif
+
+%if 0%{?_build_gmp}
+Source62:    ftp://ftp.gnu.org/gnu/gmp/gmp-%{gmp_version}.tar.bz2
+%endif
+
+%if 0%{?_build_libelf}
+Source63:    http://www.mr511.de/software/libelf-%{libelf_version}.tar.gz
 %endif
 
@@ -189,8 +292,12 @@
 
 %setup -q -T -D -n %{name}-%{version} -a0
-%{?PATCH0:%patch0 -p0}
+cd gcc-%{gcc_pkgvers}
+%{?PATCH0:%patch0 -p1}
+cd ..
 
 %setup -q -T -D -n %{name}-%{version} -a1
-%{?PATCH1:%patch1 -p0}
+cd gcc-%{gcc_pkgvers}
+%{?PATCH1:%patch1 -p1}
+cd ..
 
 
@@ -212,5 +319,26 @@
 %endif
 
-echo "RTEMS gcc-%{gcc_version}-6%{?dist}/newlib-%{newlib_version}-7%{?dist}" > gcc-%{gcc_pkgvers}/gcc/DEV-PHASE
+%if 0%{?_build_mpc}
+%setup -q -T -D -n %{name}-%{version} -a61
+%{?PATCH61:%patch61 -p1}
+  # Build mpc one-tree style
+  ln -s ../mpc-%{mpc_version} gcc-%{gcc_pkgvers}/mpc
+%endif
+
+%if 0%{?_build_gmp}
+%setup -q -T -D -n %{name}-%{version} -a62
+%{?PATCH62:%patch62 -p1}
+  # Build gmp one-tree style
+  ln -s ../gmp-%{gmp_version} gcc-%{gcc_pkgvers}/gmp
+%endif
+
+%if 0%{?_build_libelf}
+%setup -q -T -D -n %{name}-%{version} -a63
+%{?PATCH63:%patch63 -p1}
+  # Build libelf one-tree style
+  ln -s ../libelf-%{libelf_version} gcc-%{gcc_pkgvers}/libelf
+%endif
+
+echo "RTEMS gcc-%{gcc_version}-7%{?dist}/newlib-%{newlib_version}-8%{?dist}" > gcc-%{gcc_pkgvers}/gcc/DEV-PHASE
 
 
@@ -254,4 +382,6 @@
     --enable-version-specific-runtime-libs \
     --enable-threads \
+    %{?with_lto:--enable-lto}%{!?with_lto:--disable-lto} \
+    %{?with_plugin:--enable-plugin}%{!?with_plugin:--disable-plugin} \
     --enable-newlib-io-c99-formats \
     --enable-languages="$languages" $optargs
@@ -319,4 +449,11 @@
     rmdir ${RPM_BUILD_ROOT}%{_prefix}/arm-rtems4.10/include/bits
   fi
+
+  # gcc >= 4.5.0: installs weird libstdc++ python bindings.
+%if ! %{with pygdb}
+  if test -d ${RPM_BUILD_ROOT}%{_datadir}/gcc-%{gcc_version}/python; then
+    rm -rf ${RPM_BUILD_ROOT}%{_datadir}/gcc-%{gcc_version}/python/libstdcxx
+  fi
+%endif
 
   # Collect multilib subdirectories
@@ -375,4 +512,6 @@
     *jvgenmain) ;;
     */libgfortran*.*) echo "$i" >> build/files.gfortran ;;
+    %{!?with_pygdb:*/libstdc++*gdb.py*) rm ${RPM_BUILD_ROOT}/$i ;;} # ignore for now
+    %{?with_pygdb:*/libstdc++*gdb.py*) >> build/files.g++ ;;}
     */libstdc++.*) echo "$i" >> build/files.g++ ;;
     */libsupc++.*) echo "$i" >> build/files.g++ ;;
@@ -471,5 +610,5 @@
 # Version:        %{gcc_rpmvers}
 # Requires:       rtems-4.10-arm-rtems4.10-binutils
-# Requires:       rtems-4.10-arm-rtems4.10-newlib = %{newlib_version}-7%{?dist}
+# Requires:       rtems-4.10-arm-rtems4.10-newlib = %{newlib_version}-8%{?dist}
 # License:	GPL
 
@@ -489,5 +628,5 @@
 Version:        %{gcc_rpmvers}
 %{?_with_noarch_subpackages:BuildArch: noarch}
-Requires:       rtems-4.10-arm-rtems4.10-newlib = %{newlib_version}-7%{?dist}
+Requires:       rtems-4.10-arm-rtems4.10-newlib = %{newlib_version}-8%{?dist}
 License:	GPL
 
@@ -519,5 +658,8 @@
 %{_libexecdir}/gcc/arm-rtems4.10/%{gcc_version}/cc1%{_exeext}
 %{_libexecdir}/gcc/arm-rtems4.10/%{gcc_version}/collect2%{_exeext}
-
+%if "%{gcc_version}" >= "4.5.0"
+%{?with_lto:%{_libexecdir}/gcc/arm-rtems4.10/%{gcc_version}/lto%{_exeext}}
+%{_libexecdir}/gcc/arm-rtems4.10/%{gcc_version}/lto-wrapper%{_exeext}
+%endif
 
 %files -n rtems-4.10-arm-rtems4.10-gcc-libgcc -f build/files.gcc
@@ -531,9 +673,5 @@
 
 %if "%{gcc_version}" > "4.0.3"
-%if "arm-rtems4.10" != "bfin-rtems4.10"
-%if "arm-rtems4.10" != "avr-rtems4.10"
 %dir %{_gcclibdir}/gcc/arm-rtems4.10/%{gcc_version}/include/ssp
-%endif
-%endif
 %endif
 
@@ -664,5 +802,5 @@
 License:	Distributable
 Version:	%{newlib_version}
-Release:        7%{?dist}
+Release:        8%{?dist}
 %{?_with_noarch_subpackages:BuildArch: noarch}
 
@@ -685,5 +823,5 @@
 Group:          Development/Tools
 Version:        %{newlib_version}
-Release:        7%{?dist}
+Release:        8%{?dist}
 %{?_with_noarch_subpackages:BuildArch: noarch}
 License:	Distributable
