#!/bin/bash

if [ "$T3Q_HOME" == "" ]; then
   echo "T3Q_HOME environment variable not set! It must point to the T3Q installation directory!";
   exit;
fi

if [ "$JAVA_HOME" == "" ]; then
   echo "JAVA_HOME environment variable not set! It must point to the directory of your Java Runtime >= 5.0";
   exit;
fi

JAVA=$JAVA_HOME/bin/java 

CLASSPATH=$CLASSPATH:$T3Q_HOME/lib/com.yourkit.javaprofiler.controller_7.0.4.jar
CLASSPATH=$CLASSPATH:$T3Q_HOME/lib/de.ugoe.cs.swe.trex.antlr_2.7.6.jar
CLASSPATH=$CLASSPATH:$T3Q_HOME/lib/org.eclipse.core.resources_3.4.0.v20080604-1400.jar
CLASSPATH=$CLASSPATH:$T3Q_HOME/lib/org.eclipse.core.runtime_3.4.0.v20080512.jar
CLASSPATH=$CLASSPATH:$T3Q_HOME/lib/org.eclipse.equinox.common_3.4.0.v20080421-2006.jar
CLASSPATH=$CLASSPATH:$T3Q_HOME/lib/org.eclipse.osgi_3.4.0.v20080605-1900.jar
CLASSPATH=$CLASSPATH:$T3Q_HOME/lib/stringtemplate.jar
CLASSPATH=$CLASSPATH:$T3Q_HOME/lib/xpp3_min-1.1.4c.jar
CLASSPATH=$CLASSPATH:$T3Q_HOME/lib/xstream-1.3.1.jar
CLASSPATH=$CLASSPATH:$T3Q_HOME/lib/commons-cli-1.2.jar

if [ -d "$T3Q_HOME/../de.ugoe.cs.swe.trex.core/bin/de" ]; then
   CLASSPATH=$CLASSPATH:$T3Q_HOME/../de.ugoe.cs.swe.trex.core/bin
else
   CLASSPATH=$CLASSPATH:$T3Q_HOME/lib/de.ugoe.cs.swe.trex.core_0.6.0.200810271154.jar
fi

if [ -d "$T3Q_HOME/../org.etsi.common/bin/org" ]; then
   CLASSPATH=$CLASSPATH:$T3Q_HOME/../org.etsi.common/bin
else
   CLASSPATH=$CLASSPATH:$T3Q_HOME/lib/org.etsi.common.jar
fi

if [ -d "$T3Q_HOME/bin/org" ]; then
   CLASSPATH=$CLASSPATH:$T3Q_HOME/bin
else
   CLASSPATH=$CLASSPATH:$T3Q_HOME/lib/t3q.jar
fi

JAVA_CMD="$JAVA -Xmx712m -Xss128m -cp $CLASSPATH org.etsi.t3q.T3Q"

if [[ $# > 0 && $1 == "--echo" ]]; then
	echo $JAVA_CMD
else
	$JAVA_CMD "$@"
fi

#$JAVA -Xmx712m -Xss128m -cp $CLASSPATH org.etsi.t3q.T3Q "$@"
