#!/bin/sh

here=`pwd`
stdargs="-I $here/texk/m4"

acnew()
{
  echo "Configuring directory \`$1' ..." >&2
  cd $here/$1
  if test -d m4; then
    args="$stdargs -I m4"
  else
    args="$stdargs"
  fi
  echo "  calling aclocal" >&2
  aclocal --force $args || return
  echo "  calling autoconf" >&2
  autoconf --force || return
  echo >&2
  rm -rf autom4te.cache
}

test -d texk/m4 || {
  echo "Directory texk/m4 does not exist. Abort." >&2
  exit 1
}

for dir in `find * \( -name configure.in -o -name configure.ac \) -printf '%h '`; do
  case $dir in
    */texinfo|*/texi2html|*/ncurses) continue;;
  esac
  acnew $dir
done

for f in reautoconf-*.hack; do
  test -x $f && ./$f
done

exit 0
