#!/bin/sh

#
# A simple Bourne-shell script to run RLaB2 from any installed location.
# To get RlaB2 working you only need to modify the first
# shell variable.
#

#
# Modify the following to identify where the RLaB2 "root" 
# directory is...
#

RROOT="/usr"
RLAB_VER="2.1.05"
PLOT_DIR=""
PLOT_PROG="gnuplot"

#
# Do _not_ modify the next two definitions...
# (unless you are sure of what you are doing).
#

RD="$RROOT/lib/rlab2"		       # The parent rlab library directory.
RLABEXE="$RROOT/bin/rlab-$RLAB_VER"    # The rlab executable.

#
# Set the RLAB2_PATH env var.  This provides a auto path to the most
# commonly used rfiles.  You can overide this value by setting RLAB2_PATH
# in your environment prior to running rlab2
#

if test -z "$RLAB2_PATH" ; then
  RLAB2_PATH=".:$RD/rlib:$RD/toolbox:$RD/controls-toolbox:$RD/examples"
fi

#
# The RLaB2 startup script.
#

RLAB2_RC0="${HOME}/.rlab"

#
# The RLaB2 Library directory.
#

RLAB2_LIB_DIR="$RD/rlib"

#
# The RLaB2 help directory
#

RLAB2_HELP_DIR="$RD/doc/help"

#
# The pager to use.
#

RLAB2_PAGER="more"

#
# Export the shell environment variables so the RLaB process can
# access them.
#

export PATH RLAB2_PATH
export RLAB2_RC0
export RLAB2_LIB_DIR
export RLAB2_HELP_DIR
export RLAB2_PAGER

#
# Setup the environment to handle PGplot if necessary.
#

if test "$PLOT_PROG" = "pgplot" ; then
  PGPLOT_XW_WIDTH="0.5"
  PGPLOT_FONT="$PLOT_DIR/pgplot/grfont.dat"
  PGPLOT_DIR="$PLOT_DIR"
  LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PGPLOT_DIR"

  export PGPLOT_XW_WIDTH
  export PGPLOT_FONT
  export PGPLOT_DIR
  export LD_LIBRARY_PATH
fi

#
# Finally, run RLaB...
#

$RLABEXE $*

