#! /bin/sh
|
#! /bin/sh
|
#
|
#
|
# Generate all the specs and then cycle through building them.
|
# Generate all the specs and then cycle through building them.
|
#
|
#
|
|
|
RTEMS_DIR=`dirname $0`
|
RTEMS_DIR=`dirname $0`
|
CFG=./setup.cache
|
CFG=./setup.cache
|
#dst=/usr/src/redhat/SPECS
|
#dst=/usr/src/redhat/SPECS
|
dst=`pwd`
|
dst=`pwd`
|
target=@target@
|
target=@target@
|
rpm_cpu=i386
|
rpm_cpu=i386
|
|
|
usage()
|
usage()
|
{
|
{
|
echo "$0 [options] "
|
echo "$0 [options] "
|
echo " options:"
|
echo " options:"
|
echo " -b -- build binutils"
|
echo " -b -- build binutils"
|
echo " -g -- build gcc/newlib"
|
echo " -g -- build gcc/newlib"
|
echo " -d -- build gdb"
|
echo " -d -- build gdb"
|
echo " -C HOST -- build canadian cross for HOST "
|
echo " -C HOST -- build canadian cross for HOST "
|
echo " -t -- enable test/debug mode"
|
echo " -t -- enable test/debug mode"
|
echo " -cfg "
|
echo " -cfg "
|
echo " -o "
|
echo " -o "
|
exit 1 ;
|
exit 1 ;
|
}
|
}
|
|
|
#
|
#
|
# Checks the status returned by executables and exits if it is non-zero.
|
# Checks the status returned by executables and exits if it is non-zero.
|
#
|
#
|
check_fatal()
|
check_fatal()
|
{
|
{
|
if [ $1 -ne 0 ] ; then
|
if [ $1 -ne 0 ] ; then
|
shift
|
shift
|
echo "ERROR: $*" >&2
|
echo "ERROR: $*" >&2
|
exit 1
|
exit 1
|
fi
|
fi
|
#echo
|
#echo
|
#echo "End of $*"
|
#echo "End of $*"
|
#echo -n "Press return to continue> "
|
#echo -n "Press return to continue> "
|
#echo
|
#echo
|
#read line
|
#read line
|
}
|
}
|
|
|
testing=no
|
testing=no
|
do_binutils=no
|
do_binutils=no
|
do_gccnewlib=no
|
do_gccnewlib=no
|
do_gdb=no
|
do_gdb=no
|
cdn_cross=no
|
cdn_cross=no
|
|
|
while test $# -ge 1; do
|
while test $# -ge 1; do
|
case $1 in
|
case $1 in
|
-b) do_binutils=yes ; shift;;
|
-b) do_binutils=yes ; shift;;
|
-g) do_gccnewlib=yes ; shift;;
|
-g) do_gccnewlib=yes ; shift;;
|
-d) do_gdb=yes ; shift;;
|
-d) do_gdb=yes ; shift;;
|
-t) do_test=yes ; shift;;
|
-t) do_test=yes ; shift;;
|
-cfg)
|
-cfg)
|
test $# -ge 2 || usage
|
test $# -ge 2 || usage
|
shift
|
shift
|
CFG=$1
|
CFG=$1
|
shift
|
shift
|
;;
|
;;
|
-o)
|
-o)
|
test $# -ge 2 || usage
|
test $# -ge 2 || usage
|
shift
|
shift
|
dst=$1
|
dst=$1
|
shift
|
shift
|
;;
|
;;
|
-C)
|
-C)
|
test $# -ge 2 || usage
|
test $# -ge 2 || usage
|
shift
|
shift
|
build=$1
|
build=$1
|
shift
|
shift
|
if ! test -x ${RTEMS_DIR}/../config.guess ; then
|
if ! test -x ${RTEMS_DIR}/../config.guess ; then
|
echo "Missing ${RTEMS_DIR}/../config.guess!"
|
echo "Missing ${RTEMS_DIR}/../config.guess!"
|
exit 1
|
exit 1
|
fi
|
fi
|
CDN_ARGS="--build=`${RTEMS_DIR}/../config.guess` --host=${build}"
|
CDN_ARGS="--build=`${RTEMS_DIR}/../config.guess` --host=${build}"
|
cdn_cross=yes
|
cdn_cross=yes
|
;;
|
;;
|
-*)
|
-*)
|
echo "invalid option $1";
|
echo "invalid option $1";
|
usage
|
usage
|
;;
|
;;
|
*)
|
*)
|
TARGETS="${TARGETS} $1"
|
TARGETS="${TARGETS} $1"
|
shift
|
shift
|
;;
|
;;
|
esac
|
esac
|
done
|
done
|
|
|
if test ${do_binutils} = no -a ${do_gccnewlib} = no -a ${do_gdb} = no ; then
|
if test ${do_binutils} = no -a ${do_gccnewlib} = no -a ${do_gdb} = no ; then
|
echo "You must request building binutils, gcc/newlib, or gdb."
|
echo "You must request building binutils, gcc/newlib, or gdb."
|
usage
|
usage
|
fi
|
fi
|
|
|
|
|
# This is the full list .. hppa1.1 does not build now.
|
# This is the full list .. hppa1.1 does not build now.
|
#ALL_TARGETS="hppa1.1-rtems i386-rtems i960-rtems m68k-rtems \
|
#ALL_TARGETS="hppa1.1-rtems i386-rtems i960-rtems m68k-rtems \
|
# m68k-rtemself mips-rtems mips64orion-rtems \
|
# m68k-rtemself mips-rtems mips64orion-rtems \
|
# powerpc-rtems sh-rtems sh-rtemself sparc-rtems"
|
# powerpc-rtems sh-rtems sh-rtemself sparc-rtems"
|
|
|
# This is the full buildable set.
|
# This is the full buildable set.
|
if [ "X${TARGETS}" = "X" ] ; then
|
if [ "X${TARGETS}" = "X" ] ; then
|
# do not include c4x or hppa primary targets
|
# do not include c4x or hppa primary targets
|
# do not include sh-elf or i960-elf secondary targets
|
# do not include sh-elf or i960-elf secondary targets
|
TARGETS="arm-rtems h8300-rtems i386-rtems i960-rtems m68k-rtems \
|
TARGETS="arm-rtems h8300-rtems i386-rtems i960-rtems m68k-rtems \
|
mips-rtems mips64orion-rtems powerpc-rtems sh-rtems sparc-rtems"
|
mips-rtems mips64orion-rtems powerpc-rtems sh-rtems sparc-rtems"
|
fi
|
fi
|
|
|
. $CFG
|
. $CFG
|
|
|
binutils=${binutils_version}
|
binutils=${binutils_version}
|
gcc=${gcc_version}
|
gcc=${gcc_version}
|
gdb=${gdb_version}
|
gdb=${gdb_version}
|
newlib=${newlib_version}
|
newlib=${newlib_version}
|
# also use binutils_rpm_release
|
# also use binutils_rpm_release
|
buildroot=/tmp
|
buildroot=/tmp
|
|
|
#
|
#
|
# Now get started
|
# Now get started
|
#
|
#
|
start=`date`
|
start=`date`
|
|
|
echo PATH=$PATH
|
echo PATH=$PATH
|
|
|
if [ ${testing} = yes ] ; then
|
if [ ${testing} = yes ] ; then
|
ECHO=echo
|
ECHO=echo
|
fi
|
fi
|
|
|
#installed_count=`rpm -q -g rtems | wc -l`
|
#installed_count=`rpm -q -g rtems | wc -l`
|
#if [ ${installed_count} -ne 0 ] ; then
|
#if [ ${installed_count} -ne 0 ] ; then
|
# echo This script should be run with NO rtems RPMs installed.
|
# echo This script should be run with NO rtems RPMs installed.
|
# echo It appears that the following rtems RPMs are installed:
|
# echo It appears that the following rtems RPMs are installed:
|
# echo
|
# echo
|
# rpm -qa | grep rtems
|
# rpm -qa | grep rtems
|
# echo
|
# echo
|
# echo Please remove these and restart this script.
|
# echo Please remove these and restart this script.
|
# exit 1
|
# exit 1
|
#fi
|
#fi
|
|
|
#echo Copying specs files.
|
#echo Copying specs files.
|
#if [ ${testing} = no ] ; then
|
#if [ ${testing} = no ] ; then
|
# cd ${RTEMS_DIR}
|
# cd ${RTEMS_DIR}
|
#
|
#
|
# # ./configure || exit 1
|
# # ./configure || exit 1
|
# make || exit 1
|
# make || exit 1
|
#
|
#
|
# # Now generate all the specs
|
# # Now generate all the specs
|
# for target in ${TARGETS}
|
# for target in ${TARGETS}
|
# do
|
# do
|
# tspecs=`find . -name "${target}*"`
|
# tspecs=`find . -name "${target}*"`
|
# if [ "X${tspecs}" = "X" ] ; then
|
# if [ "X${tspecs}" = "X" ] ; then
|
# echo RPM specifications were not generated for ${tspec}.
|
# echo RPM specifications were not generated for ${tspec}.
|
# exit 1
|
# exit 1
|
# fi
|
# fi
|
# ${ECHO} cp -r ${tspecs} ${dst}
|
# ${ECHO} cp -r ${tspecs} ${dst}
|
# done
|
# done
|
#fi
|
#fi
|
|
|
# clean up a bit before we start
|
# clean up a bit before we start
|
cd ${dst}
|
cd ${dst}
|
test -d log || mkdir log
|
test -d log || mkdir log
|
|
|
if [ "X${rpm_build_root}" = "X" ] ; then
|
if [ "X${rpm_build_root}" = "X" ] ; then
|
echo rpm_build_root NOT set!
|
echo rpm_build_root NOT set!
|
exit 1
|
exit 1
|
fi
|
fi
|
|
|
CWD=`pwd`
|
CWD=`pwd`
|
test -d tarballs || mkdir tarballs
|
test -d tarballs || mkdir tarballs
|
|
|
OUT=${CWD}/tarballs
|
OUT=${CWD}/tarballs
|
|
|
# do all the tools
|
# do all the tools
|
for target in ${TARGETS}
|
for target in ${TARGETS}
|
do
|
do
|
bintarfile=${OUT}/${target}-binutils-${binutils}-${binutils_rpm_release}.tar
|
bintarfile=${OUT}/${target}-binutils-${binutils}-${binutils_rpm_release}.tar
|
if [ ${do_binutils} = yes ] ; then
|
if [ ${do_binutils} = yes ] ; then
|
logfile=${CWD}/log/${target}-binutils
|
logfile=${CWD}/log/${target}-binutils
|
# this part is for tar.bz2
|
# this part is for tar.bz2
|
cd ${CWD}
|
cd ${CWD}
|
if [ ! -d binutils-${binutils} ] ; then
|
if [ ! -d binutils-${binutils} ] ; then
|
echo Could not find binutils-${binutils}!
|
echo Could not find binutils-${binutils}!
|
exit 1
|
exit 1
|
fi
|
fi
|
rm -rf b-${target}-bin
|
rm -rf b-${target}-bin
|
mkdir b-${target}-bin
|
mkdir b-${target}-bin
|
cd b-${target}-bin
|
cd b-${target}-bin
|
echo "Building binutils-${binutils} for ${target}"
|
echo "Building binutils-${binutils} for ${target}"
|
../binutils-${binutils}/configure ${CDN_ARGS} --target=${target} \
|
../binutils-${binutils}/configure ${CDN_ARGS} --target=${target} \
|
--verbose --prefix=/opt/rtems >${logfile} 2>&1
|
--verbose --prefix=/opt/rtems >${logfile} 2>&1
|
check_fatal $? "binutils configure"
|
check_fatal $? "binutils configure"
|
|
|
make all >>${logfile} 2>&1
|
make all >>${logfile} 2>&1
|
check_fatal $? "make all"
|
check_fatal $? "make all"
|
|
|
make info >>${logfile} 2>&1
|
make info >>${logfile} 2>&1
|
check_fatal $? "make info"
|
check_fatal $? "make info"
|
|
|
make prefix=${rpm_build_root}/opt/rtems install >>${logfile} 2>&1
|
make prefix=${rpm_build_root}/opt/rtems install >>${logfile} 2>&1
|
check_fatal $? "make install"
|
check_fatal $? "make install"
|
|
|
make prefix=${rpm_build_root}/opt/rtems install-info >>${logfile} 2>&1
|
make prefix=${rpm_build_root}/opt/rtems install-info >>${logfile} 2>&1
|
check_fatal $? "make install-info"
|
check_fatal $? "make install-info"
|
|
|
cd ${buildroot}
|
cd ${buildroot}
|
tar cjf ${bintarfile}.bz2 opt
|
tar cjf ${bintarfile}.bz2 opt
|
cd ${CWD}
|
cd ${CWD}
|
rm -rf b-${target}-bin
|
rm -rf b-${target}-bin
|
${ECHO} rm -rf ${rpm_build_root}/opt
|
${ECHO} rm -rf ${rpm_build_root}/opt
|
#rm -rf ${rpm_build_root}/opt
|
#rm -rf ${rpm_build_root}/opt
|
else
|
else
|
echo Skipping binutils for ${target}
|
echo Skipping binutils for ${target}
|
fi
|
fi
|
|
|
#
|
#
|
# build gcc/newlib
|
# build gcc/newlib
|
#
|
#
|
|
|
if [ ${do_gccnewlib} = yes ] ; then
|
if [ ${do_gccnewlib} = yes ] ; then
|
logfile=${CWD}/log/${target}-gccnewlib
|
logfile=${CWD}/log/${target}-gccnewlib
|
# now build gcc/newlib
|
# now build gcc/newlib
|
# this part is for tar.bz2
|
# this part is for tar.bz2
|
|
|
gcctarfile=${OUT}/${target}-gcc-${gcc}-newlib-${newlib}-${gccnewlib_rpm_release}.tar
|
gcctarfile=${OUT}/${target}-gcc-${gcc}-newlib-${newlib}-${gccnewlib_rpm_release}.tar
|
if [ ${cdn_cross} = "no" ] ; then
|
if [ ${cdn_cross} = "no" ] ; then
|
bintarfile=${dst}/binaries/binutils-${binutils}-${binutils_rpm_release}/${target}-binutils-${binutils}-${binutils_rpm_release}.tar
|
bintarfile=${dst}/binaries/binutils-${binutils}-${binutils_rpm_release}/${target}-binutils-${binutils}-${binutils_rpm_release}.tar
|
cd /
|
cd /
|
rm -rf /opt/*
|
rm -rf /opt/*
|
tar xjf ${bintarfile}.bz2
|
tar xjf ${bintarfile}.bz2
|
fi
|
fi
|
|
|
cd ${CWD}
|
cd ${CWD}
|
if [ ! -d gcc-${gcc} ] ; then
|
if [ ! -d gcc-${gcc} ] ; then
|
echo Could not find gcc-${gcc}!
|
echo Could not find gcc-${gcc}!
|
exit 1
|
exit 1
|
fi
|
fi
|
if [ ! -d gcc-${gcc}/newlib ] ; then
|
if [ ! -d gcc-${gcc}/newlib ] ; then
|
echo Could not find gcc-${gcc}/newlib!
|
echo Could not find gcc-${gcc}/newlib!
|
exit 1
|
exit 1
|
fi
|
fi
|
rm -rf b-${target}-gccnewlib
|
rm -rf b-${target}-gccnewlib
|
mkdir b-${target}-gccnewlib
|
mkdir b-${target}-gccnewlib
|
cd b-${target}-gccnewlib
|
cd b-${target}-gccnewlib
|
echo "Building gcc-${gcc} for ${target}"
|
echo "Building gcc-${gcc} for ${target}"
|
../gcc-${gcc}/configure ${CDN_ARGS} --target=${target} \
|
../gcc-${gcc}/configure ${CDN_ARGS} --target=${target} \
|
--with-gnu-as --with-gnu-ld --with-newlib --verbose --enable-threads \
|
--with-gnu-as --with-gnu-ld --with-newlib --verbose --enable-threads \
|
--prefix=/opt/rtems '--enable-languages=c,c++' >${logfile} 2>&1
|
--prefix=/opt/rtems '--enable-languages=c,c++' >${logfile} 2>&1
|
check_fatal $? "gcc configure"
|
check_fatal $? "gcc configure"
|
|
|
make all >>${logfile} 2>&1
|
make all >>${logfile} 2>&1
|
check_fatal $? "make all"
|
check_fatal $? "make all"
|
|
|
make info >>${logfile} 2>&1
|
make info >>${logfile} 2>&1
|
check_fatal $? "make info"
|
check_fatal $? "make info"
|
|
|
make prefix=${rpm_build_root}/opt/rtems install >>${logfile} 2>&1
|
make prefix=${rpm_build_root}/opt/rtems install >>${logfile} 2>&1
|
check_fatal $? "make install"
|
check_fatal $? "make install"
|
|
|
cd ${target}/newlib
|
cd ${target}/newlib
|
make prefix=${rpm_build_root}/opt/rtems install-info >>${logfile} 2>&1
|
make prefix=${rpm_build_root}/opt/rtems install-info >>${logfile} 2>&1
|
check_fatal $? "newlib make install-info"
|
check_fatal $? "newlib make install-info"
|
|
|
cd ${buildroot}
|
cd ${buildroot}
|
tar cjf ${gcctarfile}.bz2 opt
|
tar cjf ${gcctarfile}.bz2 opt
|
cd ${CWD}
|
cd ${CWD}
|
rm -rf ${rpm_build_root}/opt
|
rm -rf ${rpm_build_root}/opt
|
rm -rf ${rpm_build_root}/opt/rtems
|
rm -rf ${rpm_build_root}/opt/rtems
|
rm -rf b-${target}-gccnewlib
|
rm -rf b-${target}-gccnewlib
|
else
|
else
|
echo Skipping gcc/newlib for ${target}
|
echo Skipping gcc/newlib for ${target}
|
fi
|
fi
|
|
|
#
|
#
|
# build gdb
|
# build gdb
|
#
|
#
|
|
|
if [ ${do_gdb} = yes ] ; then
|
if [ ${do_gdb} = yes ] ; then
|
# now build gdb
|
# now build gdb
|
gdbtarfile=${OUT}/${target}-gdb-${gdb}-${gdb_rpm_release}.tar
|
gdbtarfile=${OUT}/${target}-gdb-${gdb}-${gdb_rpm_release}.tar
|
logfile=${CWD}/log/${target}-gdb
|
logfile=${CWD}/log/${target}-gdb
|
|
|
# this part is for tar.bz2
|
# this part is for tar.bz2
|
|
|
if [ ! -d gdb-${gdb} ] ; then
|
if [ ! -d gdb-${gdb} ] ; then
|
echo Could not find gdb-${gdb}!
|
echo Could not find gdb-${gdb}!
|
exit 1
|
exit 1
|
fi
|
fi
|
mkdir b-${target}-gdb
|
mkdir b-${target}-gdb
|
cd b-${target}-gdb
|
cd b-${target}-gdb
|
case ${target} in
|
case ${target} in
|
arm* | d10v* | d30v* | erc32* | fr30* | h8300* | h8500* | i960* | \
|
arm* | d10v* | d30v* | erc32* | fr30* | h8300* | h8500* | i960* | \
|
m32r* | mcore* | mips* | mn10200* | mn10300* | sh* | sparc*| v850* | \
|
m32r* | mcore* | mips* | mn10200* | mn10300* | sh* | sparc*| v850* | \
|
w65* | z8k*)
|
w65* | z8k*)
|
extra_configure_arguments="--enable-sim"
|
extra_configure_arguments="--enable-sim"
|
;;
|
;;
|
powerpc*)
|
powerpc*)
|
extra_configure_arguments="--enable-sim --enable-sim-powerpc --enable-sim-timebase --enable-sim-hardware"
|
extra_configure_arguments="--enable-sim --enable-sim-powerpc --enable-sim-timebase --enable-sim-hardware"
|
# Enabling this causes the program image to be huge and causes
|
# Enabling this causes the program image to be huge and causes
|
# some gcc/hosts combinations to run out of memory.
|
# some gcc/hosts combinations to run out of memory.
|
# --enable-sim-inline
|
# --enable-sim-inline
|
;;
|
;;
|
*)
|
*)
|
;;
|
;;
|
esac
|
esac
|
echo "Building gdb-${gdb}/configure ${CDN_ARGS} --target=${target}"
|
echo "Building gdb-${gdb}/configure ${CDN_ARGS} --target=${target}"
|
../gdb-${gdb}/configure ${CDN_ARGS} --target=${target} \
|
../gdb-${gdb}/configure ${CDN_ARGS} --target=${target} \
|
${extra_configure_arguments} --verbose --prefix=/opt/rtems >${logfile} 2>&1
|
${extra_configure_arguments} --verbose --prefix=/opt/rtems >${logfile} 2>&1
|
check_fatal $? "make info"
|
check_fatal $? "make info"
|
|
|
make all >>${logfile} 2>&1
|
make all >>${logfile} 2>&1
|
check_fatal $? "make all"
|
check_fatal $? "make all"
|
|
|
make info >>${logfile} 2>&1
|
make info >>${logfile} 2>&1
|
check_fatal $? "make info"
|
check_fatal $? "make info"
|
|
|
make prefix=${rpm_build_root}/opt/rtems install >>${logfile} 2>&1
|
make prefix=${rpm_build_root}/opt/rtems install >>${logfile} 2>&1
|
check_fatal $? "make install"
|
check_fatal $? "make install"
|
|
|
make prefix=${rpm_build_root}/opt/rtems install-info >>${logfile} 2>&1
|
make prefix=${rpm_build_root}/opt/rtems install-info >>${logfile} 2>&1
|
check_fatal $? "make install-info"
|
check_fatal $? "make install-info"
|
|
|
cd ${buildroot}
|
cd ${buildroot}
|
tar cjf ${gdbtarfile}.bz2 opt
|
tar cjf ${gdbtarfile}.bz2 opt
|
cd ${CWD}
|
cd ${CWD}
|
${ECHO} rm -rf ${rpm_build_root}/opt
|
${ECHO} rm -rf ${rpm_build_root}/opt
|
rm -rf ${rpm_build_root}/opt/rtems
|
rm -rf ${rpm_build_root}/opt/rtems
|
rm -rf b-${target}-gdb
|
rm -rf b-${target}-gdb
|
else
|
else
|
echo Skipping gdb for ${target}
|
echo Skipping gdb for ${target}
|
fi
|
fi
|
|
|
done
|
done
|
|
|
# Now we are done
|
# Now we are done
|
|
|
stop=`date`
|
stop=`date`
|
|
|
echo
|
echo
|
echo "Started: " $start
|
echo "Started: " $start
|
echo "Finished: " $stop
|
echo "Finished: " $stop
|
exit 0
|
exit 0
|
|
|