#!/bin/ksh
####################################
# install_tutorial ---
#	A simple program to install
#	the SUIT tutorial files
#	into a local directory.
#
# BY:   Matt Conway
# DATE: 2 Sept 1991
####################################

####################################
TUTORIAL_DIR=tutorial
SUIT=/users/suit/suit
####################################



####################################
# The rarely changed parameters appear
# near the bottom of this file
####################################

copy_files ()
{
	for i in $SOURCE_TO_COPY
	do
		echo Copying $i
		cp $SUIT/$EXAMPLES_DIR/$i .
	done
	
	for i in $SUI_TO_COPY
	do
		echo Copying $i
		cp $SUIT/$BIN_DIR/$i .
	done
	
}


make_links_to_executables()
{
	for i in $FILES_TO_LINK
	do
		echo Linking $i
		ln -s $SUIT/$BIN_DIR/$i  ./$i 
	done
}


####################################
EXAMPLES_DIR=src/examples
BIN_DIR=bin
SOURCE_TO_COPY="empty.c Makefile"
SUI_TO_COPY="demo.sui 3cell.sui poly.sui" 
FILES_TO_LINK="demo 3cell poly"
num_files=0
installed_files=0
####################################

	echo "****************************************************************"
	echo "                 SUIT TUTORIAL INSTALLATION"
	echo""
	echo "This program will create a directory called \"$TUTORIAL_DIR\" "
	echo "and copy the proper SUIT tutorial files into that directory."
	echo ""
		
	mkdir $TUTORIAL_DIR
	cd $TUTORIAL_DIR
	copy_files
	make_links_to_executables


	for i in $SOURCE_TO_COPY $SUI_TO_COPY $FILES_TO_LINK
	do
		num_files=`echo "$num_files + 1" | bc`
	done

	for i in *
	do
		installed_files=`echo "$installed_files + 1" | bc`
	done

	if test $num_files -eq $installed_files
	then	
		echo "The SUIT files copied are:"
		echo ""
		/bin/ls
		echo ""
		echo "****************************************************************"
		echo "The SUIT tutorial files have been successfully installed."
		echo "To get into the directory with the tutorial files, type "
		echo "         cd tutorial"
		exit 0
	
	else
		echo "****************************************************************"
		echo "ERROR!"
		echo "Wanted to install $num_files files"
		echo "Actually installed $installed_files files"
		echo "****************************************************************"
		echo "The SUIT tutorial files have NOT been successfully installed."
		echo "You should have the following files:"
		for i in $SOURCE_TO_COPY $SUI_TO_COPY $FILES_TO_LINK
		do
			echo $i
		done
		echo "Please send mail to suit@Virginia.EDU"
		echo "****************************************************************"
		exit 1
	fi
	
exit 0
