%define gcc_version @gcc_version@
%define newlib_version @newlib_version@
%define gccnewlib_version gcc%{gcc_version}newlib%{newlib_version}
%define gcc_target @target_alias@
Name: @rpmprefix@%{gcc_target}-gcc
Summary: gcc and newlib C Library for %{gcc_target}.
Group: %{rpmgroup}
Release: @Release@
License: gcc is GPL/LGPL ; newlib no has restrictions on run-time usage
Version: %{gccnewlib_version}
Source0: ftp://ftp.gnu.org/pub/gnu/gcc/gcc-%{gcc_version}/gcc-%{gcc_version}@gcc_suffix@
Source1: ftp://sources.redhat.com/pub/newlib/newlib-%{newlib_version}@newlib_suffix@
@PATCH0@
@PATCH1@
Source98: brp-rtems-strip.in
Source99: brp-rtems-compress.in
%define __os_install_post ./brp-rtems-compress && ./brp-rtems-strip
BuildRequires: texinfo >= 4.2
BuildRequires: @rpmprefix@%{gcc_target}-binutils
#
# The original sources are not included in the source RPM.
# If we included them, then the source RPMs for each target
# would duplicate MBs of source unnecessarily. This is
# a duplication of over 30 MBs of source for each of
# the more than 10 targets it is possible to build.
#
# You can get them yourself from the Internet and copy them to
# your /usr/src/redhat/SOURCES directory ($RPM_SOURCE_DIR).
# Or you can try the ftp options of rpm :-)
#
%{?!_with_sources:NoSource: 0}
%{?!_with_sources:NoSource: 1}
# default languages to build
%define _cxx 1
%define _fortran 0
%define _gcj 0
%define _gnat 0
%define _objc 0
%define _libgcj 0
# custom defaults for specific targets
%if "%{gcc_target}" == "arm-rtems@osversion@"
# Gnat lacks arm support
%define _gnat 0
%endif
%if "%{gcc_target}" == "avr-rtems@osversion@"
%define _cxx 0
%define _fortran 0
%define _gcj 0
%define _gnat 0
%endif
%if "%{gcc_target}" == "h8300-rtems@osversion@"
%define _fortran 0
%define _gcj 0
%define _gnat 0
%endif
%if "%{gcc_target}" == "sh-rtems@osversion@"
# Triggers an ICE in GCC-4.0.0
%define _gnat 0
%endif
%if "%{gcc_target}" == "tic4x-rtems@osversion@"
%define _cxx 0
%define _gnat 0
%define _gcj 0
%define _fortran 0
%endif
# Allow the user to build arbitrary languages
%{?_with_cxx:%define _cxx 1}
%{?_with_fortran:%define _fortran 1}
%{?_with_gcj:%define _gcj 1}
%{?_with_gnat:%define _gnat 1}
%{?_with_objc:%define _objc 1}
%{?_with_libgcj:%define _libgcj 1}
# Allow the user to suppress building languages
%{?_without_cxx:%define _cxx 0}
%{?_without_fortran:%define _fortran 0}
%{?_without_gcj:%define _gcj 0}
%{?_without_gnat:%define _gnat 0}
%{?_without_objc:%define _objc 0}
%{?_without_libgcj:%define _libgcj 0}
%define build_cxx %_cxx
%if "%{gcc_version}" >= "4.0.0"
%define build_f95 %_fortran
%define build_g77 0
%else
%define build_f95 0
%define build_g77 %_fortran
%endif
%define build_gnat %_gnat
%define build_gcj %_gcj
%define build_objc %_objc
%define build_libgcj %_libgcj
%if %build_gcj
# Building gcj requires bison and zlib
BuildRequires: bison
%endif
%if "%_vendor" == "redhat"
%if %build_gcj
BuildRequires: zlib-devel
%endif
%if %build_gnat
# Building gnat requires gnat
# This really isn't available until RedHat 8.0. How to conditionalize this?
BuildRequires: gcc-gnat
# Urgh, building gnat requires the target c-toolchain
BuildRequires: @rpmprefix@%{gcc_target}-gcc < %{gccnewlib_version}-%{release}
%endif
%if %build_f95
BuildRequires: gmp-devel
%endif
%endif
%if "%{gcc_version}" >= "3.4"
%define gcclib %{_libdir}/gcc
%define gccexec %{_libexecdir}/gcc
%else
%define gcclib %{_libdir}/gcc-lib
%define gccexec %{_libdir}/gcc-lib
%endif
# %%description
# RTEMS is an open source operating system for embedded systems.
#
# This is gcc's and newlib C Library's sources with patches for RTEMS.
#
%prep
# untar the sources inside %{gcc_target}-gcc-newlib
%setup -c -T -n %{name}-%{version} -a0 -a1
cd gcc-%{gcc_version}
%{?PATCH0:%patch0 -p1}
cd ..
cd newlib-%{newlib_version}
%{?PATCH1:%patch1 -p1}
cd ..
sed 's,@BRPSTRIPPATH@,.%_bindir .%_prefix/%gcc_target/bin,' \
%SOURCE98 > brp-rtems-strip
chmod +x brp-rtems-strip
sed 's,@BRPCOMPRESSPATH@,.%_mandir/man* .%_infodir,' \
%SOURCE99 > brp-rtems-compress
chmod +x brp-rtems-compress
cd gcc-%{gcc_version}
sed -e 's/\(version_string.* = \"[^\"]*\)/\1 (RTEMS gcc-%{gcc_version}-@gcc_patch_version@\/newlib-%{newlib_version}-@newlib_patch_version@-@Release@)/' \
gcc/version.c > gcc/version.c~
mv gcc/version.c~ gcc/version.c
# Fix timestamps
contrib/gcc_update --touch
cd ..
# Copy the C library into gcc's source tree
ln -s ../newlib-%{newlib_version}/newlib gcc-%{gcc_version}
mkdir -p build
%build
cd build
languages="c"
%if %build_cxx
languages="$languages,c++"
%endif
%if %build_g77
languages="$languages,g77"
%endif
%if %build_f95
languages="$languages,f95"
%endif
%if %build_gcj
languages="$languages,java"
%endif
%if %build_objc
languages="$languages,objc"
%endif
%if %build_gnat
languages="$languages,ada"
%endif
%if %build_libgcj
optargs="--enable-libgcj"
%endif
%if "%{_prefix}" != "/usr"
export PATH="%{_bindir}:${PATH}"
%endif
CC="%{__cc} ${RPM_OPT_FLAGS}" \
../gcc-%{gcc_version}/configure \
--prefix=%{_prefix} \
--bindir=%{_bindir} \
--includedir=%{_includedir} \
--libdir=%{_libdir} \
--mandir=%{_mandir} \
--infodir=%{_infodir} \
--build=%_build --host=%_host \
--target=%{gcc_target} \
--with-gnu-as --with-gnu-ld --with-newlib --verbose \
--with-system-zlib --disable-nls \
--enable-version-specific-runtime-libs \
--enable-threads=rtems \
--enable-languages=$languages $optargs
%if "%_host" != "%_build"
# Bug in gcc-3.2.1:
# Somehow, gcc doesn't get syslimits.h right for Cdn-Xs
mkdir -p gcc/include
cp ../gcc-%{gcc_version}/gcc/gsyslimits.h gcc/include/syslimits.h
%endif
make all
make info
%install
export PATH="%{_bindir}:${PATH}"
rm -rf $RPM_BUILD_ROOT
cd build
# Bug in gcc-2.95.1: It doesn't build this installation directory
# If it doesn't find it, gcc doesn't install %{gcc_target}/bin/gcc
%if "%{gcc_version}" < "3.0"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/%{gcc_target}/bin
%endif
make prefix=$RPM_BUILD_ROOT%{_prefix} \
bindir=$RPM_BUILD_ROOT%{_bindir} \
libdir=$RPM_BUILD_ROOT%{_libdir} \
includedir=$RPM_BUILD_ROOT%{_includedir} \
mandir=$RPM_BUILD_ROOT%{_mandir} \
infodir=$RPM_BUILD_ROOT%{_infodir} \
install
cd %{gcc_target}/newlib
make prefix=$RPM_BUILD_ROOT%{_prefix} \
bindir=$RPM_BUILD_ROOT%{_bindir} \
libdir=$RPM_BUILD_ROOT%{_libdir} \
includedir=$RPM_BUILD_ROOT%{_includedir} \
mandir=$RPM_BUILD_ROOT%{_mandir} \
infodir=$RPM_BUILD_ROOT%{_infodir} \
install-info
# cd back to build/
cd ../..
# Bug in gcc-3.x: It puts the build dirs into *.la files
# host library
rm -f ${RPM_BUILD_ROOT}%{_prefix}/lib/libiberty.a
# We use the version from binutils
rm -f $RPM_BUILD_ROOT%{_bindir}/%{gcc_target}-c++filt%{_exeext}
%if %build_gnat
# Seemingly a VAX tool. Not meaningful for RTEMS
rm -f $RPM_BUILD_ROOT%{_bindir}/vxaddr2line%{_exeext}
%endif
# We don't ship info/dir
rm -f $RPM_BUILD_ROOT%{_infodir}/dir
touch $RPM_BUILD_ROOT%{_infodir}/dir
%if "%{_prefix}" == "/usr"
# Conflict with a native GCC's infos
rm -rf $RPM_BUILD_ROOT%{_infodir}
# Conflict with a native GCC's man pages
rm -rf $RPM_BUILD_ROOT%{_mandir}/man7
%endif
%if %build_f95
# # Bug in gcc-4.0.0pre
# mv $RPM_BUILD_ROOT%{_bindir}/gfortran $RPM_BUILD_ROOT%{_bindir}/%{gcc_target}-gfortran
%endif
%if "%{gcc_version}" >= "3.4"
# Bug in gcc-3.4.0pre
rm -f $RPM_BUILD_ROOT%{_bindir}/%{gcc_target}-%{gcc_target}-gcjh%{_exeext}
%endif
%if "%{gcc_version}" >= "3.3"
# Bug in gcc-3.3.x/gcc-3.4.x: Despite we don't need fixincludes, it installs
# the fixinclude-install-tools
rm -rf ${RPM_BUILD_ROOT}%{gcclib}/%{gcc_target}/%{gcc_version}/install-tools
rm -rf ${RPM_BUILD_ROOT}%{gccexec}/%{gcc_target}/%{gcc_version}/install-tools
%endif
%if "%{gcc_version}" < "3.0"
# Bug in gcc-2.95.x: It bogusly tries to share cpp for all targets.
# Rename it to target_alias-cpp
if test -f $RPM_BUILD_ROOT%{_bindir}/cpp%{_exeext};
then
mv $RPM_BUILD_ROOT%{_bindir}/cpp%{_exeext} \
$RPM_BUILD_ROOT%{_bindir}/%{gcc_target}-cpp%{_exeext}
fi
%endif
# Collect multilib subdirectories
f=`gcc/xgcc -Bgcc/ --print-multi-lib | sed -e 's,;.*$,,'`
echo "%defattr(-,root,root,-)" > files.libc
TGTDIR="%{_prefix}/%{gcc_target}/lib"
for i in $f; do
case $i in
\.) echo "%dir ${TGTDIR}" >> files.libc
;;
*) echo "%dir ${TGTDIR}/$i" >> files.libc
;;
esac
done
rm -f dirs ;
echo "%defattr(-,root,root,-)" >> dirs
%if "%{_prefix}" != "/usr"
echo "%dir %{_prefix}" >> dirs
echo "%dir %{_libdir}" >> dirs
%if "%{gcc_version}" >= "3.4"
echo "%dir %{_libexecdir}" >> dirs
%endif
%endif
echo "%dir %{gcclib}" >> dirs
echo "%dir %{gcclib}/%{gcc_target}" >> dirs
TGTDIR="%{gcclib}/%{gcc_target}/%{gcc_version}"
for i in $f; do
case $i in
\.) echo "%dir ${TGTDIR}" >> dirs
;;
*) echo "%dir ${TGTDIR}/$i" >> dirs
;;
esac
done
# Collect files to go into different packages
cp dirs files.gcc
cp dirs files.g77
cp dirs files.gfortran
cp dirs files.objc
cp dirs files.gcj
cp dirs files.g++
TGTDIR="%{gcclib}/%{gcc_target}/%{gcc_version}"
f=`find ${RPM_BUILD_ROOT}${TGTDIR} ! -type d -print | sed -e "s,^$RPM_BUILD_ROOT,,g"`;
for i in $f; do
case $i in
*lib*.la) rm ${RPM_BUILD_ROOT}/$i ;; # ignore: gcc produces bogus libtool libs
*f771) ;;
*f951) ;;
*cc1) ;;
*cc1obj) ;;
*cc1plus) ;; # ignore: explicitly put into rpm elsewhere
*collect2) ;;
*libobjc*) echo "$i" >> files.objc ;;
*include/objc*) ;;
*include/g++*);;
*include/c++*);;
*adainclude*);;
*adalib*);;
*gnat1);;
*jc1) ;;
*jvgenmain) ;;
*libgfortran*.a) echo "$i" >> files.gfortran ;;
*libstdc++.a) echo "$i" >> files.g++ ;;
*libsupc++.a) echo "$i" >> files.g++ ;;
*) echo "$i" >> files.gcc ;;
esac
done
TGTDIR="%{_prefix}/%{gcc_target}/lib"
f=`find ${RPM_BUILD_ROOT}${TGTDIR} ! -type d -print | sed -e "s,^$RPM_BUILD_ROOT,,g"`;
for i in $f; do
case $i in
*lib*.la) rm ${RPM_BUILD_ROOT}/$i;; # ignore - gcc produces bogus libtool libs
*libiberty.a) rm ${RPM_BUILD_ROOT}/$i ;; # ignore - GPL'ed
# all other files belong to libc
*) echo "$i" >> files.libc ;;
esac
done
cd ..