	#!/bin/sh
	#
	# Distribute Vplot to other machines
	# Writes a series of calls to rcp.  Does not create any directories;
	# they must already exist.
	#
	# Usage:
	# distribute_to  machine_name
	#
	# This will produce a file called "Copy_to_machine_name", which you can
	# sh to do the actual copying.
	#
	# You should have a subdirectory in ./machines for each machine name.
	# There must exist two files in this directory, called "dirlist"
	# and "path". In the file "dirlist" there should be a list of the
	# device libraries to put on that machine, one name per line.
	# In the file "path" the path to the filters directory on the
	# destination machine should be given. (The output of "pwd" on
	# that machine if you were in the filters directory.)
	# The modification times of the `date' files keeps track of which files
	# are out of date on which machines.
	#
	# This file will not copy machine-dependent files: "params.h",
	# "machdep*", "*.a", "*.o", "*.bin". Params.h and machdep* must
	# be copied and appropriately modified as needed by hand.
	#
	# Author - Chuck Karish
	# Debugged by Joe Dellinger 12-17-87
	#

if [ $# -ne 1 ]
then
	echo "distribute_to: Wrong number of arguments." 1>&2
	echo "Usage: distribute_to machine_name; sh Copy_to_machine_name" 1>&2
	exit 1
fi

	if [ ! -r "./machines/$1/dirlist" ]
	then
		echo "Must have a dirlist file"
		exit 1
	fi

	if [ ! -r "./machines/$1/path" ]
	then
		echo "Must have a path file"
		exit 1
	fi

GENDIRS="genlib include loclib utilities vplib Tests"
DEVDIRS=`cat ./machines/$1/dirlist | tr '\015' ' '`
DEVPATH=`cat ./machines/$1/path | tr '\015' ' '`

rm -f /tmp/Vplot_dist_$$

for direct in *.c MakeMake* $GENDIRS $DEVDIRS
do

	if [ -r $direct ]
	then
		other=""
	else
		other="otherpens/"
	fi

	if [ -r "./machines/$1/date" ]
	then
		find $other$direct -type f -newer ./machines/$1/date -print | \
			egrep -v "(\\.a\$|\\.o\$|\\.bin|\\.include|params\\.h\$)" >> \
			/tmp/Vplot_dist_$$
	else
		find $other$direct -type f -print | \
			egrep -v "(\\.a\$|\\.o\$|\\.bin|\\.include|params\\.h\$)" >> \
			/tmp/Vplot_dist_$$
	fi
done

sed < /tmp/Vplot_dist_$$ -e 's+^\(.*\)$+rcp '`pwd`'/\1 '$1':'$DEVPATH'/\1+' \
| sed -e 's+^\(.*\)\(/otherpens\)\(.*\)\(/otherpens\)\(.*\)$+\1\2\3\5+' \
> Copy_to_$1
rm -f /tmp/Vplot_dist_$$
echo 'touch -f '`pwd`'/machines/'$1'/date' >> Copy_to_$1
echo "#rm -f Copy_to_$1" >> Copy_to_$1
