#! /bin/sh
##
##---------------------------------------------------------------------------##
##
## PySol -- a Python Solitaire Game Collection
##
## Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
## Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
## Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
## Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; see the file COPYING.
## If not, write to the Free Software Foundation, Inc.,
## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
##
## Markus F.X.J. Oberhumer <markus@oberhumer.com>
## http://www.oberhumer.com/pysol
## http://www.oberhumer.com
##
##---------------------------------------------------------------------------##

###
###  This is just a convenience loader for the byte-compiled version.
###  The full source code can be obtained from the PySol home page.
###

# The HP-UX ksh and POSIX shell print the target directory to stdout
# if CDPATH is set.
if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
  as_unset=unset
else
  as_unset=false
fi
$as_unset CDPATH || test "X${CDPATH+set}" != Xset || { CDPATH=:; export CDPATH; }

# the next lines will get substituted by "make install"
PYTHON="/usr/local/bin/python2.5"
prefix='/usr/local'
dir='/usr/local/share/pysol'

# default value for PYTHON unless substituted
if echo "$PYTHON" | egrep 'PYTHON@$' > /dev/null; then
  PYTHON="python"
fi

# get Python version
PYVER=`"$PYTHON" -c '
import sys
if hasattr(sys, "version_info"):
    print "%d%d" % sys.version_info[:2]
else:
    print "%s%s" % (sys.version[0], sys.version[2])
'`

# get directory of this script
bindir=`echo "$0" | sed -e 's|[^/][^/]*$||'`
bindir=`cd "$bindir" && pwd`

f="src/pysol.py"

# try script directory unless installed
if test ! -f "$dir/$f"; then
  dir="$bindir/data"
fi

# try current directory unless installed
if test ! -f "$dir/$f"; then
  dir="./data"
fi

# final check
if test ! -f "$dir/$f"; then
  echo "$0: could not find the file '$f' !"
  exit 1
fi

# start the bytecode
exec "$PYTHON" "$dir/$f" "--prefix=$prefix" "--pkgdatadir=$dir" "--bindir=$bindir" ${1+"$@"}

echo "$0: running $PYTHON failed !"
exit 1
