#! /bin/sh

# Usage: $0 `pwd` src src/.fixed_srcs

# Script to check that the basic required fixes have been applied.

# Remove Config, */Makefile, and fix up the DES code.
patches=Patches
patchestamp=.Patches.stamp

case "$2" in
/*)	dir="$2";;
*)	dir="$1/$2";;
esac

case "$3" in
/*)	file="$3";;
*)	file="$1/$3";;
esac


if	test -r "$file"
then	touch "$file"
	exit
fi

case "`echo $dir/*/Makefile`" in
"$dir/*/Makefile")	: Nothing ;;
*)			echo "$0: deleting Makefiles ..."
			rm -f $dir/*/Makefile
esac

if	test -r $dir/Config.dist
then	echo Assuming Config is one of yours ...
elif	test -r $dir/Config
then	echo Moving distributed Config to Config.dist
	mv $dir/Config $dir/Config.dist
fi

if	test -r $dir/lib/authdes.c.dist
then	echo Assuming you have a valid version of the DES code
else	echo Moving distributed lib/authdes.c to lib/authdes.c.dist
	mv $dir/lib/authdes.c $dir/lib/authdes.c.dist
	echo Installing Australian lib/authdes.c
	cp au.authdes.c $dir/lib/authdes.c
fi

if	test -r $patches -a ! -r $patchestamp
then	echo applying patches from $patches
	(cd $dir; patch -p) < $patches && touch $patchestamp
fi

touch $file
