#!/bin/sh

R_HOME=/Library/Frameworks/R.framework/Resources

R_SHARE_DIR=/Library/Frameworks/R.framework/Resources/share
export R_SHARE_DIR
R_INCLUDE_DIR=/Library/Frameworks/R.framework/Resources/include
export R_INCLUDE_DIR
R_DOC_DIR=/Library/Frameworks/R.framework/Resources/doc
export R_DOC_DIR

JRI_LD_PATH=${R_HOME}/lib:${R_HOME}/bin:
if test -z "$LD_LIBRARY_PATH"; then
  LD_LIBRARY_PATH=$JRI_LD_PATH
else
  LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JRI_LD_PATH
fi
JAVA=/Library/Java/JavaVirtualMachines/jdk-21.0.8+9/Contents/Home/bin/java

: ${CLASSPATH=.:examples}

export R_HOME
export LD_LIBRARY_PATH

if [ -z "$1" ]; then
    echo ""
    echo " Usage: run <class> [...]"
    echo ""
    echo " For example: ./run rtest"
    echo " Set CLASSPATH variable if other than .:examples is desired"
    echo ""
else
    ${JAVA} -Djava.library.path=.: -cp ${CLASSPATH}:src/JRI.jar:JRI.jar $*
fi
