#!/bin/sh

prefix=/usr/local
exec_prefix=${prefix}
libdir=${exec_prefix}/lib 
turtledir=
beagledir=

EXE_TO_RUN="$libdir/f-spot/f-spot.exe"

if test "x$turtledir" != "x"; then
    export MONO_PATH=$turtledir/lib:$turtledir/gui:$MONO_PATH
fi

if test "x$beagledir" != "x"; then
    export MONO_PATH=$beagledir:$MONO_PATH
fi

[ -n "$FSPOT_DEBUG" ] && FSPOT_DEBUG="--debug"
[ -n "$FSPOT_TRACE" ] && FSPOT_TRACE="--trace=$FSPOT_TRACE"
[ -n "$FSPOT_PROFILE" ] && FSPOT_PROFILE="--profile=$FSPOT_PROFILE"

for arg in $*; do
    case "x$arg" in
    	x--debug)
	    FSPOT_DEBUG="$arg"
	    ;;
    	x--trace=*)
	    FSPOT_TRACE="$arg"
	    ;;
	x--profile=*)
	    FSPOT_PROFILE="$arg"
	    ;;
	x--uninstalled)
	    echo "*** Running uninstalled f-spot ***"
	    EXE_TO_RUN="./f-spot.exe"
	    export MONO_PATH=../Tao/Tao.OpenGl:../Tao/Tao.OpenGl.Glu:../Tao/Tao.OpenGl.ExtensionLoader:../dbus-sharp:../dbus-sharp-glib:../google-sharp:../gnome-keyring-sharp:../FlickrNet:../SmugMugNet:../libgphoto2-sharp:../semweb:../glitz-sharp/src/:../mono-addins/Mono.Addins:../mono-addins/Mono.Addins.Setup:../mono-addins/Mono.Addins.Gui:$MONO_PATH
	    ;;
    esac
done

if [ -n "$FSPOT_DEBUG" ]; then
    echo "** Running f-spot in Debug Mode **"
fi

if [ -n "$FSPOT_DEBUG" -o -n "$FSPOT_TRACE" -o -n "$FSPOT_PROFILE" ]; then
    MONO_OPTIONS="$FSPOT_DEBUG $FSPOT_TRACE $FSPOT_PROFILE"
    echo "** Running Mono with $MONO_OPTIONS **"
fi

exec mono $MONO_OPTIONS $EXE_TO_RUN "$@"
