# Create an output build directory in the /u1 hardware mount
set PROJ_NAME      = `basename $PWD`
set USER_DIR       = "/u1/$USER"
set USER_BUILD_DIR = "/u1/$USER/build"
set USER_PROJ_DIR  = "/u1/$USER/build/${PROJ_NAME}"
set USER_BIN_DIR   = "/u1/$USER/build/${PROJ_NAME}/bin"
set USER_BIN_RT_DIR   = "/u1/$USER/build/${PROJ_NAME}/bin_rt"
set SOFT_LINK      = "bin"
set SOFT_LINK_RT   = "bin_rt"

if(! -d $USER_DIR) then
	printf "Making %s directory\n" $USER_DIR
	mkdir $USER_DIR
endif

if(! -d $USER_BUILD_DIR ) then
	printf "Making %s directory\n" $USER_BUILD_DIR 
	mkdir $USER_BUILD_DIR 
endif

if(! -d $USER_PROJ_DIR) then
	printf "Making %s directory\n" $USER_PROJ_DIR	
	mkdir $USER_PROJ_DIR
endif

if(! -d $USER_BIN_DIR ) then
	printf "Making %s directory\n" $USER_BIN_DIR 
	mkdir $USER_BIN_DIR 
endif

if(! -d $USER_BIN_RT_DIR ) then
	printf "Making %s directory\n" $USER_BIN_RT_DIR 
	mkdir $USER_BIN_RT_DIR 
endif

#if(! -d $SOFT_LINK_RT ) then
#	printf "Making %s soft-link\n" $SOFT_LINK_RT
#	ln -s $USER_BIN_RT_DIR bin_rt 
#endif
#
#if(! -d $SOFT_LINK ) then
#	printf "Making %s soft-link\n" $SOFT_LINK
#	ln -s $USER_BIN_DIR bin 
#endif

# Base directory
setenv BASE ${PWD}

# QT Base Directory, required for compile
setenv QTDIR   /afs/slac/g/reseng/qt/qt_4.7.4_x64

# QWT Base Directory, uncomment to compile online gui
#setenv QWTDIR  /afs/slac/g/reseng/qt/qwt_6.0_x64

# Root base directory, uncomment to compile root programs
setenv ROOTSYS /afs/slac/g/reseng/root/root_v5.26.00

# Python search path, uncomment to compile python script support
setenv PYTHONPATH ${BASE}/python/lib64/python/

# Setup path
if ($?PATH) then
   setenv PATH ${BASE}/bin:${QTDIR}/bin:${PATH}
else
   setenv PATH ${BASE}/bin:${QTDIR}/bin
endif

# Setup library path
if ($?LD_LIBRARY_PATH) then
   setenv LD_LIBRARY_PATH ${QTDIR}/lib:${LD_LIBRARY_PATH}
else
   setenv LD_LIBRARY_PATH ${QTDIR}/lib
endif

# Optional QWT
if ($?QWTDIR) then
   setenv LD_LIBRARY_PATH ${QWTDIR}/lib:${LD_LIBRARY_PATH}
endif

# Optional root
if ($?ROOTSYS) then
   setenv PATH ${ROOTSYS}/bin:${PATH}
   setenv LD_LIBRARY_PATH ${ROOTSYS}/lib:${LD_LIBRARY_PATH}
endif
