#INSTALL should be saved as is replaced by --force (an odd  feature of autoreconf)
# for nested packages, autoreconf still creates issues with m4 alignment
# so autoreconf in each package with --no-recursive when there are nested ones.
# empirically, top-down order works better (trash generated by root autoreconf in nested packages is erased by nested autoreconf)

if test ! -f /usr/bin/autoreconf -a ! -f /usr/local/bin/autoreconf ; then
   echo 'You need autoreconf installed to run this in-tree bootstrap tool'
   echo 'install it from GNU autoconf source code (ftp://gnu.ftp.org/gnu)'
   exit
fi

if test -d autom4te.cache; then
rm -rf autom4te.cache
fi

backup=INSTALL_save_$(date | sed -r "s/[() :]/./g")
cp INSTALL $backup
 
topdir=`pwd`
echo "Entering: "
echo "$topdir"
autoreconf --install --force -Im4 -Im4.extra -Im4.extra.dvdauthor 

cd "$topdir"

mv $backup INSTALL
if test $? = 0; then
echo INSTALL was recovered
else
echo INSTALL was backed up in previous generation but could not be recovered.
echo Fix this manually.
fi

