#!/bin/sh 
# @(#) $RCSfile: SET_VARS,v $ version $Revision: #16 $ created $Date: 2006/06/26 $
# @(#) Copyright (c), 1987, 2006 Insightful Corp.  All rights reserved.
# Modify $SHOME/DEFAULT.DEST file to have the environment variables for the
# S-PLUS Installation files.

tmpdir=${TMPDIR:-/tmp}
TEMP_FILE=$tmpdir/SET_VARS.$$

CONTINUE=T

case $1 in
SPLUS_DEST) cat << EOF

The Splus shell script starts the S-PLUS system.  It must be installed in
a directory that is searched by all users on your system.  This directory
should be one of those in your PATH environment variable.

EOF
    echo-n "Enter the directory where you would like to install Splus: "
    CONTINUE=F
    read SPLUS_DEST
    fgrep -v SPLUS_DEST ./splus/lib/install/USER.env > $TEMP_FILE
    echo 'SPLUS_DEST='\"$SPLUS_DEST\"'; export SPLUS_DEST' >> $TEMP_FILE
    mv $TEMP_FILE ./splus/lib/install/USER.env
;;


SPLUS_SCRIPT) cat << EOF

The Splus shell script starts the S-PLUS system.  If you already have
another version of S-PLUS installed on this system and you want to continue
to use it then you should select a name for the Splus shell script that
is different from what you currently use (e.g. nSplus or Splus6).

EOF
    echo-n "Enter the name you would like to give the Splus startup script: "
    CONTINUE=F
    read SPLUS_SCRIPT
    fgrep -v SPLUS_SCRIPT ./splus/lib/install/USER.env > $TEMP_FILE
    echo 'SPLUS_SCRIPT='\"$SPLUS_SCRIPT\"'; export SPLUS_SCRIPT' >> $TEMP_FILE
    mv $TEMP_FILE ./splus/lib/install/USER.env
;;

SCRIPT_OVERWRITE)
    CONTINUE=F
    SCRIPT_OVERWRITE=y
    fgrep -v SCRIPT_OVERWRITE ./splus/lib/install/USER.env > $TEMP_FILE
    echo 'SCRIPT_OVERWRITE="y"; export SCRIPT_OVERWRITE' >> $TEMP_FILE
    mv $TEMP_FILE ./splus/lib/install/USER.env
;;

TROFF)  
    echo-n "Enter the name of your TROFF command: "
    read TROFF
    fgrep -v TROFF ./splus/lib/install/USER.env > $TEMP_FILE
    echo 'TROFF='\"$TROFF\"'; export TROFF' >> $TEMP_FILE
    mv $TEMP_FILE ./splus/lib/install/USER.env
;;

TO)
    echo " Enter the arguments to $TROFF to write to standard output"
    echo-n "(a typical value and the default setting is "-t"): "
    read TO
    fgrep -v TO ./splus/lib/install/USER.env > $TEMP_FILE
    echo 'TO='\"$TO\"'; export TO' >> $TEMP_FILE
    mv $TEMP_FILE ./splus/lib/install/USER.env
;;

OLD_NEW) while [ "$CONTINUE" = "T" ]
do
    cat << EOF

Is your version of TROFF old or new?

1:	old
2:	new
0:	Return to Previous Menu

EOF
    echo-n "Enter the number of your choice: "
    CONTINUE=F
    read WHICH
    case $WHICH in
      0)  exit 0;;
      1)  OLD_NEW="old";;
      2)  OLD_NEW="new";;
      *)      
          echo "You must enter a number between 0 and 2"
          CONTINUE=T;;
      esac
    done
    fgrep -v OLD_NEW ./splus/lib/install/USER.env > $TEMP_FILE
    echo 'OLD_NEW='\"$OLD_NEW\"'; export OLD_NEW' >> $TEMP_FILE
    mv $TEMP_FILE ./splus/lib/install/USER.env
;;

EQN)   
    echo-n "Enter the name of the EQN command (generally: eqn): "
    read EQN
    fgrep -v EQN ./splus/lib/install/USER.env > $TEMP_FILE
    echo 'EQN='\"$EQN\"'; export EQN' >> $TEMP_FILE
    mv $TEMP_FILE ./splus/lib/install/USER.env
;;

PRINT) 
    echo-n "Enter the UNIX command which sends a file to your "
    echo-n "PostScript printer: "
    read PRINT
    fgrep -v PRINT ./splus/lib/install/USER.env > $TEMP_FILE
    echo 'PRINT='\"$PRINT\"'; export PRINT' >> $TEMP_FILE
    mv $TEMP_FILE ./splus/lib/install/USER.env
;;

S_LIB_STATIC) 
  cat << EOF

If you want to add your own C or Fortran routines to S-PLUS through static
loading, you'll need to ensure that S-PLUS knows what system library
specification to use to support linking S-PLUS with your routines.  This
should be all the library specifications needed to link S-PLUS, excluding
the C library specifications.  Usually, you just need all the FORTRAN
library specifications here.

NOTE: Please see the section "Libraries For Static Loading and Dynamic
Loading with dyn.load2" in Chapter 1 of the S-PLUS User's Manual for
more details.

Enter the system library specification you would like S-PLUS to use when
static loading. Exclude the C libraries, and do not type surrounding quotes.

EOF
  CONTINUE=F
  read S_LIB_STATIC 

  fgrep -v S_LIB_STATIC ./splus/lib/install/USER.env > $TEMP_FILE
  echo 'S_LIB_STATIC='\"$S_LIB_STATIC\"'; export S_LIB_STATIC' >> $TEMP_FILE
  mv $TEMP_FILE ./splus/lib/install/USER.env
;;

S_LIB_DYNLOAD2) 
cat << EOF

If you want to add your own C or Fortran routines to S-PLUS through
dynamic loading with dyn.load2, you'll need to ensure that S-PLUS knows
what library specification to use to support linking S-PLUS with
your routines.  This should be all the library specifications needed to
link S-PLUS, including the C library specifications.  (The C library named
should usually match whatever specification cc(1) normally gives to ld(1)
(typically "-lc")):

NOTE: Please see the section "Libraries For Static Loading and Dynamic
Loading with dyn.load2" in Chapter 1 of the S-PLUS User's Manual for
more details.

Enter the library specification you would like S-PLUS to use when dynamic
loading with dyn.load2.  Include the C libraries, and do not type
surrounding quotes.

EOF
  CONTINUE=F
  read S_LIB_DYNLOAD2 

  fgrep -v S_LIB_DYNLOAD2 ./splus/lib/install/USER.env > $TEMP_FILE
  echo 'S_LIB_DYNLOAD2='\"$S_LIB_DYNLOAD2\"'; export S_LIB_DYNLOAD2'>>$TEMP_FILE
  mv $TEMP_FILE ./splus/lib/install/USER.env
;;

DPI)	while [ "$CONTINUE" = "T" ]
  do
    cat << EOF

Select a value for HP LaserJet Resolution:

1:	75  DPI
2:	100 DPI
3:	150 DPI
4:	300 DPI
0:	Return to Previous Menu

EOF
    echo-n "Enter the number of your choice: "
      CONTINUE=F
      read WHICH
      case $WHICH in
      0)	exit 0;;
      1) 	DPI=75;;
      2) 	DPI=100;;
      3) 	DPI=150;;
      4) 	DPI=300;;
      *)      echo "You must enter a number between 0 and 4"
    	  CONTINUE=T;;
      esac
    done
    fgrep -v DPI ./splus/lib/install/USER.env > $TEMP_FILE
    echo 'DPI='\"$DPI\"'; export DPI' >> $TEMP_FILE
    mv $TEMP_FILE ./splus/lib/install/USER.env
;;

ORIENTATION) while [ "$CONTINUE" = "T" ]
  do
    cat << EOF

Select the default orientation of Hardcopy Plots:

1:	landscape
2:	portrait
0:	Return to Previous Menu

EOF
    echo-n "Enter the number of your choice: "
    CONTINUE=F
    read WHICH
    case $WHICH in
      0)	exit 0;;
      1) 	ORIENT="landscape";;
      2) 	ORIENT="portrait";;
      *)      echo "You must enter a number between 0 and 2"
    	  CONTINUE=T;;
    esac
    done
    fgrep -v ORIENT ./splus/lib/install/USER.env > $TEMP_FILE
    echo 'ORIENT='\"$ORIENT\"'; export ORIENT' >> $TEMP_FILE
    mv $TEMP_FILE ./splus/lib/install/USER.env
;;

METHOD) while [ "$CONTINUE" = "T" ]
  do
    cat << EOF

Select the default hardcopy printing method:

1:	postscript
2:	laserjet
0:	Return to Previous Menu

EOF
    echo-n "Enter the number of your choice: "
    CONTINUE=F
    read WHICH
    case $WHICH in
      0)	exit 0;;
      1) 	METHOD="postscript";;
      2) 	METHOD="laserjet";;
      *)      echo "You must enter a number between 0 and 2"
    	  CONTINUE=T;;
      esac
    done
    fgrep -v METHOD ./splus/lib/install/USER.env > $TEMP_FILE
    echo 'METHOD='\"$METHOD\"'; export METHOD' >> $TEMP_FILE
    mv $TEMP_FILE ./splus/lib/install/USER.env
;;

POSTSCRIPT)
    echo ""
    echo-n "Enter the UNIX command which sends a PostScript file to the printer: "
    CONTINUE=F
    read POSTSCRIPT
    fgrep -v POSTSCRIPT ./splus/lib/install/USER.env > $TEMP_FILE
    echo 'POSTSCRIPT='\"$POSTSCRIPT\"'; export POSTSCRIPT' >> $TEMP_FILE
    mv $TEMP_FILE ./splus/lib/install/USER.env
;;

LASERJET)
    echo ""
    echo-n "Enter the UNIX command which sends a HP LaserJet file to the printer: "
    CONTINUE=F
    read LASERJET
    fgrep -v LASERJET ./splus/lib/install/USER.env > $TEMP_FILE
    echo 'LASERJET='\"$LASERJET\"'; export LASERJET' >> $TEMP_FILE
    mv $TEMP_FILE ./splus/lib/install/USER.env
;;
LIC_LOGFILE)
    echo "Enter the name of the license server logfile (either full directory path"
    echo "or relative to \$SHOME):"
    read LIC_LOGFILE
    fgrep -v LIC_LOGFILE ./splus/lib/install/LICENSE.env > $TEMP_FILE
    echo 'LIC_LOGFILE='\"$LIC_LOGFILE\"'; export LIC_LOGFILE' >> $TEMP_FILE
    mv $TEMP_FILE ./splus/lib/install/LICENSE.env
;;
LIC_RESOURCES)
    echo "Enter the name of the license server resources file (either full directory"
    echo "path or relative to \$SHOME):"
    read LIC_RESOURCES
    fgrep -v LIC_RESOURCES ./splus/lib/install/LICENSE.env > $TEMP_FILE
    echo 'LIC_RESOURCES='\"$LIC_RESOURCES\"'; export LIC_RESOURCES' >> $TEMP_FILE
    mv $TEMP_FILE ./splus/lib/install/LICENSE.env
;;
SLIC_SERVER)
    echo "Enter the name of the server to obtain licenses from (hostname or IP"
    echo "address):"
    read SLIC_SERVER
    fgrep -v SLIC_SERVER ./splus/lib/install/LICENSE.env > $TEMP_FILE
    echo 'SLIC_SERVER='\"$SLIC_SERVER\"'; export SLIC_SERVER' >> $TEMP_FILE
    mv $TEMP_FILE ./splus/lib/install/LICENSE.env
;;
SLIC_KEYDIR)
    echo "Enter the name of the license key directory (either full directory path"
    echo "or relative to \$SHOME):"
    read SLIC_KEYDIR
    fgrep -v SLIC_KEYDIR ./splus/lib/install/LICENSE.env > $TEMP_FILE
    echo 'SLIC_KEYDIR='\"$SLIC_KEYDIR\"'; export SLIC_KEYDIR' >> $TEMP_FILE
    mv $TEMP_FILE ./splus/lib/install/LICENSE.env
;;
LIC_LOGSIZE)
    echo-n "Enter the approximate maximum size for the license server logfile:"
    read LIC_LOGSIZE
    fgrep -v LIC_LOGSIZE ./splus/lib/install/LICENSE.env > $TEMP_FILE
    echo 'LIC_LOGSIZE='\"$LIC_LOGSIZE\"'; export LIC_LOGSIZE' >> $TEMP_FILE
    mv $TEMP_FILE ./splus/lib/install/LICENSE.env
;;
LIC_NUMSERVERS)
    echo-n "Enter the number of license servers to be run:"
    read LIC_NUMSERVERS
    fgrep -v LIC_NUMSERVERS ./splus/lib/install/LICENSE.env > $TEMP_FILE
    echo 'LIC_NUMSERVERS='\"$LIC_NUMSERVERS\"'; export LIC_NUMSERVERS' >> $TEMP_FILE
    mv $TEMP_FILE ./splus/lib/install/LICENSE.env
;;
LIC_RSHCMD)
    echo "Enter the command to be used to start a remote license server daemon:"
    read LIC_RSHCMD
    echo "$LIC_RSHCMD" > $SHOME/splus/lib/install/LICRSHCMD
;;

esac
