#!/bin/sh
#

BINARY="porrasturvat.bin"

# Function to find the real directory a program resides in.
# Feb. 17, 2000 - Sam Lantinga, Loki Entertainment Software
FindPath()
{
    fullpath="`echo $1 | grep /`"
    if [ "$fullpath" = "" ]; then
        oIFS="$IFS"
        IFS=:
        for path in $PATH
        do if [ -x "$path/$1" ]; then
               if [ "$path" = "" ]; then
                   path="."
               fi
               fullpath="$path/$1"
               break
           fi
        done
        IFS="$oIFS"
    fi
    if [ "$fullpath" = "" ]; then
        fullpath="$1"
    fi
    # Is the awk/ls magic portable?
    if [ -L "$fullpath" ]; then
        fullpath="`ls -l "$fullpath" | awk '{print $11}'`"
    fi
    dirname $fullpath
}

# Set the home if not already set.
if [ "${APP_PATH}" = "" ]; then
    APP_PATH="`FindPath $0`"
fi

LD_LIBRARY_PATH=.:${APP_PATH}:${LD_LIBRARY_PATH}

export LD_LIBRARY_PATH

# Let's boogie!
if [ -x "${APP_PATH}/$BINARY" ]
then
	cd "${APP_PATH}/"
	exec "./$BINARY" f $*
fi
echo "Couldn't run Porrasturvat ($BINARY)"
exit 1
