#!/bin/csh
# ftp://ftp.cs.bham.ac.uk/pub/dist/poplog/setup/bin/poplog
# http://www.cs.bham.ac.uk/research/poplog/setup/bin/poplog
# $poplocal/local/setup/bin/poplog

## Version for csh and tcsh users (sourced or run as a script)

# Aaron Sloman
# 17 Sep 2000
# Revised 23 Apr 2002 Use current.poplog link, not v15.53

# See also the poplogmail script in this directory
# NB NB Please edit the "setenv" lines to suit your installation
# The default poplogroot may not be best for you.

# Purpose:
# Script which sets up poplog environment variables, and then runs
# The command given as argument (e.g. pop11, xved, clisp, etc.)
# When used like this it sets the environment variables only in the
# process that runs the script.

# Can be "sourced" instead, to set environment variables for a whole
# login session, or in an xterm, e.g. in the user's startup file


## In the first mode, it can be invoked with commands such as
##    poplog pop11
##    poplog ved
##    poplog xved <file>
##    poplog prolog
##    poplog clisp
##    poplog pml
##    poplog pop11 +eliza

# setup local directory tree for poplog root
# may be a symbolic link to something else

## THIS IS A DEFAULT WHICH MAY NEED TO BE EDITED AT YOUR SITE
setenv poplogroot /usr/local/poplog

## THIS MAY ALSO NEED TO BE EDITED
# setenv usepop $poplogroot/v15.53
setenv usepop $poplogroot/current.poplog

# Set the poplocal variables

## THIS MAY ALSO NEED TO BE EDITED
setenv poplocal $poplogroot
setenv local    $poplocal/local

# Run the initialisation files to set up additional environment
# variables, extend $PATH, etc.
# THIS IS THE "STANDARD" poplog "login" file. It sources several others
source $usepop/pop/com/poplog

# (Optional)
# Set $EDITOR and $VISUAL, unless set by users. Users can undo this.


## THESE MAY ALSO NEED TO BE EDITED
if (! $?EDITOR) setenv EDITOR ved
if (! $?VISUAL) setenv VISUAL ved


if ($?DISPLAY) then
    # DISPLAY set. Using X, so set resources

    # Extend X resources for Ved in xterm, Xved etc.
    # Read user's file if it exists, otherwise system version
    if ( -f ~/.Xdefaults.poplog ) then

        # Get user's version
        xrdb -merge ~/.Xdefaults.poplog

    else
        # Defaults may not be ideal.
        # E.g. check font size for XVed
        xrdb -merge $poplocal/local/setup/Poplib/Xdefaults.poplog
    endif

endif

## Check if user has a location for init.p, vedinit.p etc. and if not
## use a default location (MUST EXIST)

if (-d ~/Poplib) then
    setenv poplib ~/Poplib
else if (-d ~/poplib) then
    setenv poplib ~/poplib
else
    ## A place where local versions of init.p, vedinit.p init.lsp etc.
    ## can be located
    ## Current versions supplied in setup.tar.gz are a mess and need to
    ## be reorganised. (A.Sloman 24 Aug 2001)

    setenv poplib $poplocal/local/setup/Poplib
endif

# If sourced (with no arguments) do nothing, but leave environment
# variables set.
# If run with arguments, run the command given. Use exec to save a proces.

if ( "$*" != "") exec $*
