
extdesc="the Xpdf-Tools Extension"

full_setup=`pwd`/${BASH_SOURCE}
fulldir=${full_setup%/*}
fulldir=${fulldir%/.}

if test -z $GSDLOS ; then
  GSDLOS=`uname -s | tr '[A-Z]' '[a-z]'`
  # check for running bash under Cygwin
  if test "`echo $GSDLOS | sed 's/cygwin//'`" != "$GSDLOS" ;
  then
    GSDLOS=windows
  fi
  # check for running bash under MinGW/MSys
  if test "`echo $GSDLOS | sed 's/mingw//'`" != "$GSDLOS" ;
  then
    GSDLOS=windows
  fi
  echo "GSDLOS was not set.  Setting it to '$GSDLOS'"
  export GSDLOS
fi
	

if [ "x$GEXT_XPDFTOOLS" = "x" ] ; then
  export GEXT_XPDFTOOLS=`pwd`
  export GEXTXPDFTOOLS_INSTALLED=$GEXT_XPDFTOOLS/$GSDLOS

  if [ -d "$GEXTXPDFTOOLS_INSTALLED/bin/script" ] ; then
    export PATH=$GEXTXPDFTOOLS_INSTALLED/bin/script:$PATH
  fi

  if [ -d "$GEXTXPDFTOOLS_INSTALLED/bin" ] ; then
    export PATH=$GEXTXPDFTOOLS_INSTALLED/bin:$PATH
  fi

  if [ -d "$GEXTXPDFTOOLS_INSTALLED/lib" ] ; then
    if [ "$GSDLOS" = "linux" ] ; then
      export LD_LIBRARY_PATH=$GEXTXPDFTOOLS_INSTALLED/lib:$LD_LIBRARY_PATH
    elif [ "$GSDLOS" = "darwin" ] ; then
      export DYLD_LIBRARY_PATH=$GEXTXPDFTOOLS_INSTALLED/lib:$DYLD_LIBRARY_PATH
    fi
  fi

  extdir=${GEXT_XPDFTOOLS##*/}

  if [ "x$GSDL3EXTS" = "x" ] ; then
    export GSDL3EXTS=$extdir
  else 
    export GSDL3EXTS=$GSDL3EXTS:$extdir
  fi


  echo "+Your environment is now setup for $extdesc"
else
  echo "+Your environment is already setup for $extdesc"
fi
