#!/bin/sh

reWrite() {
    ret=""
    WD=`pwd`
    for arg in $*
    do
	if [ -f ./$arg ]
	then
	    ret="$ret $WD/$arg"
	else
	    ret="$ret $arg"
	fi
   done

    echo "$ret"
}
 
MD_BIN_PATH=/usr/local/lib/monodevelop/bin

if [ -n $PKG_CONFIG_PATH ]; then
	export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/lib/pkgconfig/
else
	export PKG_CONFIG_PATH=/usr/lib/pkgconfig/
fi

ARGS=`reWrite "$@"`
set -- $ARGS

case x$1 in
	x--profile)
		exec /usr/bin/mono --profile $MD_BIN_PATH/mdrun.exe $@
		exit 0
		;;
	x--debug)
		export MONODEVELOP_DISPATCH_DEBUG=yes
		exec /usr/bin/mono --debug $MD_BIN_PATH/mdrun.exe $@
		exit 0
		;;
	x--trace)
		exec /usr/bin/mono --trace $MD_BIN_PATH/mdrun.exe $@
		exit 0;
		;;
esac

exec /usr/bin/mono $MD_BIN_PATH/mdrun.exe $@

