#!/bin/sh

#********************************************************************
# AUTHORS: Vijay Ganesh, David L. Dill
#
# BEGIN DATE: November, 2005
#
# LICENSE: Please view LICENSE file in the home dir of this Program
#********************************************************************

while [ $# -gt 0 ]; do
    case "$1" in
	--with-prefix=*)
	    PREFIX=${1#*=};;
	--with-gcc=*)
	    CC=${1#*=};;
	--with-g++=*)
	    CXX=${1#*=};;
	--with-fpic)
	    CFLAGS_FPIC=-fpic;;
	*)
	    echo "Usage: $0 [options]"
	    echo "   --with-prefix=/prefix/path   Install STP at the specified path"
	    echo "   --with-gcc=/path/to/gcc      Use gcc at the specified path"
	    echo "   --with-g++=/path/to/g++      Use g++ at the specified path"
	    echo "   --with-fpic                  Required to build 64-bit shared libraries."
	    echo "$0 failed"
	    exit 1;;
    esac

    shift
done

# check for an option --with-prefix=/path/to/prefix and use that as the
# prefix, otherwise use /usr/local
PREFIX=${PREFIX:-/usr/local}

echo "export PREFIX=$PREFIX" > scripts/config.info
echo "Setting prefix to... $PREFIX"
if [ -n "$CC" ]; then
    echo "export CC=$CC" >> scripts/config.info
    echo "Setting CC to... $CC"
fi
if [ -n "$CXX" ]; then
    echo "export CXX=$CXX" >> scripts/config.info
    echo "Setting CXX to... $CXX"
fi
if [ -n "$CFLAGS_FPIC" ]; then
    echo "export CFLAGS_FPIC=$CFLAGS_FPIC" >> scripts/config.info
    echo "Setting CFLAGS_FPIC to... $CFLAGS_FPIC"
fi

echo "STP is configured successfully."
cp scripts/Makefile.in Makefile

echo
echo "Type 'make' to compile STP."
echo "Type 'make install' to compile & install STP."
