#!/bin/sh
# $Id: setup-clean,v 1.4 2014/04/08 23:16:26 tom Exp $

failed() {
	echo "?? $*" >&2
	exit 1
}

if [ $# != 0 ]
then
	MKFILE=$1
	shift 1
else
	MKFILE=Makefile
	test -f makefile.in && MKFILE=makefile
	test -f makefile    && MKFILE=makefile
fi

while [ $# != 0 ]
do
	test -f $1 || failed "missing $1"
	shift 1
done

if [ -f "$MKFILE" ]
then
	make distclean
	rm -f *.out mk_shared_lib.sh     
	find . -type f -name 'coverage.info' -exec rm -f {} \; -print
	find . -type f -name '*.plist' -exec rm -f {} \;
	find . -type f -name '*.gcda' -exec rm -f {} \; -print
	find . -type f -name '*.gcno' -exec rm -f {} \; -print
	find . -type f -name '*.o' -exec rm -f {} \; -print
	find . -type f -name core -exec rm -f {} \; -print
fi
