#!/bin/bash
# This file is a launch script for Linux, Mac, and Cygwin/MSys

dir=$(dirname "${BASH_SOURCE[0]}") # Directory containing this script.
jar_dir="$dir" # The JAR file is located in the same folder as this script.

if [[ $OSTYPE == cygwin ]] && type -p cygpath &> /dev/null ; then
    # The java program on Windows expects the directory in Windows format
    # instead of cygwin/linux format.
	jar_dir=$(cygpath -w "$jar_dir")
fi

# Modify PATH (for Windows) and LD_LIBRARY_PATH (for Linux/Mac) so that
# the RNAstructure_GUI library is properly loaded regardless of the CWD
#export LD_LIBRARY_PATH+=":$dir"
#export PATH+=":$dir"
# Set DATAPATH so the native library can find the thermodynamic 
# parameter files.
#export DATAPATH="$dir/../data_tables"

OPTIONS=()
if [[ $OSTYPE = darwin* ]]; then
    # Specify option for Mac OS X Menu title.
    OPTIONS+=('-Xdock:name=RNAstructure')
fi

# __JAVA_BIN_DIR__ is replaced with the autodetected jdk binary directory
__JAVA_BIN_DIR__/java "${OPTIONS[@]}" -Djava.library.path=$jar_dir -jar "$jar_dir"/RNAstructure.jar  "$@"