#! /bin/sh

export ANT_OPTS=-Xmx256m

bootclasspath=$JAVA_HOME/jre/lib/rt.jar
os=""
ws=""
target=""

usage="usage: $0 -os <osType> -ws <windowingSystemType> [-bc <bootclasspath>] [-target <target>]"

if [ $# -lt 1 ]
then
	echo >&2 "$usage"
	exit 1
fi

while [ $# -gt 0 ]
do
	case "$1" in
		-os) os="$2"; shift;;
		-ws) ws="$2"; shift;;
		-bc) bootclasspath="$2"; shift;;
		-target) target="$2"; shift;;
 		-*)
			echo >&2 $usage
			exit 1;;
		*) break;;	# terminate while loop
	esac
	shift
done

if [ "x$os" = "x" ]
then
	echo >&2 "$usage"
	exit 1
fi

if [ "x$ws" = "x" ]
then
	echo >&2 "$usage"
	exit 1
fi

if [ "$os-$ws" = "linux-motif" ] || [ "$os-$ws" = "linux-gtk" ] || [ "$os-$ws" = "solaris-motif" ] || [ "$os-$ws" = "aix-motif" ] || [ "$os-$ws" = "hpux-motif" ] || [ "$os-$ws" = "qnx-photon" ] || [ "$os-$ws" = "win32-win32" ]
then
	ant -buildfile build.xml $target -Dos=$os -Dws=$ws -Dbootclasspath=$bootclasspath
else
	echo "The os-ws combination of $os-$ws is not valid."
	exit 1
fi
