#! /bin/sh
#shell script to launch a specific application on linux.
#Avoid export of LD_LIBRARY_PATH, and append the profile.xml of the application
#At the end you just have to launch the 'ApplicationName-Version.sh'

#Don't modify this file, it will automaticaly be generated by Cmake.

makeAbsolute() {
    case $1 in
        /*)
            # absolute
            echo "$1"
            ;;
        *)
            # relative
            echo `makeAbsolute "$2" "$PWD"`/"$1" | sed 's,/\.$,,'
            ;;
    esac
}

me=/usr
if test -L "$me"; then
    # Try readlink(1)
    readlink=`type readlink 2>/dev/null` || readlink=
    if test -n "$readlink"; then
        # We have readlink(1), so we can use it. Assuming GNU readlink (for -f).
        me=`readlink -nf "$me"`
    else
        # No readlink(1), so let's try ls -l
        me=`ls -l "$me" | sed 's/^.*-> //'`
        base=`dirname "$me"`
        me=`makeAbsolute "$me" "$base"`
    fi
fi
#Find the directories
bindir="$me/bin"
libdir=`cd "$me/lib/x86_64-linux-gnu" ; pwd`
bundledir=`cd "$me/lib/x86_64-linux-gnu/fw4spl"; pwd`

#export LD_LIBRARY_PATH
LD_LIBRARY_PATH=$libdir:${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
export LD_LIBRARY_PATH
#export the path to the fonts (mandatory for Qt)
QT_QPA_FONTDIR=$fontdir
export QT_QPA_FONTDIR
#Use CMAKE Variable of fwlauncher and Profile.xml path
exec "$bindir/fwlauncher-0.1" "$bundledir/VRRender_0-9/profile.xml" "-B" "$bundledir" "--rwd" "$me"

