#!/bin/sh
#
# This is the installer script for Graphlet binaries.
#
#------------------------------------------ CVS
#
# CVS Headers -- The following headers are generated by the CVS
# version control system. Note that especially the attribute
# Author is not necessarily the author of the code.
#
# $source: /home/br/CVS/graphlet/src/gt_base/Attributes.h,v $
# $Author: himsolt $
# $Revision: 1.2 $
# $Date: 1999/03/05 20:39:36 $
# $Locker:  $
# $State: Exp $
#
#------------------------------------------ CVS
#
# (C) University of Passau 1995-1999, Graphlet Project
#

#
# Argument evaluation (experimental)
#

INSTALL_DIR=`pwd`

while [ $# -gt 0 ] ; do
    case $1 in
	-dir)
	    if [ $# -gt 1 ]; then
		shift;
		INSTALL_DIR=$1;
		shift;
	    else
		echo "Usage: $0 -dir installation_directory"
	    fi
	    ;;
	*)
	    echo "Usage: $0"
	    exit 1
	    ;;
    esac
done
  
echo "Installing Graphlet at $INSTALL_DIR"


#
# Variables
#


SCRIPTS="gmlview graphlet"
ETC_DIR=lib/graphlet/etc
GRAPHSCRIPT_DIR=lib/graphscript
BIN_DIR=bin


#
# Programs used here
#

MV="/bin/mv -f"
RM="/bin/rm -f"
CAT=/bin/cat
SED=/bin/sed
CHMOD=/bin/chmod
CHMOD_EXEC=a+rx


#
# Changing paths in $SCRIPTS
#

for file in $SCRIPTS ; do
    $MV -f $BIN_DIR/$file $BIN_DIR/$file.bak.$$
    install_dir=`echo $INSTALL_DIR | $SED -e 's/\//\\\\\//g'`
    $CAT $BIN_DIR/$file.bak.$$ | \
    $SED \
	-e "s/^INSTALL_DIR=.*/INSTALL_DIR=$install_dir/" \
	-e "s/^#GRAPHLET_DIR/GRAPHLET_DIR/" \
	-e "s/^#TCL_LIBRARY/TCL_LIBRARY/" \
	-e "s/^#TK_LIBRARY/TK_LIBRARY/" \
	>$BIN_DIR/$file
    $CHMOD $CHMOD_EXEC $BIN_DIR/$file
done


##########################################
#
# Set emacs variables
#
##########################################

# ;;; Local Variables: ***
# ;;; End: ***
