#!/bin/csh
# utility script for setting environment for Jpp software.

# Set environment variables for Jpp software

if ($?prompt != 0) then
  echo "Setting environment variables for Jpp software."
endif

if ( ! -r setenv.csh ) then
  echo "ERROR: This script must be used from the Jpp directory."
  exit

endif


# ROOT

if ($?NODE != 0) then
    
    setenv ROOT_VERSION v5.34.14

    if ( `echo $NODE | cut -c1-2` == cc ) then 
	source /usr/local/root/$ROOT_VERSION/bin/thisroot.csh /usr/local/root/$ROOT_VERSION/
    endif

endif


setenv SYSTEM    `uname -s`
setenv MACHINE   `uname -m`
setenv PROCESSOR `uname -p`

setenv ANTRS_DAQ_ROOT `pwd`/externals/antares-daq/
setenv ANTRS_OUT      $ANTRS_DAQ_ROOT/out/$SYSTEM
setenv ANTRS_BIN      $ANTRS_OUT/bin
setenv ANTRS_LIB      $ANTRS_OUT/lib
setenv ANTRS_INCLUDE  $ANTRS_DAQ_ROOT/include

setenv JPP_DIR `pwd`
setenv JPP_BIN  $JPP_DIR/out/$SYSTEM/bin/
setenv JPP_LIB  $JPP_DIR/out/$SYSTEM/lib/
setenv JPP_DOC  $JPP_DIR/doc/
setenv JPP_INC  $JPP_DIR/software/
setenv JPP_DATA $JPP_DIR/data/

setenv CHSM_DIR $JPP_DIR/externals/chsm

foreach DIR ($JPP_BIN $ANTRS_BIN $ROOTSYS/bin);
    if ( `echo ${PATH} | egrep ${DIR} > /dev/null` == "" ) then
	setenv PATH "${DIR}:${PATH}"
    endif
end


if ( ! $?LD_LIBRARY_PATH ) then 
    setenv LD_LIBRARY_PATH
endif

foreach DIR ($JPP_LIB $ANTRS_LIB $ROOTSYS/lib);
    if ( `echo ${LD_LIBRARY_PATH} | egrep ${DIR}` == "" ) then
	setenv LD_LIBRARY_PATH ${DIR}:${LD_LIBRARY_PATH}
    endif
end
