#!/bin/sh
#
# $Id: run_autoconfig,v 1.28 1999/05/24 22:43:36 peter Exp $
#
# Bootstrap script

need_to_make_depend=no

case :$PATH: in
   */NT/tools:*)
      echo Stripping NT/tools from path temporarily...
      PATH=`echo :$PATH | sed 's@:[^:]*/NT/tools:@@g' | sed 's@^:@@'`
   ;;
esac

if test "x$1" = "x" ; then
  base=`echo $0 | sed 's@[^/]*$@@g'`
  if test "x$base" != "x" ; then
    cd "$base"
  fi

  localdir=`pwd`
else
  cd "$1"

  localdir=`echo $0 | sed 's@[^/]*$@@g'`
  if test "x$localdir" = "x"; then
    localdir=`pwd`
  else
    localdir=`cd $localdir;pwd`
  fi
fi

find . -type d -print|egrep -v '/(CVS)|(RCS)$'| while read dir; do

  if [ -f $dir/Makefile.am -a -f $dir/configure.in ]; then
    # aclocal needs to be run before autoconf
    echo "Running aclocal in $dir"
    (cd $dir ; aclocal )
    echo "touch:ing Makfile.in in $dir"
    (cd $dir ; touch Makefile.in)
# GMP breaks with automake 1.4. libiodbc only works with 1.4+
# Automake is evil and should die. Put generated files in CVS.
#    echo "Running automake in $dir"
#    (cd $dir ; automake )
  fi

  if [ -f $dir/acconfig.h -a $dir/configure.in ]; then
    echo "Running autoheader in $dir"
    ( cd $dir ; autoheader && echo foo >stamp-h.in )
  fi

  if [ -f $dir/configure.in ]; then
    if grep AC_INIT $dir/configure.in >/dev/null; then
      echo "Running autoconf in $dir"
      ( cd $dir ; autoconf --localdir=$localdir )
    else
      echo "$dir seems to use Cygnus-configure."
    fi
  fi

  if [ -f $dir/Makefile.in -a ! -f $dir/dependencies ] && egrep @dependencies@ $dir/Makefile.in >/dev/null; then
    touch $dir/dependencies
    need_to_make_depend=yes
  fi
done

if test "x$need_to_make_depend" = "xyes" ; then
  echo You need to run \"make depend\" after \"configure\", and then \"configure\" again.
fi

exit 0
