#!/bin/csh
#
# File:  $CDEV/.setup
#
# EPICS users, see lines below containing EPICS
#
   if ( $?CDEV == 0 ) then
	setenv CDEVVERSION 1.7.2

      echo "Setting up CDEV Version $CDEVVERSION"

# to use EPICS, define EPICSLIB or uncomment these lines:   
#      if ( $?EPICSLIB == 0 ) then
#         setup epics
#      endif
   
      setenv OS `uname -s`
      setenv REVISION `uname -r`
      
      switch ($OS)
         case HP-UX:
         setenv LIBDIR `echo $REVISION | awk '{ FS="."; printf("hpux-%s.%s", $2, $3); exit; }'`
         breaksw
         
         case SunOS:
         setenv OS_MAJOR_REV `echo $REVISION | awk '{FS="."; print $1; exit; }'`
	 if ($OS_MAJOR_REV < 4) then
	 	setenv LIBDIR sunos
	 else
	 	setenv LIBDIR solaris
	 endif
         breaksw
      
      	 case Linux:
	 	setenv LIBDIR Linux
	 breaksw
	 
	 case AIX:
	 	setenv LIBDIR `echo uname -v | awk '{FS="."; printf("aix-%s.%s", $REVISION, $1); exit; }'`
	 breaksw
	 
	 default:
	 	setenv LIBDIR $OS
	 breaksw
 
      endsw
      
         
      setenv CDEV              `pwd`
      setenv CDEVLIB           $CDEV/lib/$LIBDIR
      setenv CDEVSHOBJ         $CDEVLIB
      setenv CDEVBIN           $CDEV/bin/$LIBDIR
      setenv CDEVINCLUDE       $CDEV/include
      setenv CDEVDDL           $CDEV/ddl/master.bdd
      setenv CDEV_ACCOUNT_FILE $CDEV/ddl/cdevAccount.txt      

      setenv PATH ${PATH}:${CDEVBIN}

# to use EPICS, uncomment these 2 lines and comment out next 2   
      setenv EPICS /devl/epics
      setenv EPICSLIB /devl/epics/base/lib/Linux
      setenv SHLIB_PATH ${CDEVSHOBJ}:${CDEVLIB}:${EPICSLIB}
      setenv LD_LIBRARY_PATH ${CDEVSHOBJ}:${CDEVLIB}:${EPICSLIB}
#      setenv SHLIB_PATH ${CDEVSHOBJ}:${CDEVLIB}
#      setenv LD_LIBRARY_PATH ${CDEVSHOBJ}:${CDEVLIB}
     
      unsetenv LIBDIR
      unsetenv OS_MAJOR_REV
      unsetenv OS
      unsetenv REVISION

#---- Automatic way to recreate the important symbolik links---------------

set R=`cat /etc/redhat-release | awk 'BEGIN{FS=" "};{print $5}'`
set MAKEFILE1="Makefile.linux-redhat$R-x86"
set DIR1="include/makeinclude/"
set DIR2="extensions/cdevGenericServer/include/makeinclude/"

if ( -e $DIR1$MAKEFILE1 ) then
        echo "Creating the Symbolic link ${DIR1}Makefile.linux -> $MAKEFILE1"
        rm -f ${DIR1}Makefile.linux
        ln -s $MAKEFILE1 ${DIR1}Makefile.linux
else
        echo "file $MAKEFILE1 does not exist in $DIR1"
endif

if ( -e $DIR2$MAKEFILE1 ) then
        echo "Creating the Symbolic link ${DIR2}Makefile.linux -> $MAKEFILE1"
        rm -f ${DIR2}Makefile.linux
        ln -s $MAKEFILE1 ${DIR2}Makefile.linux
else
        echo "file $MAKEFILE1 does not exist in $DIR2"
endif       
#-----------------------------------------------------------------------------
   endif


