#! /bin/sh 
#
# Script to do the configuration work required before running configure
# when starting from fresh CVS checkout, or cvs update
#
# $Header: /cvsroot/lesstif/lesstif/test/CVSMake,v 1.18 2002/05/14 16:29:47 amai Exp $
#

echo "$0 running in `pwd`"

# Get m4 from current PATH!
M4_=`which m4`
if test -x "$M4_"
then
   M4="$M4_"
   export M4
else
   echo "No m4 processor found. Exiting"
   exit 1
fi

# Find a tool dump HTML to ASCII
#lynx_=`which lynx`
#if test -x "$lynx_"
#then
#  HTMLDUMP="$lynx_ -dump -force_html "
#else
#  links_=`which links`
#  if test -x "$links_"
#  then
#     HTMLDUMP="$links_ -dump "
#  else
#     echo "Can not create Install!"
#  fi
#fi
#$HTMLDUMP doc/www.lesstif.org/INSTALL.html >INSTALL.txt 2>/dev/null || sed -e 's/<[^<>]*>//g' doc/www.lesstif.org/INSTALL.html >Install

# Defaults
distflag="--ignore-deps"
distopt=" "
localmode="no"
clean="no"
cleanopt=""

while test $# -gt 0 ; do
   case "${1}" in
     nodist )
       distflag="--include-deps "
       distopt="nodist"
       echo "(Embedding dependencies)"
       shift ;;
     local )
       localmode="yes"
       echo "local mode:don't run CVSMake in subtrees"
       shift ;;
     clean )
       clean="yes"
       cleanopt="clean"
       echo "Clean up"
       shift ;;
     * )
       echo "unknown flag ${1}"
       exit 1
       shift ;;
   esac
done

# Check for some options
if test "$clean" = "yes" ; then
  if test -f Makefile ; then
     make  maintainer-clean
  else
     echo "Already clean"
  fi
fi


# Print out some information about the system and the auto* tools
#./scripts/LTsysinfo

# Clean up old files which could hurt otherwise.
# Actually this won't help if building outside the source tree ...
rm -f config.cache config.guess config.log config.status config.sub \
      libtool ltmain.sh aclocal.m4 Makefile install-sh mkinstalldirs \
      missing ylwrap

# Our 'canonical' sequence:
echo ""
echo "running libtoolize"
libtoolize --copy --force --automake

echo "running aclocal"
aclocal -I . -I ..

echo "running autoconf"
autoconf

echo "running autoheader"
autoheader

echo "running automake"
automake --add-missing --copy  --foreign $distflag
