#!@bash@

# This line will be automatically uncommented when you "make install"
#installed=1

if [ -z $installed ] ; then
    echo "*** Running uninstalled @target@ ***"
    THIS_PATH="../Util:../BeagleClient:."
    THIS_EXE="./@target@"

    export MONO_PATH="../Util:../BeagleClient${MONO_PATH+:$MONO_PATH}"
    export LD_LIBRARY_PATH="../glue/.libs${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}"
    export BEAGLE_FILTER_PATH="../Filters${BEAGLE_FILTER_PATH+:$BEAGLE_FILTER_PATH}"
else
    THIS_PATH="@pkglibdir@"
    THIS_EXE="@pkglibdir@/@target@"
fi

if [ -n "$_GET_ON_THE_HEAP_BUDDY_BANDWAGON" ]; then
   n=1
   while [ -e $BEAGLE_HEAP_BUDDY_DIR/outfile.helper.$n ]; do
	 n=$(($n+1))
   done	
   MONO_EXTRA_ARGS="--profile=heap-buddy:$BEAGLE_HEAP_BUDDY_DIR/outfile.helper.$n $MONO_EXTRA_ARGS"
fi

if [ -n "$BEAGLE_DEBUG_FLAG_IS_SET" ]; then
   MONO_EXTRA_ARGS="--debug $MONO_EXTRA_ARGS"
fi

export MONO_PATH="$THIS_PATH${MONO_PATH+:$MONO_PATH}"

CMDLINE="mono --debug $MONO_EXTRA_ARGS $THIS_EXE $@"

PROCESS_NAME="beagled-helper"
exec -a $PROCESS_NAME $CMDLINE

