dnl Process this file with autoconf to produce a configure script.
AC_INIT(get_filename.c)
AC_PROG_CC
AC_PROG_RANLIB
AC_PROG_LN_S
AC_PROG_INSTALL
dnl Checks for header files.
AC_HEADER_DIRENT
#Contribution by VaX#n8 <vax@linkdead.paranoia.com>
AC_HEADER_STDC
AC_CHECK_HEADERS(fcntl.h sys/file.h sys/time.h unistd.h sys/select.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_TIME

dnl Checks for library functions.
AC_TYPE_SIGNAL
AC_FUNC_UTIME_NULL
#AC_CHECK_FUNCS(getcwd gethostname gettimeofday mkdir rmdir select socket strdup strftime strstr)

dnl Check for libraries
# fmod, logb, and frexp are found in -lm on most systems.
# On HPUX 9.01, -lm does not contain logb, so check for sqrt.
AC_CHECK_LIB(m, sqrt(0.0) + t)
#AC_CHECK_LIB(resolv, gethostbyname)
#AC_CHECK_LIB(nsl, gethostname, [LIBS="$LIBS -lnsl"])
#AC_CHECK_LIB(socket, setsockopt, [LIBS="$LIBS -lsocket"])
#Contribution by: Larry Schwimmer schwim@cyclone.stanford.edu
AC_CHECK_FUNC(connect, , ac_check_socket=1)
if test "$ac_check_socket" = 1; then
  AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", ac_check_both=1)
fi
if test "$ac_check_both" = 1; then
  ac_old_libs=$LIBS
  LIBS="$LIBS -lsocket -lnsl"
  AC_CHECK_FUNC(accept, checknsl=0, LIBS=$ac_old_libs)
fi
AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"]))

dnl Optional stuff
AC_ARG_ENABLE(structured-queries,, AC_DEFINE(STRUCTURED_QUERIES,0),AC_DEFINE(STRUCTURED_QUERIES,1))
AC_ARG_ENABLE(pointer,,, AC_DEFINE(AGREP_POINTER))
AC_ARG_ENABLE(measure-times,, AC_DEFINE(MEASURE_TIMES))

AC_OUTPUT(Makefile index/Makefile compress/Makefile agrep/Makefile libtemplate/Makefile libtemplate/util/Makefile libtemplate/template/Makefile libtemplate/include/autoconf.h)

