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
AC_CONFIG_SRCDIR([generic/buttonbox.itk])
# RCS: $Id: configure.in,v 1.5 2006/11/07 20:28:24 irby Exp $

#--------------------------------------------------------------------
# We should really cache the ITCL_VERSION when we configure itcl,
# and pick up the version from the cache here.
#--------------------------------------------------------------------

ITCL_VERSION=3.2
AC_SUBST(ITCL_VERSION)

PACKAGE=iwidgets
MAJOR_VERSION=2
MINOR_VERSION=2
PATCHLEVEL=.0

VERSION=${MAJOR_VERSION}.${MINOR_VERSION}${PATCHLEVEL}

AC_SUBST(PACKAGE)
AC_SUBST(VERSION)

AC_CONFIG_AUX_DIR(./config)
AC_PREREQ(2.59)

AC_PROG_INSTALL

case "`uname -s`" in
    *win32* | *WIN32* | *CYGWIN_NT*|*CYGWIN_98*|*CYGWIN_95*)
	CYGPATH="cygpath -w"
	RELPATH=".. .. bin"
    ;;
    *)
	CYGPATH=echo
	RELPATH=..
    ;;
esac

AC_SUBST(CYGPATH)
AC_SUBST(RELPATH)

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

SC_PATH_TCLCONFIG
SC_LOAD_TCLCONFIG

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

SC_PATH_TKCONFIG
SC_LOAD_TKCONFIG

#--------------------------------------------------------------------
#   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 ${srcdir}/../itcl; pwd`)

ITCL_LIB_DIR=""
for dir in $exec_prefix/lib $TCL_LIB_DIR $itcl_search ; do
    if test -r $dir/library/itcl.tcl; then
        ITCL_LIB_DIR=$dir
	ITCL_SRC_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 itcl.tcl on your system.)
fi

#--------------------------------------------------------------------
#   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],
        itk_search=$withval, itk_search=`cd ${srcdir}/../itk; pwd`)

ITK_LIB_DIR=""
for dir in $exec_prefix/lib $TCL_LIB_DIR $itk_search ; do
    if test -r $dir/library/itk.tcl; then
        ITK_LIB_DIR=$dir
        ITK_SRC_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 itk.tcl on your system.)
fi

#--------------------------------------------------------------------
#   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)

#--------------------------------------------------------------------
# A tcl shell is needed to run the test suite.
#--------------------------------------------------------------------

#SC_PROG_TCLSH

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

AC_CONFIG_FILES([Makefile \
	iwidgets.tcl \
	pkgIndex.tcl])
AC_OUTPUT
