#! /bin/sh --
# $Id: prepare,v 1.10 2004/01/07 14:46:22 lhecking Exp $
# Small shell script to prepare the gnuplot sources when
# checked out from CVS.

# Note that autoconf 2.52 or newer is required; automake versions older than
# 1.7 might not work

exelist="configure configure.vms depcomp install-sh missing mkinstalldirs config/djconfig.sh lisp/configure"

chmod 755 $exelist >/dev/null 2>&1
chmod og-w docs/* lisp/* >/dev/null 2>&1

# Clean up
rm -rf autom4te.cache lisp/autom4te.cache config.cache config.status

if aclocal -I m4 && autoheader \
  && (cd config && make -f Makefile.am.in Makefile.am ) \
  && (cd demo && make -f Makefile.am.in Makefile.am ) \
  && (cd m4 && make -f Makefile.am.in Makefile.am ) \
  && (cd term && make -f Makefile.am.in Makefile.am ) \
  && (cd tutorial && make -f Makefile.am.in Makefile.am ) \
  && (cd lisp && aclocal && automake && autoconf ) \
  && automake -a -c \
  && sed 's/noinst_PROGRAMS = bf_test$(EXEEXT) @GNUPLOT_X11@/noinst_PROGRAMS = bf_test$(EXEEXT) @GNUPLOT_X11@$(EXEEXT)/' \
	<src/Makefile.in >src/Makefile.in2 \
  && mv -f src/Makefile.in2 src/Makefile.in \
  && autoconf
then
  echo
  echo "The gnuplot source code was successfully prepared."
  echo "Run configure now, then make && make install to build and install gnuplot."
  echo
else
  echo
  echo "Some part of the preparation process failed."
  echo "Please refer to INSTALL for details."
  echo
  exit 1
fi

exit 0
