#!/bin/sh
# -*-shell-script-*-
# coot wrapper script
# Copyright 2004, 2005, 2006 Paul Emsley, University of York

#
current_exe_dir=`dirname $0`
echo current_exe_dir is $current_exe_dir

if [ $current_exe_dir = . ] ; then
  COOT_PREFIX=`dirname $PWD`
else
  COOT_PREFIX=`dirname "$current_exe_dir"`
fi

# echo COOT_PREFIX is $COOT_PREFIX


# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# If the COOT_PREFIX is correct, then these should not need modification
# i.e.  nothing below here need be changed.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
#
prefix=$COOT_PREFIX
PATH=$COOT_PREFIX/bin:$PATH

SYMINFO=$COOT_PREFIX/share/coot/syminfo.lib
COOT_SCHEME_DIR=$COOT_PREFIX/share/coot/scheme
# COOT_REFMAC_LIB_DIR=$COOT_PREFIX/share/coot/lib
COOT_STANDARD_RESIDUES=$COOT_PREFIX/share/coot/standard-residues.pdb
COOT_PIXMAPS_DIR=$COOT_PREFIX/share/coot/pixmaps
COOT_DATA_DIR=$COOT_PREFIX/share/coot
COOT_RESOURCES_FILE=$COOT_PREFIX/share/coot/cootrc
COOT_REF_STRUCTS=$COOT_PREFIX/share/coot/reference-structures
PYTHONPATH=$COOT_PREFIX/share/coot/python
if [ -z "$PYTHONPATH" ] ; then
    PYTHONPATH=$COOT_PREFIX/share/coot/python
else
    PYTHONPATH=${PYTHONPATH}:$COOT_PREFIX/share/coot/python
fi

GUILE_LOAD_PATH=\
$COOT_PREFIX/share/guile/1.6:$COOT_PREFIX/share/guile:$COOT_PREFIX/share/guile/gtk-1.2:$COOT_PREFIX/share/guile/gui:$COOT_PREFIX/share/guile/www:$COOT_PREFIX/share/guile/site
GUILE_WARN_DEPRECATED=no

if [ -n "$LOCAL_GUILE_LOAD_PATH_EXTRAS" ] ; then
    GUILE_LOAD_PATH=${LOCAL_GUILE_LOAD_PATH_EXTRAS}:$GUILE_LOAD_PATH
fi

# echo GUILE_LOAD_PATH is now $GUILE_LOAD_PATH

systype=`uname`

if [ $systype = Linux ] ; then
   if [ -z "$LD_LIBRARY_PATH" ] ;  then
       LD_LIBRARY_PATH=$COOT_PREFIX/lib
   else
       LD_LIBRARY_PATH=$COOT_PREFIX/lib:${LD_LIBRARY_PATH}
   fi
fi

# some (Intel, I supose) Mac users may need to change
# DYLD_LIBRARY_PATH to DYLD_FALLBACK_LIBRARY_PATH, if running into
#  problems with Framwork jpeg libraries (don't forget the export
# at the end too).
#
if [ $systype = Darwin ] ; then
   if [ -z "$DYLD_LIBRARY_PATH" ] ;  then
       DYLD_LIBRARY_PATH=$COOT_PREFIX/lib
   else
       DYLD_LIBRARY_PATH=$COOT_PREFIX/lib:${DYLD_LIBRARY_PATH}
   fi
fi

export SYMINFO
export COOT_PREFIX
export COOT_STANDARD_RESIDUES
# export COOT_REFMAC_LIB_DIR
export PYTHONPATH
export COOT_SCHEME_DIR
export COOT_REF_STRUCTS
export COOT_RESOURCES_FILE
export COOT_PIXMAPS_DIR
export COOT_DATA_DIR
export GUILE_LOAD_PATH
export DYLD_LIBRARY_PATH
export LD_LIBRARY_PATH
export LD_LIBRARYN32_PATH

$COOT_PREFIX/libexec/coot-findwaters-bin $*
