#! /bin/sh

if [ -f $HOME/.antrc ]; then 
	. $HOME/.antrc
fi

LOCALCLASSPATH="`java-config --classpath ant`"

if [ -n "$CLASSPATH" ]; then
	LOCALCLASSPATH="$CLASSPATH:$LOCALCLASSPATH"
fi

if [ -n "$JAVA_HOME" ]; then
	if [ -f "$JAVA_HOME/lib/tools.jar" ]; then
		LOCALCLASSPATH="$LOCALCLASSPATH:$JAVA_HOME/lib/tools.jar"
    fi
	if [ -f "$JAVA_HOME/lib/classes.zip" ]; then
		LOCALCLASSPATH="$LOCALCLASSPATH:$JAVA_HOME/lib/classes.zip"
	fi
else
	cat <<EOF 1>&2
Warning: JAVA_HOME environment variable is not set (or not exported).
  If build fails because sun.* classes could not be found
  you will need to set the JAVA_HOME environment variable
  to the installation directory of java.
EOF
fi

exec java -classpath $LOCALCLASSPATH -Dant.home=${ANT_HOME:=/usr/share/java/ant} $ANT_OPTS \
	org.apache.tools.ant.Main "$@"

