#!/bin/sh

#Recherche de java et controle que se soit une version SUN
vJavaCmd="java"
xCheckJava () {
	vInputVarName=\$"$1"
	vInputVarVal=`eval "expr \"$vInputVarName\" "`
	if [ -z "$vInputVarVal" ];then
		eval "$1=false"
		return
	fi
	vSunJavaFound=`$vInputVarVal -version 2>&1 | grep -o "HotSpot"`
	if [ "$vSunJavaFound" != "HotSpot" ]; then
		eval "$1=false"
		return
	fi
}
xCheckJava vJavaCmd
if [ "$vJavaCmd" = "false" ]; then
	vJavaCmd="$JAVA_HOME/bin/java"
	xCheckJava vJavaCmd
	if [ "$vJavaCmd" = "false" ]; then
		echo "ERREUR: JRE de SUN introuvable. Veuillez déclarer la variable d'environnement JAVA_HOME."
		exit 1
	fi
fi

echo "Compilation, scserver"

$vJavaCmd -classpath "libext/ant.jar:libext/ant.nodeps.jar:libext/ant.launcher.jar:libext/ant.contrib.jar" -Xmx150m org.apache.tools.ant.Main -buildfile build.xml
