#!/bin/tcsh

# Override the sitewide OSNAME to one that includes the architecture
setenv OS `/bin/uname -s`
setenv ARCH `/bin/uname -p`
setenv OSNAME ${OS}-${ARCH}

# MySQL
if ( ! $?LD_LIBRARY_PATH ) then
	setenv LD_LIBRARY_PATH /apps/mysql/lib/mysql
else
	setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/apps/mysql/lib/mysql
endif

# Group disk (it is mounted different on clons!)
setenv GROUPDISK /group
if ( ! -e ${GROUPDISK} ) then
setenv GROUPDISK /u/group
endif

# JANA
setenv JANA_HOME ${GROUPDISK}/12gev_phys/builds/PRODUCTION/${OSNAME}
setenv PATH ${PATH}:${JANA_HOME}/bin
setenv JANA_PLUGIN_PATH ${JANA_HOME}/lib

# Hall-D
setenv HALLD_HOME ${GROUPDISK}/halld/Software/builds/LATEST
setenv PATH ${PATH}:${HALLD_HOME}/bin:${HALLD_HOME}/bin/${OSNAME}
setenv JANA_PLUGIN_PATH ${HALLD_HOME}/lib/${OSNAME}:${JANA_PLUGIN_PATH}
setenv JAVAROOT /apps
setenv HALLD_EXTERNALPACKAGES ${GROUPDISK}/halld/Software/ExternalPackages
setenv XERCESCROOT ${HALLD_EXTERNALPACKAGES}/xerces-c-src_2_7_0.${OSNAME}
setenv XERCES_INCLUDE ${HALLD_EXTERNALPACKAGES}/include
setenv XERCES_LIB ${HALLD_EXTERNALPACKAGES}/lib/${OSNAME}
setenv XERCES_JAR ${XERCESCROOT}/tools/jars
setenv CLASSPATH ${XERCES_JAR}/xalan.jar:${XERCES_JAR}/xerces.jar
setenv PERL5LIB ${HALLD_EXTERNALPACKAGES}/perl_mods/lib/site_perl/5.8.2/i686-linux
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:${XERCES_LIB}
setenv PATH ${HALLD_EXTERNALPACKAGES}/bin:${HALLD_EXTERNALPACKAGES}/bin/${OSNAME}:${PATH}

setenv JANA_CALIB_URL file:///group/halld/calib
setenv JANA_GEOMETRY_URL xmlfile://${HALLD_HOME}/src/programs/Simulation/hdds/main_HDDS.xml

setenv HALLD_MY ${HOME}/HallD
setenv PATH ${HALLD_MY}/bin/${OSNAME}:${PATH}

#setenv MCFAST_DIR ${HALLD_EXTERNALPACKAGES}/mcfast_v5_2_Linux+2.4+GCC3_2_1
#setenv STDHEP_DIR ${HALLD_EXTERNALPACKAGES}/stdhep_v5_01_Linux+2.4
#setenv MCFIO_DIR ${MCFAST_DIR}/mcfio
#setenv QQ_DIR ${HALLD_EXTERNALPACKAGES}/qq_v9_2b_Linux+2.4


# ROOT
if ( -e /site/bin/use && -e /apps/bin/perl) then
  use root
endif


# CERNLIB
if ( -e /site/bin/setup ) then
  setup cernlib
#if ( $OSNAME == 'Linux-i686' ) then
#	setenv CERN /apps/cernlib/i386_rhel3
#	setenv CERN_LEVEL 2003
#else if  ( $OSNAME == 'SunOS-sparc' ) then
#	setenv CERN /site/cernlib/sun4_solaris8
#	setenv CERN_LEVEL 2001
else
	setenv CERN /usr/local/cern
	setenv CERN_LEVEL PRO
endif

setenv CERN_ROOT ${CERN}/${CERN_LEVEL}
setenv PATH ${CERN_ROOT}/bin:$PATH

rehash
