#! /bin/sh
# $Id$

# Script to setup DDD configuration work before actually running configure
# when starting from fresh CVS checkout.  See `README-CVS' for details.

this=`basename $0`
echo "$this: setting up DDD from CVS..."

# Check on libtool version
# libtool 1.6 will have LT_PREREQ. Meanwhile it is better than nothing.
LIBTOOL_VERSION=`libtoolize --version | sed '1q' | sed 's/.*libtool) *//'`
LIBTOOL_MAJOR=`echo ${LIBTOOL_VERSION} | cut -d. -f1`
LIBTOOL_MINOR=`echo ${LIBTOOL_VERSION} | cut -d. -f2`
if test `expr "${LIBTOOL_MAJOR}" '=' 1` = 1; then
  if test `expr "${LIBTOOL_MINOR}" '<' 5` = 1; then
    echo "$this: Please use libtool 1.5 or later."
    exit 1
  fi
fi

# Newer versions of autoconf choke if any file generated by config.status
# is absent.  So generate these files by hand...
(cd ddd && make -f Makefile.am Ddd.in srcdir=. M4=m4 MV=mv \
	   DELETE_CR=cat GREP=grep AWK=awk)

# Set up configure scripts.
# Note: no `--copy': config scripts are created as symbolic links.
aclocal
autoheader
libtoolize
autoconf
automake --include-deps --add-missing --verbose

# Configure the package once, using default arguments (or given arguments)
sh ./configure "$@"

# Make DDD Makefiles
(cd ddd && (make Makefile; make Makefile))

# Create everything in the distribution that can be installed.
# See the `INSTALL' file for prerequisites.
# If all went well, delete any configuration-dependent files.
make progstuff && make distclean

echo "$this: setting up DDD from CVS...done."
echo "$this: Now see the INSTALL file for configuring and building DDD."
