#!/bin/sh

if [ -z "${OPTITDIR}" ] ; then
    OPTITDIR=/usr/local/optit
fi

LD_LIBRARY_PATH=${OPTITDIR}/lib:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH
runide_sh=$1
shift

echo "No memory profiling; to turn on, change -J-Xrunpri:dmp -dmp to just -J-Xrunpri"
exec ${runide_sh} \
    -J-DOPTITDIR=${OPTITDIR} \
    -J-Xbootclasspath/a:${OPTITDIR}/lib/oibcp.jar \
    -J-Xboundthreads \
    -cp ${OPTITDIR}/lib/optit.jar \
    -J-Xrunpri:dmp \
    -Jintuitive.audit.Audit \
    -J-startCPUprofiler:type=sampler,samplingPeriod=1,onlyCPU=true \
    -J-dmp \
    -J-wait \
     $*
