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

if [ -z $PSCONFIG_DIR ]; then
  PSCONFIG_DIR=/home/kiawe/eugene/src.alala/panstarrs/ipp/psconfig
fi

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

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

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

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

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