#!/bin/sh

####
#### A script to run xchek
####

##
## read global and user configuration files if they exist
##
if [ -f /etc/xchek.conf ] ; then 
    . /etc/xchek.conf
fi

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

###
### find xchek root directory
###

PRG="$0"
XCHEK_ROOT=`dirname $PRG`/..

CURRENT_DIR=`pwd`

###
### go to the root directory
###
#cd $XCHEK_ROOT 

###
### setup environment variables
###
if [ -z "$ROOT" ] ; then
 source $XCHEK_ROOT/bin/env.sh `pwd` > /dev/null
fi

###
### now we are ready to run
###
if [ "$DEBUG" == "no" ] ; then
    unset ASSERT
else
    ASSERT=-ea
fi
MEMORY_MIN=${MEMORY_MIN:-512m}
MEMORY_MAX=${MEMORY_MAX:-512m}

echo "ms: $MEMORY_MIN, mx: $MEMORY_MAX"

java $ASSERT -Xms$MEMORY_MIN -Xmx$MEMORY_MAX -Duser.dir="$CURRENT_DIR" -Dcvcl.cmd="${CVCL_BINARY}" $JAVA_OPT edu.toronto.cs.yasm.YasrApp "$@"

###
### return to parent directory
###
cd $CURRENT_DIR



