%define gcc_version @gcc_version@
%define newlib_version @newlib_version@
Name: @target_alias@-gcc-newlib
Summary: gcc and newlib C Library for @target_alias@.
Group: rtems
Release: @Release@
License: gcc is GPL/LGPL ; newlib no has restrictions on run-time usage
Autoreqprov: on
Packager: corsepiu@faw.uni-ulm.de and joel@OARcorp.com
Version: gcc%{gcc_version}newlib%{newlib_version}
# gcc 3.x and gcc 2.9
# Source0: ftp://ftp.gnu.org/pub/gnu/gcc/gcc-@gcc_version@.tar.gz
Source0: ftp://ftp.gnu.org/pub/gnu/gcc/gcc-@gcc_version@.tar.bz2
# gcc 2.95.x
# Source0: ftp://ftp.gnu.org/pub/gnu/gcc/gcc-%{gcc_version}.tar.bz2
Source1: ftp://sources.redhat.com/pub/newlib/newlib-%{newlib_version}.tar.gz
@PATCH1@
@PATCH3@
BuildPreReq: texinfo >= 4.2
BuildPreReq: @target_alias@-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 :-)
#
NoSource: 0
NoSource: 1
# Use rpm -ba --define 'gnat [0|1]' xxx.spec to override building gnat for
# those targets wanting to support ada.
%if "%{gcc_version}" >= "3.2"
# default to building gnat
%define _gnat %{?gnat:%gnat}%{!?gnat:1}
%else
# default to not building gnat
%define _gnat %{?gnat:%gnat}%{!?gnat:0}
%endif
# Use rpm -ba --define 'gcj [0|1]' xxx.spec to override building gcj for
# those targets wanting to support gcj.
%if "%{gcc_version}" >= "3.2"
# default to building gcj
%define _gcj %{?gcj:%gcj}%{!?gcj:1}
%else
# default to not building gcj
%define _gcj %{?gnat:%gcj}%{!?gcj:0}
%endif
%define build_cxx 1
%define build_g77 0
%define build_objc 0
%define build_gcj 0
%define build_gnat 0
%if "@target_alias@" == "arm-rtems"
%define build_gcj %_gcj
%endif
%if "@target_alias@" == "c4x-rtems"
%define build_cxx 0
%endif
%if "@target_alias@" == "i386-rtems"
%define build_gnat %_gnat
%define build_gcj %_gcj
%endif
%if "@target_alias@" == "i960-rtems"
%define build_cxx 0
%endif
%if "@target_alias@" == "m68k-rtems"
%define build_gcj %_gcj
%endif
%if "@target_alias@" == "mips-rtems"
%define build_gnat %_gnat
%define build_gcj %_gcj
%endif
%if "@target_alias@" == "powerpc-rtems"
%define build_gnat %_gnat
%define build_gcj %_gcj
%endif
%if "@target_alias@" == "sparc-rtems"
%define build_gnat %_gnat
%define build_gcj %_gcj
%endif
%if %build_gcj
# Building gcj requires bison and zlib
BuildPreReq: bison
%if "%_vendor" == "redhat"
BuildPreReq: zlib-devel
%endif
%endif
%if %build_gnat
# Building gnat requires gnat
%if "%_vendor" == "redhat"
# This really isn't available until RedHat 8.0. How to conditionalize this?
# BuildPreReq: gcc-gnat
%endif
%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.
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|packages]/SOURCES directory ($RPM_SOURCE_DIR).
Or you can try the ftp options of rpm :-)
%prep
# untar the sources inside @target_alias@-gcc-newlib
%setup -c -T -n %{name} -a0 -a1
@PATCH2@
@PATCH4@
cd gcc-%{gcc_version}
sed -e 's/\(version_string = \"[^\"]*\)/\1 (OAR Corporation 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}
test -d build || mkdir build
%build
cd build
# ALERT: GCJ would be better if we could add this flag and build
# it's libraries but this code isn't ready to be embedded.
# libgcj_flag="--enable-libgcj"
languages="c"
%if %build_cxx
languages="$languages,c++"
%endif
%if %build_g77
languages="$languages,g77"
%endif
%if %build_gcj
languages="$languages,java"
%endif
%if %build_objc
languages="$languages,objc"
%endif
%if %build_gnat
languages="$languages,ada"
%endif
../gcc-%{gcc_version}/configure \
--build=%_build --host=%_host \
--target=@target_alias@ \
--with-gnu-as --with-gnu-ld --with-newlib --verbose \
--with-system-zlib --disable-nls \
--enable-version-specific-runtime-libs \
--enable-threads=rtems --prefix=%{_prefix} \
--enable-languages=$languages ${libgcj_flag}
%if "%_host" != "%_build"
# Bug in gcc-3.2.1:
# Somehow, gcc doesn't get syslimits.h right for Cdn-Xs
test -d gcc/include || mkdir -p gcc/include
cp ../gcc-%{gcc_version}/gcc/gsyslimits.h gcc/include/syslimits.h
%endif
%if %build_gnat
cd ../gcc-%{gcc_version}/gcc/ada
touch treeprs.ads [es]info.h nmake.ad[bs]
cd ../../../build
%endif
make all
%if %build_gnat
# This gnat configuration is crap :(
# This is what is documented, but it doesn't work for me (RC)
# make gnatlib_and_tools
make -C gcc cross-gnattools
make -C gcc ada.all.cross
# This should work, but doesn't.
# make -C gcc gnatlib
# This is what gcc/ada/Makefile.in contains by default,
# but what we override below
GNATLIBCFLAGS="-g -O2"
# Let gnatlib building find newlib's headers
GNATLIBCFLAGS="$GNATLIBCFLAGS -isystem `pwd`/@target_alias@/newlib/targ-include"
GNATLIBCFLAGS="$GNATLIBCFLAGS -isystem `pwd`/../newlib-%{newlib_version}/newlib/libc/include"
# Without this xgcc doesn't find the target's binutils.
GNATLIBCFLAGS="$GNATLIBCFLAGS -B%{_prefix}/@target_alias@/bin/"
%if "@target_alias@" == "mips-rtems"
GNATLIBCFLAGS="$GNATLIBCFLAGS -G0"
%endif
make -C gcc GNATLIBCFLAGS="${GNATLIBCFLAGS}" gnatlib
%endif
make info
%install
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 @target_alias@/bin/gcc
%if "%{gcc_version}" < "3.0"
../gcc-%{gcc_version}/mkinstalldirs \
$RPM_BUILD_ROOT%{_prefix}/@target_alias@/bin
%endif
make prefix=$RPM_BUILD_ROOT%{_prefix} \
bindir=$RPM_BUILD_ROOT%{_bindir} install
cd @target_alias@/newlib
make prefix=$RPM_BUILD_ROOT%{_prefix} \
bindir=$RPM_BUILD_ROOT%{_bindir} install-info
# cd back to build/
cd ../..
%if %build_gnat
# Install a copy of gcc as gnatgcc
# Enables us to mix different versions of gnat and gnatgcc
rm -f $RPM_BUILD_ROOT%{_bindir}/@target_alias@-gnatgcc%{_exeext}
ln $RPM_BUILD_ROOT%{_bindir}/@target_alias@-gcc%{_exeext} \
$RPM_BUILD_ROOT%{_bindir}/@target_alias@-gnatgcc%{_exeext}
%endif
# Bug in gcc-3.x: It puts the build dirs into *.la files
# host library
rm -f ${RPM_BUILD_ROOT}%{_prefix}/lib/libiberty.a
%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%{_prefix}/bin/cpp%{_exeext};
then
mv $RPM_BUILD_ROOT%{_prefix}/bin/cpp%{_exeext} \
$RPM_BUILD_ROOT%{_prefix}/bin/@target_alias@-cpp%{_exeext}
fi
%endif
# gzip info files
gzip -f $RPM_BUILD_ROOT%{_prefix}/info/*.info 2>/dev/null
gzip -f $RPM_BUILD_ROOT%{_prefix}/info/*.info-? 2>/dev/null
gzip -f $RPM_BUILD_ROOT%{_prefix}/info/*.info-?? 2>/dev/null
rm -f dirs ;
echo "%defattr(-,root,root)" >> dirs
echo "%dir %{_prefix}/lib" >> dirs ;
echo "%dir %{_prefix}/lib/gcc-lib" >> dirs ;
echo "%dir %{_prefix}/lib/gcc-lib/@target_alias@" >> dirs ;
# Collect multilib subdirectories
f=`gcc/xgcc -Bgcc/ --print-multi-lib | sed -e 's,;.*$,,'`
TGTDIR="%{_prefix}/lib/gcc-lib/@target_alias@/%{gcc_version}"
for i in $f; do
case $i in
\.) echo "%dir ${TGTDIR}" >> dirs
;;
*) echo "%dir ${TGTDIR}/$i" >> dirs
;;
esac
done
TGTDIR="%{_prefix}/@target_alias@/lib"
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.objc
cp dirs files.gcj
cp dirs files.g++
TGTDIR="%{_prefix}/lib/gcc-lib/@target_alias@/%{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) ;;
*cc1obj) ;;
*libobjc*) echo "$i" >> files.objc ;;
*include/objc*) ;;
*include/g++*);;
*include/c++*);;
*adainclude*);;
*adalib*);;
*gnat1);;
*jc1) ;;
*jvgenmain) ;;
*cc1plus) ;; # ignore: explicitly put into rpm elsewhere
*libstdc++.a) echo "$i" >> files.g++ ;;
*libsupc++.a) echo "$i" >> files.g++ ;;
*) echo "$i" >> files.gcc ;;
esac
done
TGTDIR="%{_prefix}/@target_alias@/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 gcc
*) echo "$i" >> files.gcc ;;
esac
done