define([AC_CACHE_LOAD], )dnl
define([AC_CACHE_SAVE], )dnl

dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/gs.erl)

if test -z "$ERL_TOP" || test ! -d $ERL_TOP ; then
  AC_MSG_ERROR(You need to set the environment variable ERL_TOP!)
fi
erl_top=${ERL_TOP}
AC_CONFIG_AUX_DIRS($erl_top/erts/autoconf)

dnl FIXME: Should be AC_CANONICAL_TARGET but we follow pattern in
dnl main configure.in.

if test "X$host" != "Xfree_source" -a "X$host" != "Xwin32"; then
    AC_CANONICAL_HOST
    system_type=${host_cpu}_`echo $host_os | sed 's/^\([[^\.]]*\)\.\(.*\)$/\1/'`
else
    system_type=$host
fi



dnl
dnl We try to find a prebuilt Tcl/Tk distribution that will later
dnl be unpacked into "priv/tcl". The 'gstk_port_handler' module
dnl seach for the "wish" program int this direcory first before
dnl searching the operating system executable search path.
dnl

AC_SUBST(TCL_TAR)

AC_MSG_CHECKING(for prebuilt tcl/tk in tcl/binaries/$system_type.tar.gz)
if test -f "tcl/binaries/$system_type.tar.gz" ; then
    TCL_TAR="binaries/$system_type.tar.gz"
    AC_MSG_RESULT(found)
else
    TCL_TAR=""
    AC_MSG_RESULT(not found, using PATH at runtime)
fi

AC_OUTPUT(
  tcl/$host/Makefile:tcl/Makefile.in
  tcl/win32/Makefile:tcl/Makefile.in
  )