#! /bin/sh
# The SPIMS software is covered by a license. The use of the software
# represents acceptance of the terms and conditions in the license.
# ******************************************************************
# Copyright (c) 1989, Swedish Institute of Computer Science
# Arguments: distribution name (= a relative path name of a distribution directory)
# SRCDIR: an absolute path name

if [ $# != 2 ]; then
	echo 'Usage: make_dist <src dir> <distribution directory>'
	exit 2
fi
SRCDIR="$1"
DISTDIR="$2"

cd $SRCDIR

echo "Creating dir $DISTDIR"
mkdir $DISTDIR

for i in *; do
	if [ -d $i ]; then
		mkdir $DISTDIR/$i
		case $i in
		OBJ ) 	(echo copying OBJ;
			cp -p $i/Makefile $DISTDIR/$i;
			cp -p $i/make $DISTDIR/$i);;
		autoconf | benchmarks | bin | composers | config | \
		dist | demo | filters | h | infile | initiators | \
		protoaddrs | protocols | responders | runs | src | test ) \
			(echo copying $i;
			cp -p $i/* $DISTDIR/$i;
			rm -f $DISTDIR/$i/*~ $DISTDIR/*.bak $DISTDIR/*.BAK;
			chmod +w $DISTDIR/$i/*);;
		outfile ) (echo leving $i empty;);;
		mc68020* | vax* | sparc* | sun3* | OBJ* | RCS | tmp | temp | slask ) \
			(echo NOT copying $i;
			rmdir $DISTDIR/$i);;
		* )	(echo copying protocol $i;
			cd $DISTDIR/$i;
			cp -p $SRCDIR/$i/Makefile .
			ln -s ../config/make .
			echo >makefile.conf;
			chmod +w *)
		esac
	fi
done
echo copying top-level files
cp Makefile make README TAGS $DISTDIR
