#!/bin/sh -

# This script will start Artemis on a UNIX system.  This script should
# be left in the same directory as the rest of the Artemis
# distribution, so that the java class files can be found.  If
# necessary a symbolic link can be made to this script from
# /usr/local/bin/ or elsewhere.


# $Header: /nfs/disk222/yeastpub/Repository/powmap/art,v 1.47 2000/09/26 09:29:54 kmr Exp $

# resolve links - $0 may be a link
PRG=$0
progname=`basename $0`

while [ -h "$PRG" ] ; do
  ls=`ls -ld "$PRG"`
  link=`expr "$ls" : '.*-> \(.*\)$'`
  if expr "$link" : '.*/.*' > /dev/null; then
    PRG="$link"
  else
    PRG="`dirname $PRG`/$link"
  fi
done

ARTEMIS_HOME=`dirname "$PRG"`/.

if [ "$CLASSPATH" = "" ]
then
    CLASSPATH=$ARTEMIS_HOME:$ARTEMIS_HOME/lib/JacORB.jar
else
    CLASSPATH=$ARTEMIS_HOME:$ARTEMIS_HOME/lib/JacORB.jar:$CLASSPATH
fi

export CLASSPATH


ARTEMIS_PROPERTIES="-Dartemis.environment=UNIX"

MEM="-mx150m -ms20m"

if [ "$ARTEMIS_JVM_FLAGS" = "" ]
then
    FLAGS="$MEM -noverify"
else
    FLAGS="$MEM -noverify $ARTEMIS_JVM_FLAGS"
fi


# work-around for OSF JVM core dump problem
if [ `uname` = OSF1 ]
then
    FLAGS="$FLAGS -Dsimple_splash_screen=true"
fi


QUIET=no

if [ $# = 0 ]
then
    :
else
    if [ "$1" = "-h" -o "$1" = "--help" ]
    then
        cat <<EOF
usage: $0 [-options options_file] [EMBL/GENBANK/SEQUENCE_FILE [+FEATURE_FILE] [+FEATURE_FILE] ...] ...
EOF
        exit 0
    fi


    while test $# != 0
    do
        case $1 in
        -options) FLAGS="$FLAGS -Dextra_options=$2"; shift ;;
        -D*) FLAGS="$FLAGS $1" ;;
        -fast) FLAGS="$FLAGS -fast" ;;
        -quiet) QUIET=yes ; FLAGS="$FLAGS -Drun_quietly=true" ;;
        *) break ;;
        esac
        shift
    done
fi

if [ "$JAVA_VM" = "" ]
then
    JAVA=java
else
    JAVA=$JAVA_VM
fi

if [ "$QUIET" = no ]
then
    echo starting Artemis with flags: $FLAGS 1>&2
fi

$JAVA $FLAGS $ARTEMIS_PROPERTIES Diana $*
