#! /bin/sh
#
# Last modified on Thu Jan 19 15:51:47 PST 1995 by kalsow
#

RELEASE=$1 ; shift
ARCHIVE=$1 ; shift

#-------------------------------------------------------------- clean trash ---
echo --- removing trash --- `date`
find $ARCHIVE \( -name "VERS" -o -name "RCS" -o -name "DSC" -o -name "DS" -o -name "AOSF" \) -type d -print | xargs rm -rf

find $ARCHIVE \( -name ",*" -o -name ".,*" -o -name ".emacs_[0-9]*" -o -name "*~" -o -name core -o -name a.out -o -name ".m3*" -o -name ".nfs*" \) -print | xargs rm -rf

#--------------------------------------------------- fix source directories ---
echo --- fixing source directories --- `date`
find $ARCHIVE -name "src" -type d -exec M3EXPORT/finish-src {} \;

#------------------------------------------------------------ fix makefiles ---
echo --- fixing m3makefiles --- `date`
find $ARCHIVE -name "m3makefile" -exec M3EXPORT/clean-make {} \;

#----------------------------------------------------------- build tar file ---
# echo " "
# echo ----------------- building $ARCHIVE tar file
# echo ----------------- `date`
# echo " "

echo --- building tar file --- `date`
if [ ! -d $RELEASE ]; then mkdir $RELEASE ; fi
tar cflh - $ARCHIVE | gzip > $RELEASE/$ARCHIVE.tar.gz


