#!/bin/csh -f
#@(#)purifyplus_setup.csh $Revision: 1.25 $  $Date: 03/16/2009 $
#@(#)(C) Copyright IBM Corporation. 2001, 2009. All Rights Reserved.
#------------------------------------------------------------------------
# Purpose: Rational PurifyPlus for UNIX setup script.
#
# Note: Use this command to invoke this from your .cshrc file:
#       source <location>/purifyplus_setup.csh
#
# This file is converted from a template that comes with PurifyPlus.
# Items with %tags% are converted into specific locations or versions
# that are known at installation time.
#
# All variables beginning with _ are local and will be unset at
# the end of this script.
#------------------------------------------------------------------------
if (! $?USER) then
    setenv USER $LOGNAME
else
    setenv USER $USER
endif

set _RationalDir       = /afs/.cs/s/purifyplus-7.0/sun4x_58
set _PurifyPlus        = PurifyPlus
set _PurifyPlusVer     = 7.0.0.0-014
set _LmLicense         = 27001@frank.cs.wisc.edu:27001@frank:27001@moon-unit:27001@dweezle:27001@frank.cs.wisc.edu,27001@moon-unit.cs.wisc.edu,27001@dweezle.cs.wisc.edu
set _PurifyAixVer      = "not-installed"
set _QuantifyAixVer    = "not-installed"
set _PurecovAixVer     = "not-installed"
set _PurifyHpVer       = "not-installed"
set _QuantifyHpVer     = "not-installed"
set _PurecovHpVer      = "not-installed"
set _PurifyHpiaVer     = "not-installed"
set _QuantifyHpiaVer   = "not-installed"
set _PurecovHpiaVer    = "not-installed"
set _PurifyLnxVer      = "not-installed"
set _QuantifyLnxVer    = "not-installed"
set _PurecovLnxVer     = "not-installed"
set _PurifySolVer      = "7.0.0.0-014"
set _QuantifySolVer    = "7.0.0.0-014"
set _PurecovSolVer     = "7.0.0.0-014"
set _PurifySolx64Ver   = "not-installed"
set _QuantifySolx64Ver = "not-installed"
set _PurecovSolx64Ver  = "not-installed"
set _PurifySg32Ver     = "not-installed"
set _RelDir            = $_RationalDir/releases
set _Config            = $_RationalDir/config
set _PurifyPlus        = $_RelDir/$_PurifyPlus.$_PurifyPlusVer

switch("`uname -sr`")
case AIX*:
    set _Arch=rs6k_aix
    set _OS="AIX"
    set _Purify=$_RelDir/purify.aix.$_PurifyAixVer
    set _Quantify=$_RelDir/quantify.aix.$_QuantifyAixVer
    set _PureCov=$_RelDir/purecov.aix.$_PurecovAixVer
    breaksw

case HP-UX*B.10.20:
case HP-UX*B.11.*:
    switch("`uname -m`")
    case ia64:
        set _Arch=hpia
        set _OS="HP-UX IA64"
        set _Purify=$_RelDir/purify.hpia.$_PurifyHpiaVer
        set _Quantify=$_RelDir/quantify.hpia.$_QuantifyHpiaVer
        set _PureCov=$_RelDir/purecov.hpia.$_PurecovHpiaVer
        breaksw
    default:
        set _Arch=hppa_hpux
        set _OS="HP-UX PA-RISC"
        set _SysA=hp
        set _SysB=hp64
        # On B.11.xx, check if this machine is running a 64-bit kernel.
        switch("`uname -r`")
        case B.11.*:
            getconf KERNEL_BITS | grep 64 >&! /dev/null
            if ($status == 0) then
                # Default to 64 bit.
                set _SysA=hp64
                set _SysB=hp
            endif
        endsw
        set _Purify=$_RelDir/purify.$_SysA.$_PurifyHpVer
        if (! -x $_Purify/purify) then
            set _Purify=$_RelDir/purify.$_SysB.$_PurifyHpVer
        endif
        set _Quantify=$_RelDir/quantify.$_SysA.$_QuantifyHpVer
        if (! -x $_Quantify/quantify) then
            set _Quantify=$_RelDir/quantify.$_SysB.$_QuantifyHpVer
        endif
        set _PureCov=$_RelDir/purecov.$_SysA.$_PurecovHpVer
        if (! -x $_PureCov/purecov) then
            set _PureCov=$_RelDir/purecov.$_SysB.$_PurecovHpVer
        endif
    endsw
    breaksw

case Linux*:
    switch("`uname -m`")
    case *86:
    case x86*:
        set _Arch=i386_linux2
        set _OS="Linux"
        set _Purify=$_RelDir/purify.$_Arch.$_PurifyLnxVer
        set _Quantify=$_RelDir/quantify.$_Arch.$_QuantifyLnxVer
        set _PureCov=$_RelDir/purecov.$_Arch.$_PurecovLnxVer
        breaksw
    default:
        unset _Arch
    endsw
    breaksw

case SunOS*5.*:
    switch("`uname -p`")
    case sparc:
        set _Arch=sun4_solaris2
        set _OS="Solaris"
        set _Purify=$_RelDir/purify.sol.$_PurifySolVer
        set _Quantify=$_RelDir/quantify.sol.$_QuantifySolVer
        set _PureCov=$_RelDir/purecov.sol.$_PurecovSolVer
        breaksw
    case i386:
        set _Arch=solaris_x64
        set _OS="Solaris x64"
        set _Purify=$_RelDir/purify.solaris_x64.$_PurifySolx64Ver
        set _Quantify=$_RelDir/quantify.solaris_x64.$_QuantifySolx64Ver
        set _PureCov=$_RelDir/purecov.solaris_x64.$_PurecovSolx64Ver
        breaksw
    default:
        unset _Arch
    endsw
    breaksw

case IRIX*6.*:
    set _Arch=mips_irix_n32
    set _OS="IRIX"
    set _Purify=$_RelDir/purify.sg32.$_PurifySg32Ver
    set _Quantify=NotAvailableOnIrix
    set _PureCov=NotAvailableOnIrix
    breaksw

default:
    unset _Arch
endsw

if ($?_Arch) then

    setenv RSU_LICENSE_MAP $_Config/PurifyPlus_License_Map

    if ( ! $?LM_LICENSE_FILE ) then
        setenv LM_LICENSE_FILE $_LmLicense
    else
        switch("$LM_LICENSE_FILE")
        case *${_LmLicense}*:
            breaksw
        default:
            setenv LM_LICENSE_FILE "${_LmLicense}:$LM_LICENSE_FILE"
        endsw
    endif

    if ( -f $_Config/templates2.ini ) then
       setenv RSU_TEMPLATE2_INI $_Config/templates2.ini
    else if ( -f $_PurifyPlus/extras/install_data/templates2.ini ) then
       setenv RSU_TEMPLATE2_INI $_PurifyPlus/extras/install_data/templates2.ini
    endif

    if ( -d $_PurifyPlus/$_Arch/bin ) then
        set _PurifyPlusInst=true
        switch ("$PATH")
        case *$_PurifyPlus/$_Arch/bin*:
            breaksw
        default:
            set path = ( $_PurifyPlus/$_Arch/bin $path )
            if ( -x $_PurifyPlus/$_Arch/bin/purifyplus_help ) \
                echo "purifyplus_help   On-line documentation main page"
            if ( -x $_PurifyPlus/$_Arch/bin/purify ) \
                echo "purify     added to path"
            if ( -x $_PurifyPlus/$_Arch/bin/purecov ) \
                echo "purecov    added to path"
            if ( -x $_PurifyPlus/$_Arch/bin/quantify ) \
                echo "quantify   added to path"
        endsw
    else
        if ( -d $_Purify ) then
            set _PurifyPlusInst=true
            switch("$PATH")
            case *$_Purify*:
                breaksw
            default:
                set path = ( $_Purify $path )
                echo "purify     added to path"
            endsw
        endif

        if ( -d $_Quantify ) then
            set _PurifyPlusInst=true
            switch("$PATH")
            case *$_Quantify*:
                breaksw
            default:
                set path = ( $_Quantify $path )
                echo "quantify   added to path"
            endsw
        endif

        if ( -d $_PureCov ) then
            set _PurifyPlusInst=true
            switch("$PATH")
            case *$_PureCov*:
                breaksw
            default:
                set path = ( $_PureCov $path )
                echo "purecov    added to path"
            endsw
        endif
    endif

    if ( ! $?MANPATH ) then
        if ( -x /usr/bin/manpath ) then
            setenv MANPATH `/usr/bin/manpath`
        else
            setenv MANPATH /usr/man
        endif
    endif

    if ( -d $_PureCov/man ) then
        switch("$MANPATH")
        case *$_PureCov/man*:
            breaksw
        default:
            setenv MANPATH "$_PureCov/man:${MANPATH}"
        endsw
    endif

    if ( -d $_Purify/man ) then
        switch("$MANPATH")
        case *$_Purify/man*:
            breaksw
        default:
            setenv MANPATH "$_Purify/man:${MANPATH}"
        endsw
    endif

    if ( -d $_Quantify/man ) then
        switch("$MANPATH")
        case *$_Quantify/man*:
            breaksw
        default:
            setenv MANPATH "$_Quantify/man:${MANPATH}"
        endsw
    endif

    if ( $?_PurifyPlusInst ) then
        rehash
    else
        echo "Rational PurifyPlus for UNIX $_PurifyPlusVer"
        echo "not installed on the $_OS platform."
    endif
else
    echo "Rational PurifyPlus for UNIX $_PurifyPlusVer"
    echo "not supported on this platform:"
    echo "  `uname -a`"
endif

# Unset all of the local vars (_ prefix) used by this setup script:
unset _RationalDir _Arch _OS _Sys _SysA _SysB
unset _LmLicense _Config _RelDir _PurifyPlus _PurifyPlusInst
unset _Purify           _Quantify           _PureCov
unset _PurifyAixVer     _QuantifyAixVer     _PurecovAixVer
unset _PurifyHpVer      _QuantifyHpVer      _PurecovHpVer
unset _PurifyHpiaVer    _QuantifyHpiaVer    _PurecovHpiaVer
unset _PurifyLnxVer     _QuantifyLnxVer     _PurecovLnxVer
unset _PurifySolVer     _QuantifySolVer     _PurecovSolVer
unset _PurifySolx64Ver  _QuantifySolx64Ver  _PurecovSolx64Ver
unset _PurifySg32Ver

