#! /bin/sh
# Fancy colors used to beautify the output a bit.
#
NORMAL="\033[0m"
BOLD="\033[1m"
RED="\033[91m"
YELLOW="\033[93m"
GREEN="\033[92m"

# Checks for Python interpreter. Honours $PYTHON if set. Stores path to
# interpreter in $PYTHON.
#
checkPython()
{
	if [ -z $PYTHON ]; then
	  PYTHON=`which python 2>/dev/null`
	fi
	echo -n "Checking for Python               :  "
	if [ ! -x "$PYTHON" ]; then
	  echo -e $GREEN"not found!"$NORMAL
	  echo "Please make sure that the Python interpreter is available in your PATH"
	  echo "or invoke configure using the PYTHON flag, e.g."
	  echo "$ PYTHON=/usr/local/bin/python configure"
	  exit 1
	fi
	echo -e $GREEN"$PYTHON"$NORMAL
}

# Generates a Makefile. Requires that $WAF is set.
#
generateMakefile()
{
	cat > Makefile << EOF
all:
	@$WAF

verb:
	@$WAF -v

install:
	@$WAF install

clean:
	@$WAF clean

uninstall:
	@$WAF uninstall

dist:
	@$WAF dist

distclean:
	@$WAF distclean
	rm -rf cache/
EOF
}

checkPython
WAF=./waf

if [[ "$1" == "--help" ]]; then
   $WAF --help
   exit
fi

generateMakefile
$WAF configure $@

