dnl	This file is an input file used by the GNU "autoconf" program to
dnl	generate the file "configure", which is run during [incr Tcl]
dnl installation to configure the system for the local environment.

AC_INIT(tcl8.1.1/generic/tcl.h)
# RCS: $Id: configure.in,v 1.7 1999/06/30 22:03:11 damon Exp $

AC_CONFIG_AUX_DIR(config)
AC_PREREQ(2.0)

case "$SHELL" in
    bash)
	echo "It's good you're using BASH for a shell, but you must"
	echo "export SHELL=/bin/bash, not just $SHELL"
	;;
    */sh)
	echo "Looks like you're using an old Bourne shell.  You are"
	echo "likely headed for trouble.  If the build fails, get BASH"
	echo "from ftp://prep.ai.mit.edu/pub/gnu, build it and use it"
	echo "for your shell.  You'll should also make sure to export"
	echo "CONFIG_SHELL=/bin/bash (or /usr/local/bin/bash)."
	echo "Ksh should work too."
	;;
    */ksh)
	;;
    */csh)
	echo "Running from the C-Shell, eh?  I like your style, but"
	echo "you are about for sure headed for disaster.  Use another"
	echo "shell (bash or ksh) to configure and build Neotcl8.1.1."
	exit 1
	;;
esac

cat << EOF
***Warning***"
	Some configure scripts included in these packages stretch the limits
	of stock tools delivered with many Unix vendors' systems.  The tools
	that are taken to their limits are (in the order in which they
	should be prime suspects): the Bourne shell (/bin/sh), sed, and make.
EOF

# -----------------------------------------------------------------------
#
#   Set up a new default --prefix.  If a previous installation of
#   [incr Tcl] can be found searching $PATH use that directory.
#
# -----------------------------------------------------------------------

AC_PREFIX_DEFAULT(/usr/local)
dnl AC_PREFIX_PROGRAM(itclsh)

AC_ARG_ENABLE(make,     [  --disable-make    disable automatic make of tcl core])
AC_ARG_WITH(tk,       [  --without-tk     do not build the Tk toolkit])
AC_ARG_WITH(tclx,     [  --without-tclx   do not build Extended Tcl (TclX)])
AC_ARG_WITH(neo,      [  --without-neo    do not build the NeoSoft (Neo) package])
AC_ARG_WITH(gd,       [  --without-gd     do not build Gd])
AC_ARG_WITH(sharedDummy,       [  --enable-shared     Build a shared version])

pkg_list="tclx neo itcl gd"

pkg_tcl=tcl8.1.1/unix
pkg_tk=tk8.1.1/unix
pkg_tclx=tclX8.1.1/unix
pkg_neo=neo8.1.1/generic
pkg_itcl=itcl3.0.1/itcl/unix
pkg_gd=gd1.2

AC_ARG_WITH(x, [  --without-x	do not build Tk nor packages that use Tk],
	use_x=$withval, use_x=yes)

if test "$use_x" = "no"
then
	with_tk=no
fi


# Don't try to build if the directory is not there.

dirlist=""

for pkg in $pkg_list
do
    eval withval=\$with_$pkg
    if test "$withval" != no
    then
	eval dir=\$pkg_$pkg
	if test -d $dir
	then
		dirlist="$dirlist $dir"
	else
		echo WARNING: $pkg cannot be built: $dir is missing
	fi
    fi
done


PREBUILD="$pkg_tcl"
if test "$with_tk" != "no"
then
  PREBUILD="$PREBUILD $pkg_tk"
fi
AC_SUBST(PREBUILD)

# New in release 8.1: configure core Tcl/Tk code first, then actually do a make.
# This allows some packages which search for the Tcllib to configure correctly.

alldirs="$PREBUILD $dirlist"
AC_SUBST(alldirs)

if test "$enable_make" = no
then
   dirlist="$PREBUILD $dirlist"
fi

ac_popdir=`pwd`
for pkgdir in $PREBUILD
do
  echo "Configuring in ($PREBUILD)"
  cd $pkgdir
  echo "running ${CONFIG_SHELL-/bin/sh} ./configure $ac_configure_args"
  # The eval makes quoting arguments work.
  if eval ${CONFIG_SHELL-/bin/sh} ./configure $ac_configure_args
  then :
  else
    { echo "configure: error: $ac_sub_configure failed for $ac_config_dir" 1>&2; exit 1; }
  fi

  if test "$enable_make" != no
  then
    echo "Building and installing in $pkgdir"
    make install
  fi
  cd $ac_popdir
done

echo Configuring $dirlist
AC_CONFIG_SUBDIRS($dirlist)


AC_OUTPUT(Makefile)
