Chris Johns db65c6aaf1 Support Canadian cross builds on FreeBSD (and other hosts).
Set up the rules to manage the separate host and build setting to
allow a Canadian cross to complete.

Update the scripts to move the build directory and host/build
flags into the defaults so they are common for all build
configurations.
2013-05-15 12:15:14 +10:00

207 lines
6.0 KiB
INI

#
# GCC Common Support.
#
# This configuration file configure's, make's and install's gcc. It uses
# newlib, MPFR, MPC, and GMP in a one-tree build configuration.
#
%include %{_configdir}/checks.cfg
%ifn %{defined gcc_version_message}
%error No GCC Version message defined.
%endif
#
# The package description.
#
Name: %{_target}-gcc-%{gcc_version}-newlib-%{newlib_version}-%{release}
Summary: GCC v%{gcc_version} and Newlib v%{newlib_version} for target %{_target} on host %{_host}
Version: %{gcc_version}
Release: %{release}
URL: http://gcc.gnu.org/
BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
#
# Supports Candian Cross (Cxc).
#
%define allow_cxc
#
# The GCC library directory
#
%global _gcclibdir %{_prefix}/lib
#
# Prepare the source code.
#
%prep
# gcc and optional the g++ core if separate packages
source_dir_0="gcc-%{gcc_version}"
%setup -q -c -n %{name}-%{version}
%{?source1:%setup -q -D -T -n %{name}-%{version} -a1}
cd ${source_dir_0}
%{?patch0:%patch0 %{?patch0_opts:%{patch0_opts}}%{!?patch0_opts:-p1}}
%{?patch1:%patch1 %{?patch1_opts:%{patch1_opts}}%{!?patch1_opts:-p1}}
%{?patch2:%patch2 %{?patch2_opts:%{patch2_opts}}%{!?patch2_opts:-p1}}
%{?patch3:%patch3 %{?patch3_opts:%{patch3_opts}}%{!?patch3_opts:-p1}}
%{?patch4:%patch4 %{?patch4_opts:%{patch4_opts}}%{!?patch4_opts:-p1}}
%{?patch5:%patch5 %{?patch5_opts:%{patch5_opts}}%{!?patch5_opts:-p1}}
%{?patch6:%patch6 %{?patch6_opts:%{patch6_opts}}%{!?patch6_opts:-p1}}
%{?patch7:%patch7 %{?patch7_opts:%{patch7_opts}}%{!?patch7_opts:-p1}}
%{?patch8:%patch8 %{?patch8_opts:%{patch8_opts}}%{!?patch8_opts:-p1}}
%{?patch9:%patch9 %{?patch9_opts:%{patch9_opts}}%{!?patch9_opts:-p1}}
cd ..
# newlib
source_dir_10="newlib-%{newlib_version}"
%setup -q -D -T -n %{name}-%{version} -a10
cd ${source_dir_10}
%{?patch10:%patch10 %{?patch10_opts:%{patch10_opts}}%{!?patch10_opts:-p1}}
%{?patch11:%patch11 %{?patch11_opts:%{patch11_opts}}%{!?patch11_opts:-p1}}
%{?patch12:%patch12 %{?patch12_opts:%{patch12_opts}}%{!?patch12_opts:-p1}}
%{?patch13:%patch13 %{?patch13_opts:%{patch13_opts}}%{!?patch13_opts:-p1}}
%{?patch14:%patch14 %{?patch14_opts:%{patch14_opts}}%{!?patch14_opts:-p1}}
%{?patch15:%patch15 %{?patch15_opts:%{patch15_opts}}%{!?patch15_opts:-p1}}
%{?patch16:%patch16 %{?patch16_opts:%{patch16_opts}}%{!?patch16_opts:-p1}}
%{?patch17:%patch17 %{?patch17_opts:%{patch17_opts}}%{!?patch17_opts:-p1}}
%{?patch18:%patch18 %{?patch18_opts:%{patch18_opts}}%{!?patch18_opts:-p1}}
%{?patch19:%patch19 %{?patch19_opts:%{patch19_opts}}%{!?patch19_opts:-p1}}
cd ..
# Link newlib into the gcc source tree
%{__rmfile} ${source_dir_0}/newlib
%{__ln_s} $PWD/${source_dir_10}/newlib ${source_dir_0}/newlib
# MPFR
source_dir_20="mpfr-%{mpfr_version}"
%setup -q -D -T -n %{name}-%{version} -a20
cd ${source_dir_20}
%{?patch20:%patch20 -p1}
cd ..
# Build MPFR one-tree style
%{__rmfile} ${source_dir_0}/mpfr
%{__ln_s} $PWD/${source_dir_20} ${source_dir_0}/mpfr
# MPC
source_dir_21="mpc-%{mpc_version}"
%setup -q -D -T -n %{name}-%{version} -a21
cd ${source_dir_21}
%{?patch21:%patch21 -p1}
cd ..
# Build MPC one-tree style
%{__rmfile} ${source_dir_0}/mpc
%{__ln_s} $PWD/${source_dir_21} ${source_dir_0}/mpc
# GMP
source_dir_22="gmp-%{gmp_version}"
%setup -q -D -T -n %{name}-%{version} -a22
cd ${source_dir_22}
%{?patch22:%patch22 -p1}
cd ..
# Build GMP one-tree style
%{__rmfile} ${source_dir_0}/gmp
%{__ln_s} $PWD/${source_dir_22} ${source_dir_0}/gmp
echo "%{gcc_version_message}" > ${source_dir_0}/gcc/DEV-PHASE
# Fix timestamps
cd ${source_dir_0}
contrib/gcc_update --touch
cd ..
%build
%{build_directory}
mkdir -p ${build_dir}
cd ${build_dir}
# Languages.
languages="c"
%if %{enable_cxx}
languages="$languages,c++"
%endif
%if %{enable_ada}
languages="$languages,ada"
%endif
%if %{enable_go}
languages="$languages,go"
%endif
%if %{enable_fortran}
languages="$languages,fortran"
%endif
%if %{enable_java}
languages="$languages,java"
%endif
%if %{enable_objc}
languages="$languages,objc"
%endif
%{host_build_flags}
../${source_dir_0}/configure \
--prefix=%{_prefix} \
--bindir=%{_bindir} \
--exec_prefix=%{_exec_prefix} \
--includedir=%{_includedir} \
--libdir=%{_gcclibdir} \
--libexecdir=%{_libexecdir} \
--mandir=%{_mandir} \
--infodir=%{_infodir} \
--datadir=%{_datadir} \
--build=%{_build} --host=%{_host} \
--target=%{_target} \
--disable-libstdcxx-pch \
--with-gnu-as --with-gnu-ld --verbose \
--with-newlib \
--with-system-zlib \
--disable-nls --without-included-gettext \
--disable-win32-registry \
--enable-version-specific-runtime-libs \
--disable-lto \
--enable-newlib-io-c99-formats \
%{?with_iconv:--enable-newlib-iconv} \
%{?with_threads:--enable-threads}%{!?with_threads:--disable-threads} \
%{?with_plugin:--enable-plugin}%{!?with_plugin:--disable-plugin} \
%{?enable_obsolete:--enable-obsolete} \
--enable-languages="$languages"
if test "%_host" != "%_build" ; then
# Bug in gcc-3.2.1:
# Somehow, gcc doesn't get syslimits.h right for Cdn-Xs
mkdir -p gcc/include
cp ../${source_dir_0}/gcc/gsyslimits.h gcc/include/syslimits.h
fi
%{__make} %{?_smp_mflags} all
cd ..
%install
%{__rmdir} $SB_BUILD_ROOT
cd ${build_dir}
%{__make} DESTDIR=$SB_BUILD_ROOT install
cd ..
# libiberty doesn't honor --libdir, but always installs to a
# magically guessed _libdir
%{__rmfile} ${SB_BUILD_ROOT}%{_libdir}/libiberty.a
# We use the version from binutils
%{__rmfile} $SB_BUILD_ROOT%{_bindir}/%{_target}-c++filt%{_exeext}
# We don't ship info/dir
%{__rmfile} $SB_BUILD_ROOT%{_infodir}/dir
# Don't want libffi's man-pages
%{__rmfile} $SB_BUILD_ROOT%{_mandir}/man3/*ffi*
# Clean the symlinks away incase the source is a repo
%{__rmfile} ${source_dir_0}/newlib
%{__rmfile} ${source_dir_0}/mpfr
%{__rmfile} ${source_dir_0}/mpc
%{__rmfile} ${source_dir_0}/gmp
%testing
# Add testing here.
export RUNTESTFLAGS=--target_board=%{_target}-run