# this script sets the PS IPP build environment for BASH shell users

if [ -z $PSCONFIG_DIR ]; then
  # PSCONFIG_DIR=/home/eugene/src/panstarrs/ipp/psconfig
  PSCONFDIR=@PSCONFDIR@
fi

if (( $# == 0 )); then
  /bin/csh $PSCONFDIR/psconfig.csh
  return 0
fi

if [[ "$1" == "--help" ]]; then
  echo "USAGE: psconfig (version) : set configuration to specified version"
  return 0
fi

if [[ "$1" == "--list" ]]; then
  /bin/csh $PSCONFDIR/psconfig.csh --list
  return 0
fi

version=$1
psconfigure=`/bin/csh $PSCONFDIR/psconfig.csh --psconfigure $version`
psautogen=`/bin/csh $PSCONFDIR/psconfig.csh --psautogen $version`
psperlbuild=`/bin/csh $PSCONFDIR/psconfig.csh --psperlbuild $version`
alias psconfigure=$psconfigure
alias psautogen=$psautogen
alias psperlbuild=$psperlbuild

# psconfig env variables
export PSCONFDIR=`/bin/csh $PSCONFDIR/psconfig.csh --psconfdir $version`
export PSVERSION=`/bin/csh $PSCONFDIR/psconfig.csh --psversion $version`

# environment variables
export PATH=`/bin/csh $PSCONFDIR/psconfig.csh --path $version`
export ARCH=`/bin/csh $PSCONFDIR/psconfig.csh --arch $version`
export LD_LIBRARY_PATH=`/bin/csh $PSCONFDIR/psconfig.csh --ld_library_path $version`
export PKG_CONFIG_PATH=`/bin/csh $PSCONFDIR/psconfig.csh --pkg_config_path $version`
export ACLOCAL_FLAGS=`/bin/csh $PSCONFDIR/psconfig.csh --aclocal_flags $version`
export PERL5LIB=`/bin/csh $PSCONFDIR/psconfig.csh --perl5lib $version`
