|
From: <wsh...@us...> - 2003-08-08 14:52:54
|
Update of /cvsroot/emc/rcslib/etc
In directory sc8-pr-cvs1:/tmp/cvs-serv5926
Added Files:
Tag: wps_multiplat_dev_branch
multiplatbuild.sh
Log Message:
.
--- NEW FILE: multiplatbuild.sh ---
#!/bin/sh
startdir=`pwd`
if test "x${rcsdir}" = "x" ; then
progdir=`echo $0 | sed 's#/multiplatbuild.sh##' | sed 's#multiplatbuild.sh##'`
if test "x${progdir}" != "x" ; then
if ( cd ${progdir} && cd .. && test -f src/rcs.hh ) ; then
cd ${progdir}
cd ..
rcsdir=`pwd`
fi
fi
fi
if test "x${rcsdir}" = "x" ; then
if test -f src/rcs.hh ; then
rcsdir=`pwd`
elif test -f ../src/rcs.hh ; then
rcsdir=`cd ..; pwd`
elif test -f ../../src/rcs.hh ; then
rcsdir=`cd ../..; pwd`
elif test -f ../../../src/rcs.hh ; then
rcsdir=`cd ../../.. ; pwd`
elif test -f ../../../../src/rcs.hh ; then
rcsdir=`cd ../../../.. ; pwd`
fi
fi
if test "x${rcsdir}" = "x" ; then
echo "Can not determine rcsdir." >&2
exit 1
fi
if test "x${CC}" = "x" ; then
if qcc -v >/dev/null 2>/dev/null ; then
CC=qcc;
elif gcc -v >/dev/null 2>/dev/null ; then
CC=gcc;
elif /usr/bin/gcc -v >/dev/null 2>/dev/null ; then
CC=/usr/bin/gcc;
elif cc -v >/dev/null 2>/dev/null ; then
CC=cc;
fi
fi
CC_NAME=`${CC} -v 2>&1 | tail -n 1 | sed 'y# #_#' | sed 'y#-#_#' | sed 'y#:#_#' | sed 'y#(#_#' | sed 'y#)#_#' `
UNAME_S=`uname -s | sed 'y# #_#' | sed 'y#-#_#' | sed 'y#:#_#' | sed 'y#(#_#' | sed 'y#)#_#' `
UNAME_R=`uname -r | sed 'y# #_#' | sed 'y#-#_#' | sed 'y#:#_#' | sed 'y#(#_#' | sed 'y#)#_#'`
UNAME_M=`uname -m | sed 'y# #_#' | sed 'y#-#_#' | sed 'y#:#_#' | sed 'y#(#_#' | sed 'y#)#_#'`
if test "x${UNAME_S}" = "xLinux" ; then
if test "x`${rcsdir}/etc/havertlinux.sh | head -n 1`" = "xYES" ; then
UNAME_S=Linux_with_rtlinux;
elif test "x`${rcsdir}/etc/havertai.sh | head -n 1`" = "xYES" ; then
UNAME_S=Linux_with_rtai;
fi
fi
LIBC_NAME=NOT_GLIBC
if test -f /usr/include/features.h ; then
if grep _GLIBC /usr/include/features.h >/dev/null 2>/dev/null ; then
GLIBC_MAJOR_VERSION=`grep __GLIBC__ /usr/include/features.h | grep '#define' | grep -v PREREQ | head -n 1 | awk '{printf("%s",$3);}'`
GLIBC_MINOR_VERSION=`grep __GLIBC_MINOR__ /usr/include/features.h | grep '#define' | grep -v PREREQ | head -n 1 | awk '{printf("%s",$3);}'`
LIBC_NAME=GLIBC_${GLIBC_MAJOR_VERSION}_${GLIBC_MINOR_VERSION}
else
LIBC_NAME=NOT_GLIBC
fi
else
LIBC_NAME=NOT_GLIBC
fi
install_dir=${rcsdir}/multiplatinstalls/${UNAME_S}/${UNAME_R}/${UNAME_M}/${LIBC_NAME}/${CC_NAME}
echo "install_dir=${install_dir}" >&2
if test ! -d ${install_dir} ; then
mkdir -p ${install_dir} || (echo "mkdir -p ${install_dir} failed." >&2 ; exit 127 ) || exit 127
fi
build_dir=${rcsdir}/multiplatbuilds/${UNAME_S}/${UNAME_R}/${UNAME_M}/${LIBC_NAME}/${CC_NAME}
echo "build_dir=${build_dir}" >&2
if test ! -d ${build_dir} ; then
mkdir -p ${build_dir} || (echo "mkdir -p ${build_dir} failed." >&2 ; exit 127 )
fi
cd ${build_dir} || (echo "cd ${build_dir} failed." >&2 ; exit 127 ) || exit 127
PLAT=`(cd ${rcsdir}; mkdir_cmd=true; . ${rcsdir}/etc/platname)`
export PLAT
mkdir -p ${rcsdir}/plat || (echo "mkdir -p ${rcsdir}/plat failed." >&2 ; exit 127 ) || exit 127
\rm -f /tmp/linktest* >/dev/null 2>/dev/null
( cd /tmp ; touch linktestfile$$ ; ln -s linktestfile$$ linktestfile$$.link ); >/dev/null 2>/dev/null
#ls -l /tmp/link*
if test -h /tmp/linktestfile$$.link -a '!' -h /tmp/linktestfile$$ ; then
LINK_FLAG=-h;
else
LINK_FLAG=-L;
fi
\rm -f /tmp/linktest* >/dev/null 2>/dev/null
if test ${LINK_FLAG} ${rcsdir}/plat/${PLAT} ; then
rm ${rcsdir}/plat/${PLAT} || ( echo "Can not remove old symbolic link." >&2 ; exit 127 ) || exit 127
fi
if test -d ${rcsdir}/plat/${PLAT} ; then
(cd ${rcsdir}/plat && (mkdir -p .moved.$$ ; mv ${PLAT} .moved.$$ ) ) || (echo "Can not move old plat out of the way." >&2 ; exit 127 ) || exit 127
fi
( cd ${rcsdir}/plat && ln -s ${install_dir} ${PLAT} || exit 127 ) || ( echo "Can not setup symbolic link." >&2 ; exit 127 ) || exit 127
( cd ${rcsdir} ; PLAT=; rm ~/.platname* ; mkdir_cmd=true; . ${rcsdir}/etc/platname >/dev/null; 2>/dev/null;
if test "x${ORIG_PLAT}" != "x" -a "x${ORIG_PLAT}" != "x${PLAT}" ; then
if test ${LINK_FLAG} ${rcsdir}/plat/${ORIG_PLAT} ; then
rm ${rcsdir}/plat/${ORIG_PLAT} ;
elif test -d ${rcsdir}/plat/${ORIG_PLAT} ; then
( mkdir -p ${rcsdir}/plat/.moved.$$/ ) >/dev/null 2>/dev/null;
mv ${rcsdir}/plat/${ORIG_PLAT} ${rcsdir}/plat/.moved.$$/
fi
(cd ${rcsdir}/plat/ ; ln -s ${install_dir} ${ORIG_PLAT}; )
fi
if test "x${ETC_RELEASE_PLAT}" != "x" -a "x${ETC_RELEASE_PLAT}" != "x${PLAT}" ; then
if test ${LINK_FLAG} ${rcsdir}/plat/${ETC_RELEASE_PLAT} ; then
rm ${rcsdir}/plat/${ETC_RELEASE_PLAT} ;
elif test -d ${rcsdir}/plat/${ETC_RELEASE_PLAT} ; then
( mkdir -p ${rcsdir}/plat/.moved.$$/ ) >/dev/null 2>/dev/null;
mv ${rcsdir}/plat/${ETC_RELEASE_PLAT} ${rcsdir}/plat/.moved.$$/
fi
(cd ${rcsdir}/plat/ ; ln -s ${install_dir} ${ETC_RELEASE_PLAT}; )
fi
if test "x${DEBIAN_PLAT}" != "x" -a "x${DEBIAN_PLAT}" != "x${PLAT}" ; then
if test ${LINK_FLAG} ${rcsdir}/plat/${DEBIAN_PLAT} ; then
rm ${rcsdir}/plat/${DEBIAN_PLAT} ;
elif test -d ${rcsdir}/plat/${DEBIAN_PLAT} ; then
( mkdir -p ${rcsdir}/plat/.moved.$$/ ) >/dev/null 2>/dev/null;
mv ${rcsdir}/plat/${DEBIAN_PLAT} ${rcsdir}/plat/.moved.$$/
fi
(cd ${rcsdir}/plat/ ; ln -s ${install_dir} ${DEBIAN_PLAT}; )
fi
if test "x${REDHAT_PLAT}" != "x" -a "x${REDHAT_PLAT}" != "x${PLAT}" ; then
if test ${LINK_FLAG} ${rcsdir}/plat/${REDHAT_PLAT} ; then
rm ${rcsdir}/plat/${REDHAT_PLAT} ;
elif test -d ${rcsdir}/plat/${REDHAT_PLAT} ; then
( mkdir -p ${rcsdir}/plat/.moved.$$/ ) >/dev/null 2>/dev/null;
mv ${rcsdir}/plat/${REDHAT_PLAT} ${rcsdir}/plat/.moved.$$/
fi
(cd ${rcsdir}/plat/ ; ln -s ${install_dir} ${REDHAT_PLAT}; )
fi
if test "x${OLD_PLAT}" != "x" -a "x${OLD_PLAT}" != "x${PLAT}" ; then
if test ${LINK_FLAG} ${rcsdir}/plat/${OLD_PLAT} ; then
rm ${rcsdir}/plat/${OLD_PLAT} ;
elif test -d ${rcsdir}/plat/${OLD_PLAT} ; then
( mkdir -p ${rcsdir}/plat/.moved.$$/ ) >/dev/null 2>/dev/null;
mv ${rcsdir}/plat/${OLD_PLAT} ${rcsdir}/plat/.moved.$$/
fi
(cd ${rcsdir}/plat/ ; ln -s ${install_dir} ${OLD_PLAT}; )
fi
if test "x${PLATBASE}" != "x" -a "x${PLATBASE}" != "x${PLAT}" ; then
if test ${LINK_FLAG} ${rcsdir}/plat/${PLATBASE} ; then
rm ${rcsdir}/plat/${PLATBASE} ;
elif test -d ${rcsdir}/plat/${PLATBASE} ; then
( mkdir -p ${rcsdir}/plat/.moved.$$/ ) >/dev/null 2>/dev/null;
mv ${rcsdir}/plat/${PLATBASE} ${rcsdir}/plat/.moved.$$/
fi
(cd ${rcsdir}/plat/ ; ln -s ${install_dir} ${PLATBASE}; )
fi
)>/dev/null 2>/dev/null;
if test $# -lt 1 ; then
if test ! -f Makefile ; then
${rcsdir}/configure --prefix=${install_dir} || (echo "configure failed." >&2 ; exit 127 ) || exit 127
fi
make || (echo "make failed." >&2 ; exit 127 ) || exit 127
make install || (echo "make install failed." >&2 ; exit 127 ) || exit 127
elif test "x${1}" = "xconfig" ; then
${rcsdir}/configure --prefix=${install_dir} $2 $3 $4 $5 || (echo "configure failed." >&2 ; exit 127 ) || exit 127
elif test "x${1}" = "xmake" ; then
if test ! -f Makefile ; then
${rcsdir}/configure --prefix=${install_dir} || (echo "configure failed." >&2 ; exit 127 ) || exit 127
fi
make || (echo "make failed." >&2 ; exit 127 ) || exit 127
else
if test ! -f Makefile -a "xdistclean" != "x${1}" ; then
${rcsdir}/configure --prefix=${install_dir} || exit 127
fi
if test -f Makefile ; then
make $* || (echo "make $* failed." >&2 ; exit 127 ) || exit 127
fi
fi
echo "rcsdir=${rcsdir}" >&2
echo "install_dir=${install_dir}" >&2
echo "build_dir=${build_dir}" >&2
echo "PLAT=${PLAT}" >&2
exit 0
|