#!/bin/sh

# install STCP

STCPDIR=`pwd`
export STCPDIR
WHERE=/usr
export WHERE

usage()
{
    echo "    usage: ./install solaris|linux"
    exit 0
}

OS_TYPE=$1
if [ -z "$OS_TYPE" ]
then
    echo "Missing parameter"
    usage
fi
if [ $OS_TYPE != 'solaris' ] && [ $OS_TYPE != 'linux' ]
then
    echo "Unknown operating system type:"
    usage
fi

echo "STCP Installer"
#echo "Installing in: $WHERE"
#if [ ! "`id | grep root`" ]; then
#    echo "Terminated: You must be root to install STCP"
#    exit 1
#fi

echo "Compiling SSIM libraries..."
cd $STCPDIR/ssim
cp Makefile.$OS_TYPE Makefile
make -s clean
make -s depend
make -s
echo "Compiling STCP..."
cd $STCPDIR/src
cp Makefile.$OS_TYPE Makefile
make -s clean
make -s depend
make -s

#cd /

#if [ -x $WHERE/bin/stcp ]; then
#    echo "Removing old version of STCP"
#    rm -f $WHERE/bin/stcp
#    rm -f $WHERE/man/man1/stcp
#fi
#cp $STCPDIR/src/stcp $WHERE/bin/stcp
#cp $STCPDIR/man/man1/stcp.1 $WHERE/man/man1/stcp.1

echo "Done."

