#!/bin/sh
##
## $local/com/INSTALL_MOTIF_POPLOG
## http://www.cs.bham.ac.uk/research/poplog/com/INSTALL_MOTIF_POPLOG
## Install Motif poplog then run INSTALL_LIKE_BHAM
##
## Aaron Sloman (http://www.cs.bham.ac.uk/~axs/)
## revised
##      28 Oct 2003
##          Changed to use SETUPDIRS and to use and pass on rootdir argument
##      24 Jul 2003
##          Changed to use LINK_MOTIF_POPLOG, and to use sh, not csh
##      3 May 2003
##          Added -norsv to newpop command
##      10 Mar 2003
##          Use new name for Core linux poplog tar file
##      11 Jan 2003
##      Check for /usr/X11R6/lib/libXm.so otherwise exit
## revised 10 Jan 2003
##    Reinserted call to poplink_cmnd: needed on too many systems because
##    of motif variations
## revised 18 Sep 2002
##      Removed call to poplink_cmnd: does not work on mandrake 8.2
## 14 Sep 2002

## If the following does not work it may be necessary to run the script
##     relinking-linux-poplog
## available from
##      http://www.cs.bham.ac.uk/research/poplog/tools/relinking.linux.poplog
## if not included in your tar file

## Create Poplog directory and define some environment variables
## Assumes that either a directory has been passed in as argument or
## the default should be used

. SETUPDIRS $*
    # 'source' this to get $usepop etc

## Run this in the directory in which the poplog tar file
## has been unpacked

tardir=`pwd`

export poplocal=$rootdir

export local=$poplocal/local

cd $usepop

echo "Unpacking poplog+motif. May take some time"

# Install linux poplog with motif
zcat $tardir/linux-pc-1553c.tar.gz | tar xf -

echo "UNPACKING POPLOG TAR FILE COMPLETE"

echo "main poplog system installed in $usepop"

echo "======================================================"

echo "directories in $usepop/pop "
ls -l $usepop/pop/

echo "======================================================"
echo "Now rebuilding system images"

. $usepop/pop/com/poplog.sh

export popsrc=$usepop/pop/src
export popsys=$usepop/pop/pop

## Now link poplog
$usepop/INSTALL/LINK_MOTIF_POPLOG

## Check for success of LINK command
if [ -f $usepop/pop/lib/psv/startup.psv ]
then
    echo "$usepop/LINK/LINK_MOTIF_POPLOG worked OK"
else
    echo "$usepop/LINK/LINK_MOTIF_POPLOG did not work"
    exit
fi

## Needed for later items
export pop_pop11="-$popsavelib/startup.psv"

echo "======================================================"

echo "Now installing packages in $local"

cd $tardir

echo "Run INSTALL_LIKE_BHAM"

./INSTALL_LIKE_BHAM

echo "======================================================"
echo "Finished INSTALL_LIKE_BHAM"

echo "done INSTALL_MOTIF_POPLOG FOR LINUX + PC"
