# Run this script to regenerate or update all the missing/out-of-date files.
# The files that are generated are given as comments.

srcdir=`dirname $0`
PKG_NAME="gkleds"

DIE=0

echo "Checking for autoconf..."
(autoconf --version) < /dev/null > /dev/null 2>&1 || {
  echo
  echo "**Error**: You must have \`autoconf' installed."
  echo "Download the appropriate package for your distribution,"
  echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
  DIE=1
}

echo "Checking for automake..."
(automake --version) < /dev/null > /dev/null 2>&1 || {
  echo
  echo "**Error**: You must have \`automake' installed."
  echo "Download the appropriate package for your distribution,"
  echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
  DIE=1
}

echo "Checking for autoheader..."
(autoheader --version) < /dev/null > /dev/null 2>&1 || {
  echo
  echo "**Error**: Missing \`autoheader'. The version of \`autoconf'"
  echo "installed doesn't appear to be complete."
  echo "Download the appropriate package for your distribution,"
  echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
  DIE=1
}

# automake takes care of libtool, but...
echo "Checking for libtool..."
(grep "^AM_PROG_LIBTOOL" $srcdir/configure.ac >/dev/null) && {
  (libtool --version) < /dev/null > /dev/null 2>&1 || {
    echo
    echo "**Error**: You must have \`libtool' installed."
    echo "Download the appropriate package for your distribution,"
    echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
    DIE=1
  }
}

echo "Checking for aclocal..."
(aclocal --version) < /dev/null > /dev/null 2>&1 || {
  echo
  echo "**Error**: Missing \`aclocal'. The version of \`automake'"
  echo "installed doesn't appear recent enough."
  echo "Download the appropriate package for your distribution,"
  echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
  DIE=1
}




if test "$DIE" -eq 1; then
  exit 1
fi
echo "All necessary tools found (versions not checked). Now running them..."
echo ""

echo "Running aclocal..." && \
aclocal # aclocal.m4 && \
echo "Running libtoolize --copy..." && \
libtoolize --copy # libtool and friends && \
echo "Running autoheader..." && \
autoheader # config-h.in && \
echo "Running automake --gnu --add-missing --copy..." && \
automake --gnu --add-missing --copy # Makefile.in, install-sh and friends && \
echo "Running autoconf --warnings=all..." && \
autoconf --warnings=all # configure and friends && \

echo ""
echo Now type \".\/configure --help\" to get configuration
echo options for $PKG_NAME. Then type \".\/configure \<options\>\"
echo to configure $PKG_NAME. 
