#!/bin/sh
# autowild
# for those of you that have no wild-automake

# ugh
verbose=true
if test x$1 = x-v; then
	verbose=echo
fi

#ugh
# PERL=@PERL@
PERL=/usr/bin/perl
PROGNAME=autowild #don't includee path; this messes up stuff
WILD_MAKEFILES=$(find . -name \*.wild)
for i in $WILD_MAKEFILES; do
	dir=$(dirname $i)
	wild=$(basename $i)
	make=$(basename $i .wild)
	TOPDIR=`pwd`
	(cd $dir

	$verbose -n "trying $dir/$make.. "
	cat $wild | $PERL $TOPDIR/bin/wild-perl >> $make.NEW
	if [ ! -f $make ]; then
	    touch $make
	fi

	if cmp -s $make.NEW $make; then
	    $verbose "autowild: $dir/$make didn't change"
	    rm $make.NEW
	else
		mv $make.NEW $make
		$verbose "autowild: creating $dir/$make"
	fi
	)
done
	
