%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-newlib Summary: GCC and newlib C Library for %{gcc_target} Group: %{rpmgroup} License: gcc is GPL/LGPL ; newlib no has restrictions on run-time usage Version: %{gccnewlib_version} Release: @Release@ URL: http://gcc.gnu.org BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Source0: ftp://ftp.gnu.org/pub/gnu/gcc/gcc-%{gcc_version}/gcc-core-%{gcc_version}@gcc_suffix@ Source50: ftp://sources.redhat.com/pub/newlib/newlib-%{newlib_version}@newlib_suffix@ @PATCH0@ @PATCH50@ 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: 50} # 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_cxx Source1: ftp://ftp.gnu.org/pub/gnu/gcc/gcc-%{gcc_version}/gcc-g++-%{gcc_version}@gcc_suffix@ @PATCH1@ %{?!_with_sources:NoSource: 1} %endif %if %build_f95 Source2: ftp://ftp.gnu.org/pub/gnu/gcc/gcc-%{gcc_version}/gcc-fortran-%{gcc_version}@gcc_suffix@ @PATCH2@ %{?!_with_sources:NoSource: 2} %endif %if %build_gcj Source3: ftp://ftp.gnu.org/pub/gnu/gcc/gcc-%{gcc_version}/gcc-java-%{gcc_version}@gcc_suffix@ @PATCH3@ %{?!_with_sources:NoSource: 3} %endif %if %build_gnat Source4: ftp://ftp.gnu.org/pub/gnu/gcc/gcc-%{gcc_version}/gcc-ada-%{gcc_version}@gcc_suffix@ @PATCH4@ %{?!_with_sources:NoSource: 4} %endif %if %build_objc Source5: ftp://ftp.gnu.org/pub/gnu/gcc/gcc-%{gcc_version}/gcc-objc-%{gcc_version}@gcc_suffix@ @PATCH5@ %{?!_with_sources:NoSource: 5} %endif %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 libc BuildRequires: @rpmprefix@%{gcc_target}-libc < %{newlib_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 for %{gcc_target}. %prep # untar the sources inside %{gcc_target}-gcc-newlib %setup -c -T -n %{name}-%{version} %setup -T -D -n %{name}-%{version} -a0 %{?PATCH0:%patch0 -p0} %if %build_cxx %setup -T -D -n %{name}-%{version} -a1 %{?PATCH1:%patch1 -p0} %endif %if %build_f95 %setup -T -D -n %{name}-%{version} -a2 %{?PATCH2:%patch2 -p0} %endif %if %build_gcj %setup -T -D -n %{name}-%{version} -a3 %{?PATCH3:%patch3 -p0} %endif %if %build_gnat %setup -T -D -n %{name}-%{version} -a4 %{?PATCH4:%patch4 -p0} %endif %if %build_objc %setup -T -D -n %{name}-%{version} -a5 %{?PATCH5:%patch5 -p0} %endif %setup -T -D -n %{name}-%{version} -a50 cd newlib-%{newlib_version} %{?PATCH50:%patch50 -p1} cd .. # 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 ;; %if "%{_prefix}" != "/usr" # Fix up brp-compress to handle %%_prefix != /usr */brp-compress*) b=$(basename $a) sed -e 's,\./usr/,./%{_prefix},' < $a > $b chmod a+x $b ;; %endif esac done sed -e 's,^[ ]*/usr/lib/rpm.*/brp-strip,./brp-strip,' \ %if "%{_prefix}" != "/usr" -e 's,^[ ]*/usr/lib/rpm.*/brp-compress,./brp-compress,' \ %endif < os_install_post~ > os_install_post %define __os_install_post . ./os_install_post 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} %build mkdir -p 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 %if "%{_prefix}" != "/usr" make info %endif cd .. %install %if "%{_prefix}" != "/usr" export PATH="%{_bindir}:${PATH}" %endif 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 %if "%{_prefix}" != "/usr" 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 ../.. %endif # 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 %if "%{_prefix}" != "/usr" # We don't ship info/dir rm -f $RPM_BUILD_ROOT%{_infodir}/dir touch $RPM_BUILD_ROOT%{_infodir}/dir %endif %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 ..