#!/usr/bin/env bash
# DO NOT EDIT - This file was automatically generated.
UNAME=`uname -smp | sed -e 's/ /,/g'`
FILE_SEP='/'; if [[ "$UNAME" = CYGWIN* ]]; then FILE_SEP='\\'; fi
PATH_SEP=':'; if [[ "$UNAME" = CYGWIN* ]]; then PATH_SEP=';'; fi

prog="$(readlink "$0" 2>&1)"
[ $? -eq 127 -o "$prog" = "" ] && prog="$0"
TOP="$(cd "$(dirname "$prog")/.." && pwd)"
if [[ "$UNAME" = CYGWIN* ]]; then PATH="$PATH:$TOP/lib"; TOP="$(cygpath -am "$TOP")"; fi

[ -n "$JAVA_HOME" ] || JAVA_HOME='/usr/local/openjdk6'
[ -n "$JRE_HOME" ] || JRE_HOME='/usr/local/openjdk6/jre'
if [[ "$UNAME" = CYGWIN* ]]; then JAVA_HOME="$(cygpath -am "$JAVA_HOME")"; JRE_HOME="$(cygpath -am "$JRE_HOME")"; fi
if [ -n "$JAVA_HOME" -a -e "$JAVA_HOME/bin/java" ]; then
    JAVA="$JAVA_HOME/bin/java"
    JAR="$JAVA_HOME/bin/jar"
elif [ -n "$JRE_HOME" -a -e "$JRE_HOME/bin/java" ]; then
    JAVA="$JRE_HOME/bin/java"
    JAR="$JRE_HOME/bin/jar"
else
    echo "JAVA_HOME ($JAVA_HOME) is not pointing to a JRE or a JDK"
    exit 1
fi
if [[ "$UNAME" = CYGWIN* ]]; then JAVA="$(cygpath -au "$JAVA")"; JAR="$(cygpath -au "$JAR")"; fi

# NOTE: the above assumes that Cygwin==win32 (probably valid)

#CONFIG_FILE='standard.cfg'
LPG_JAR='lpg.jar'
ECJ_JAR='ecj.jar'
WALA_JAR='com.ibm.wala.cast.java_1.0.0.201101071300.jar'
WALA2_JAR='com.ibm.wala.cast_1.0.0.201101071300.jar'
WALA3_JAR='com.ibm.wala.core_1.1.3.201101071300.jar'
WALA4_JAR='com.ibm.wala.shrike_1.3.1.201101071300.jar'
MATH_JAR='commons-math-2.2.jar'
CROSS_COMPILE_BGP='false'

extra_cp=""
args=""

parse=true
while [ -n "$1" ]; do
    if [ -z "${parse}" ]; then
        args="${args} '$1'"
        shift
        continue
    fi
    case "$1" in
        -classpath|-cp) shift; extra_cp="$1";;
        --) parse=;;
        *) args="${args} '$1'";;
    esac
    shift
done

cp="${TOP}${FILE_SEP}stdlib${FILE_SEP}x10.jar${PATH_SEP}${TOP}${FILE_SEP}lib${FILE_SEP}${MATH_JAR}"
[ -n "${extra_cp}" ] && cp="${extra_cp}${PATH_SEP}${cp}"

command="\"${JAVA}\" -jar \"${TOP}${FILE_SEP}lib${FILE_SEP}${ECJ_JAR}\" -1.5 -nowarn -encoding utf-8 -classpath \"${cp}\" ${args}"
#echo "$command"

eval "$command"
exit $?
