#! /bin/sh
#	$Id: maintainerclobber,v 1.4 2007/07/31 23:22:43 fang Exp $

# emulates a "make maintainerclean" and more
# run this script from the top_srcdir (root)
# "maintainer-clean" should invoke "make distclean"
# Any .tar.* distribution tarballs will not be deleted by this script.  

if test ! -f configure.ac
then
	echo "You must run this script from the top source directory."
	exit 1
fi

if test -f Makefile
then
	make clean-cvsignore maintainer-clean
fi

rm -f *~
rm -f aclocal.m4
rm -rf autom4te.cache
rm -f autoscan.log
rm -f configure.scan
rm -f config.status
rm -f configure
(mkdir preserve && cd libltdl && \
	mv CVS README.CVS .cvsignore ../preserve && \
	cd .. && \
	rm -rf libltdl && \
	mv preserve libltdl )
(cd config && \
	rm -f install-sh \
	missing \
	ylwrap \
	mkinstalldirs \
	config.guess \
	config.sub \
	compile \
	depcomp \
	ltmain.sh )
rm -f src/__config__.h.in
rm -f src/headers_deps.make
rm -f libtool
#  what if there are Makefiles we wish to keep? address later...
rm -rf `find . -name .libs`
rm -rf `find . -name .deps`
rm -f `find . -name "stamp-h*"`
rm -f `find . -name Makefile`
rm -f `find . -name Makefile.in`
rm -f `find . -name dummy.cc`
# rm -f `find . -name .cvsignore | grep -v config`

# to see what's left:
ls -R

echo "Run \"bootstrap\" to regenerate maintainer files."

