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(iwidgets.tcl.in)
# RCS: $Id: configure.in,v 1.1.1.1 1999/01/03 06:52:54 sparker Exp $

ITCL_VERSION=3.0
IWIDGETS_VERSION=0
VERSION=2.2.${IWIDGETS_VERSION}

AC_CONFIG_AUX_DIR(../../config)
AC_PREREQ(2.0)

# -----------------------------------------------------------------------
#   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)
AC_PREFIX_PROGRAM(tclsh)

if test "${prefix}" = "NONE"; then
    prefix=/usr/local
fi
if test "${exec_prefix}" = "NONE"; then
    exec_prefix=$prefix
fi

AC_PROG_INSTALL
AC_PROG_RANLIB

# -----------------------------------------------------------------------
BUILD_DIR=`pwd`
IWIDGETS_SRC_DIR=`cd $srcdir/..; pwd`
cd ${BUILD_DIR}

#--------------------------------------------------------------------
#   See if there was a command-line option for where Tcl is;  if
#   not, search for Tcl.
#--------------------------------------------------------------------

AC_ARG_WITH(tcl, [  --with-tcl=DIR          use Tcl 8.0 binaries from DIR],
        itcl_search=$withval, itcl_search=`cd ../../..; ls -d \`pwd\`/tcl8.0*/unix`)

TCL_LIB_DIR=""
for dir in $exec_prefix/lib $itcl_search ; do
    if test -r $dir/tclConfig.sh; then
        TCL_LIB_DIR=$dir
        break
    fi
done

if test -z "$TCL_LIB_DIR"; then
    AC_MSG_ERROR(Can't find Tcl libraries.  Use --with-tcl to specify the directory containing tclConfig.sh on your system.)
fi
. $TCL_LIB_DIR/tclConfig.sh

#--------------------------------------------------------------------
#   See if there was a command-line option for where Tk is;  if
#   not, search for Tk.
#--------------------------------------------------------------------

AC_ARG_WITH(tk, [  --with-tk=DIR           use Tk 8.0 binaries from DIR],
        itcl_search=$withval, itcl_search=`cd ../../..; ls -d \`pwd\`/tk8.0*/unix`)

TK_LIB_DIR=""
for dir in $exec_prefix/lib $TCL_LIB_DIR $itcl_search ; do
    if test -r $dir/tkConfig.sh; then
        TK_LIB_DIR=$dir
        break
    fi
done

if test -z "$TK_LIB_DIR"; then
    AC_MSG_ERROR(Can't find Tk libraries.  Use --with-tk to specify the directory containing tkConfig.sh on your system.)
fi
. $TK_LIB_DIR/tkConfig.sh

#--------------------------------------------------------------------
#   See if there was a command-line option for where Itcl is;  if
#   not, search for Itcl.
#--------------------------------------------------------------------

AC_ARG_WITH(itcl, [  --with-itcl=DIR         use Itcl 3.0 binaries from DIR],
        itcl_search=$withval, itcl_search=`cd ${BUILD_DIR}/../../itcl/unix; pwd`)

ITCL_LIB_DIR=""
for dir in $exec_prefix/lib $TCL_LIB_DIR $itcl_search ; do
    if test -r $dir/itclConfig.sh; then
        ITCL_LIB_DIR=$dir
        break
    fi
done

if test -z "$ITCL_LIB_DIR"; then
    AC_MSG_ERROR(Can't find Itcl libraries.  Use --with-itcl to specify the directory containing itclConfig.sh on your system.)
fi
. $ITCL_LIB_DIR/itclConfig.sh

#--------------------------------------------------------------------
#   See if there was a command-line option for where Itk is;  if
#   not, search for Itk.
#--------------------------------------------------------------------

AC_ARG_WITH(itk, [  --with-itk=DIR          use Itk 3.0 binaries from DIR],
        itcl_search=$withval, itcl_search=`cd ${BUILD_DIR}/../../itk/unix; pwd`)

ITK_LIB_DIR=""
for dir in $exec_prefix/lib $TCL_LIB_DIR $itcl_search ; do
    if test -r $dir/itkConfig.sh; then
        ITK_LIB_DIR=$dir
        break
    fi
done

if test -z "$ITK_LIB_DIR"; then
    AC_MSG_ERROR(Can't find Itk libraries.  Use --with-itk to specify the directory containing itkConfig.sh on your system.)
fi
. $ITK_LIB_DIR/itkConfig.sh

#--------------------------------------------------------------------
#   Fill in template files with the proper info.
#--------------------------------------------------------------------
AC_SUBST(BUILD_DIR)
AC_SUBST(TCL_LIB_DIR)
AC_SUBST(TCL_SRC_DIR)
AC_SUBST(TK_LIB_DIR)
AC_SUBST(TK_SRC_DIR)
AC_SUBST(ITCL_LIB_DIR)
AC_SUBST(ITCL_SRC_DIR)
AC_SUBST(ITK_LIB_DIR)
AC_SUBST(ITK_SRC_DIR)

AC_SUBST(ITCL_VERSION)
AC_SUBST(IWIDGETS_VERSION)
AC_SUBST(IWIDGETS_LIBRARY)
AC_SUBST(IWIDGETS_SRC_DIR)

AC_OUTPUT(Makefile)
