#!/bin/csh -f
#
# NAME:
#       setup_ana_exe
# PURPOSE:
#       to set up an alias for the ANA executable suitable for the operating
#       system that's being used
# HISTORY:
#       Created 27 August 1998 by Louis Strous
#	Modified 10/18/07 for new ana versions (ZAF)
# Get operating system name (or "unknown")
# Need both operating system and processor type to determine which
# version of ana to run
set OSN = `(uname -s || echo unknown)`
set OSP = `(uname -p)`
set OSM = `(uname -m)`

# Get directory location for ANA executable. ANA_DIR/ is the default.
# Alternates may be defined but changes to the path are reflected below
set ANA_EXE_MAIN = $ANA_DIR/exe/
set ANA_EXE_ALT1 = /net/solserv/data1/data13/trace_egse_sw/ana/exe/
set ANA_EXE_ALT2 = /net/shine/Users/shine/ana/
set ANA_EXE_ALT3 = $ANA_DIR/


# Treat special cases
switch ($OSN)
 # ANA is (currently) not available in IRIX 64 bits -- use 32 instead
 # 10/07- 64 bit IRIX should be available so put in another case - ZAF
 case IRIX:
    set OS = IRIX
    breaksw
 case IRIX64:
    set OS = IRIX
    breaksw
 # DEC OSF
 case OSF1:
    set OS = OSF1
    breaksw
 # SUN machines, two cases
 # osp=sparc
 case SunOS:
    set OS = SunOS
    breaksw
 case Solaris:
    set OS = SUNOS
    breaksw
# Linux machines
 case Linux:
    set OS = Linux
    breaksw
# two processors for Mac OS and 32 and 64 bit
# 9/13/2013 assume 64 bit now
 case Darwin:
    echo ${0}: got Darwin
    switch ($OSP)
      case i386:
        echo ${0}: got ${OSP}
        switch ($OSM)
	  case x86_64:
            echo ${0}: got ${OSM}
	    #set to intel64 when exe file available
            set OS = intel
            breaksw
          case i386:
            echo ${0}: got ${OSM}
	    #set to intel32 when exe file available
            set OS = intel
            breaksw
      case powerpc:
        set OS = g5
        breaksw
    endsw
    breaksw
 case unknown:
#    echo ${0}: Could not determine your operating system -- assuming Irix.
    set OS = IRIX
    breaksw
endsw
echo ${0}: OS is  ${OS}
# there are a few combinations of filenames and paths for ana executables
# if sought executable exists: set up appropriate alias
foreach ANA_EXE_DIR ($ANA_EXE_MAIN $ANA_EXE_ALT1 $ANA_EXE_ALT2 $ANA_EXE_ALT3)
if (-x ${ANA_EXE_DIR}${OS}-ana) then
  alias ana ${ANA_EXE_DIR}${OS}-ana
else if (-x ${ANA_EXE_DIR}ana-${OS}) then
  alias ana ${ANA_EXE_DIR}ana-${OS}
else if (-x ${ANA_EXE_DIR}${OS}_ana) then
  alias ana ${ANA_EXE_DIR}${OS}_ana
else if (-x ${ANA_EXE_DIR}ana_${OS}) then
  alias ana ${ANA_EXE_DIR}ana_${OS}
endif
end
