#!/bin/sh
#
# Wrapper script to start a Winelib application once it is installed
#
# Copyright (C) 2002 Alexandre Julliard

# determine the app Winelib library name
appname=`basename "$0" .exe`.exe

#allow Wine to load Winelib application from the current directory
export WINEDLLPATH=$WINEDLLPATH:.

# first try explicit WINELOADER
if [ -x "$WINELOADER" ]; then exec "$WINELOADER" "$appname" "$@"; fi

# then default bin directory
if [ -x "/usr/local/bin/wine" ]; then exec "/usr/local/bin/wine" "$appname" "$@"; fi

# now try the directory containing $0
appdir=""
case "$0" in
  */*)
    # $0 contains a path, use it
    appdir=`dirname "$0"`
    ;;
  *)
    # no directory in $0, search in PATH
    saved_ifs=$IFS
    IFS=:
    for d in $PATH
    do
      IFS=$saved_ifs
      if [ -x "$d/$0" ]; then appdir="$d"; break; fi
    done
    ;;
esac
if [ -x "$appdir/wine" ]; then exec "$appdir/wine" "$appname" "$@"; fi

# finally look in PATH
exec wine "$appname" "$@"
