#!@bash@

if [ -e ./@target@ ] && [ -e ./Makefile.am ] ; then
    echo "*** Running uninstalled @target@ ***"
    THIS_PATH="../Util:../BeagleClient:."
    THIS_EXE="./@target@"

    export BEAGLED_COMMAND="./beagled.dummy"

    export MONO_PATH="../Util:../BeagleClient:$MONO_PATH"
    export LD_LIBRARY_PATH="../glue/.libs:$LD_LIBRARY_PATH"

    export BEAGLE_FILTER_PATH="../Filters"

else
    THIS_PATH="@pkglibdir@"
    THIS_EXE="@pkglibdir@/@target@"

    export BEAGLED_COMMAND="beagled"

    export MONO_PATH="@pkglibdir@:$MONO_PATH"
    export LD_LIBRARY_PATH="@pkglibdir@:$LD_LIBRARY_PATH"
fi

if [ -z "$BEAGLE_MONO_RUNTIME" ]; then
   BEAGLE_MONO_RUNTIME="mono"
else
   echo "*** Using mono runtime at $BEAGLE_MONO_RUNTIME ***"
fi

MONO_PATH="$THIS_PATH:$MONO_PATH" exec $BEAGLE_MONO_RUNTIME --debug $MONO_EXTRA_ARGS $THIS_EXE "$@"

