#!/bin/csh -f
#
#      $Id: INSTALL,v 1.20 2003-05-16 14:53:12 haley Exp $
#
#########################################################################
#                                                                       #
#              Copyright (C)  1992                                      #
#        University Corporation for Atmospheric Research                #
#              All Rights Reserved                                      #
#                                                                       #
#########################################################################
#
#   File:       INSTALL
#
#   Author:     John Clyne
#           National Center for Atmospheric Research
#           PO 3000, Boulder, Colorado
#
#   Date:       Tue Sep 29 08:31:24 MDT 1992
#
#   Description:    Present the NCAR Graphics installation menu
#
#   Usage:      INSTALL
#
#   Environment:    
#           LOCALDIR (exported)     path to install scripts. 
#           VERSION (exported)  NCAR Graphics version number
#
#   Files:      $LOCALDIR/var/version   contains version number
#
#
#   Options:
#
#

#
# get the dir name where INSTALL lives
#
set dir = `expr \( x"$0" : x'\(/\)$' \) \| \( x"$0" : x'\(.*\)/[^/]*$' \) \| .`
if ($status != 0) then
    echo "$0 : Can't find working directory, <expr> failed" > /dev/tty
    exit 1
endif

setenv LOCALDIR "$dir"

setenv SYSTEM `$LOCALDIR/sys_type`
setenv SYSTEM_TO_INSTALL $SYSTEM

if ($status != 0) then
        exit 1
endif

setenv VERSION `cat $LOCALDIR/var/version.$SYSTEM`

clear
cat <<EOF


                 NCAR Graphics Unix Version $VERSION
                     Copyright (C) 1987-2003
          University Corporation for Atmospheric Research
     The use of this Software is governed by a License Agreement.


EOF

echo "    Do you want to install NCAR Graphics on a system different than"
echo -n "    the type of system you are running this INSTALL script on [y/n] (n) ? "
set answer =  $<
if ("$answer" == "y") then
  setenv SYSTEM_TO_INSTALL `$LOCALDIR/sys_type -d`
  if ($status == 2) then
    exit 0
  endif
  if ($status != 0) then
      $LOCALDIR/pause
  endif
endif

if ("$SYSTEM_TO_INSTALL" == "IRIX_IP") then
sgimenu:
    clear
cat <<EOF


                 NCAR Graphics Unix Version $VERSION
                     Copyright (C) 1987-2003
          University Corporation for Atmospheric Research
     The use of this Software is governed by a License Agreement.


      I see you are either running on a Silicon Graphics (SGI) system
      or have selected to install binaries for an SGI.
  
      On some SGI systems, three different options are supported for
      building libraries and binaries. These options are '-n32', '-64',
      and '-32'.

      Please select which set of SGI binaries you want to install:

        1.  'n32' binaries
        2.   '64' binaries
        3.   '32' binaries (not available on NCAR Graphics 4.1.1 CD-ROM)
        4.   Help

        0.  Exit

EOF
    echo -n "    Select: "
    set answer =  $<
    switch ("$answer")

    case "1":
      setenv SYSTEM_TO_INSTALL IRIX_n32_IP
      breaksw

    case "2":
      setenv SYSTEM_TO_INSTALL IRIX_64_IP
      breaksw

    case "3":
      setenv SYSTEM_TO_INSTALL IRIX_32_IP
      breaksw

    case "4":

        clear
        cat <<EOF

    If you have an older SGI system, like an Indigo, then you should
    go with the "-32" option since this is the only one compatible with
    older SGIs. Please note that the "-32" binaries are not available on
    the NCAR Graphics $VERSION CD-ROM.

    If you have a newer SGI and are not sure which option to choose, 
    then either check with your system administrator, or see the SGI
    man page for "cc".
EOF
        $LOCALDIR/pause
        goto sgimenu
        breaksw

    case "0":
        exit 0
        breaksw

    default
        echo "Invalid option <$answer>"
        $LOCALDIR/pause
        goto sgimenu
    endsw
endif

if ("$SYSTEM_TO_INSTALL" == "AIX_RS6000") then
ibmmenu:
    clear
cat <<EOF


                 NCAR Graphics Unix Version $VERSION
                     Copyright (C) 1987-2002
          University Corporation for Atmospheric Research
     The use of this Software is governed by a License Agreement.


      I see you are either running on an IBM RS6000 system
      or have selected to install binaries for an IBM RS6000.
  
      On some IBM systems, two options are supported for building
      libraries and binaries: '-q32' and '-q64'.

      Please select which set of SGI binaries you want to install:

        1.  'q32' binaries
        2.  'q64' binaries
        3.   Help

        0.  Exit

EOF
    echo -n "    Select: "
    set answer =  $<
    switch ("$answer")

    case "1":
      setenv SYSTEM_TO_INSTALL AIX_32_RS6000
      breaksw

    case "2":
      setenv SYSTEM_TO_INSTALL AIX_64_RS6000
      breaksw

    case "3":

        clear
        cat <<EOF

    If you have an older IBM system, then you should go with the "-q32"
    option.

    If you have a newer IBM and are not sure which option to choose, 
    then either check with your system administrator, or see the IBM
    man page for "cc".
EOF
        $LOCALDIR/pause
        goto ibmmenu
        breaksw

    case "0":
        exit 0
        breaksw

    default
        echo "Invalid option <$answer>"
        $LOCALDIR/pause
        goto ibmmenu
    endsw
endif

#
# Now onto main menu.
#
while (1) 
    clear
cat <<EOF


                 NCAR Graphics Unix Version $VERSION
                     Copyright (C) 1987-2003
          University Corporation for Atmospheric Research
     The use of this Software is governed by a License Agreement.



        1.  Ordering information
        2.  Install software for a(n) $SYSTEM_TO_INSTALL system
        3.  Remove installed software
        4.  Help

        0.  Exit

EOF

    echo -n "    Select: "
    set answer =  $<
    switch ("$answer")
    case "1":
        clear
        cat <<EOF



    To order NCAR Graphics or request further information please call
    or write NCAR Graphics Information:

        University Corporation for Atmospheric Research
        SCD/NCAR Graphics Orders
        P.O. Box 3000
        Boulder, CO 80307-3000 (USA)

        Telephone:  (303) 497-1201
        Telex:      989764
        FAX:        (303) 497-1814
        email:      ncarginf@ncar.ucar.edu
EOF
        $LOCALDIR/pause
        
    
        breaksw

    case "2":
        $LOCALDIR/install_soft
        if ($status != 0) then
            $LOCALDIR/pause
        endif
        breaksw

    case "3":
        $LOCALDIR/remove_soft
        if ($status != 0) then
            $LOCALDIR/pause
        endif
        breaksw

    case "4":

        clear
        cat <<EOF


    This is the main menu for the NCAR Graphics software installation
    program. From this menu you may choose to: 

        1. Get information on ordering NCAR Graphics.

        2. Install NCAR Graphics software.

        3. Remove previously installed versions of NCAR Graphics.

        4. Print this help message.

        0. Exit the INSTALL program.
EOF
        $LOCALDIR/pause
        breaksw

    case "99":
        $PAGER bambi1.ani
        breaksw
    case "0":
        exit 0
        breaksw

    case ""
        breaksw

    default
        echo "Invalid option <$answer>"
        $LOCALDIR/pause
    endsw
end
