#! /bin/sh
# autogen.sh -- auto generate configure and build scripts and templates
#
# Authors:
#   Morten Eriksen <mortene@sim.no>
#   Lars J. Aas <larsa@sim.no>

PROJECT=Dime

AUTOCONF_VER=2.5[0234]
AUTOMAKE_VER=1.5
LIBTOOL_VER=1.4.2

echo "Verifying installed configuration tool versions..."

if test -z "`autoconf --version | grep \" $AUTOCONF_VER\" 2> /dev/null`"; then
  cat <<EOF

  Invalid Version of Autoconf
  ---------------------------
  You must use the CVS development version of autoconf ($AUTOCONF_VER)
  to generate configure information and Makefiles for $PROJECT.

    ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.52.tar.gz
EOF
  DIE=true
fi

if test -z "`automake --version | grep \" $AUTOMAKE_VER\" 2> /dev/null`"; then
  cat <<EOF

  Invalid Version of Automake
  ---------------------------
  You must use the CVS development version of automake to ($AUTOMAKE_VER)
  to generate configure information and Makefiles for $PROJECT.

  The CVS automake repository can be fetched by running the following
  set of commands:

    $ cvs -d :pserver:anoncvs@anoncvs.cygnus.com:/cvs/automake login
    $ cvs -d :pserver:anoncvs@anoncvs.cygnus.com:/cvs/automake co automake
EOF
  DIE=true
fi

if test -z "`libtool --version | grep \" $LIBTOOL_VER \" 2> /dev/null`"; then
  cat <<EOF

  Invalid Version of Libtool
  --------------------------
  You must have libtool version $LIBTOOL_VER installed to generate
  configure information and Makefiles for $PROJECT.

    Get ftp://ftp.gnu.org/pub/gnu/libtool/libtool-1.3.5.tar.gz
EOF
  DIE=true
fi

# abnormal exit?
${DIE=false} && echo "" && exit 1

echo "Running aclocal..."
aclocal -I cfg/m4

echo "Running autoheader..."
autoheader

echo "Running autoconf..."
autoconf

echo "Running automake..."
automake

echo "Done."

