#!/bin/bash
#sh
TAUROOT=/usr/src/packages/BUILD/tau-2.35.1/TAUBUILD
MACHINE=x86_64

if [ ! -d "$TAUROOT" ]; then #If the original root directory is not found find and work from this script's bin directory 

  SOURCE="$0"
  while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
    DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
    SOURCE="$(readlink "$SOURCE")"
    [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
  done
  TAUBIN="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"

  TAUROOT=`dirname $TAUBIN`
  MACHINE=`basename $TAUROOT`
  TAUROOT=`dirname $TAUROOT`

fi #End backup root search


GUI_LIBDIR=${TAUROOT}/${MACHINE}/lib

# MAIN_LIB=${GUI_LIBDIR}/slog2printrecur.jar
MAIN_LIB=${GUI_LIBDIR}/slog2printserial.jar


if [ -z "${GUI_LIBDIR}" -o "${GUI_LIBDIR}" = "/lib" ]; then
    echo "GUI_LIBDIR is NOT set!"
    exit 1
else
    echo "GUI_LIBDIR is set. GUI_LIBDIR = "${GUI_LIBDIR}
fi

java -Xmx500m -Xms32m -jar ${MAIN_LIB} "$@"
