dnl Process this file with autoconf to produce a configure script.
AC_INIT(find/pred.c)
AC_CONFIG_HEADER(config.h)

AC_SUBST(INCLUDES)dnl
AC_ARG_ENABLE(id-cache,
[  --enable-id-cache       cache all UIDs & GIDs; avoid if using NIS or Hesiod],
  AC_DEFINE(CACHE_IDS))
AC_ARG_WITH(afs,
[  --with-afs              support -fstype afs],
[  AC_DEFINE(AFS)
  CPPFLAGS="$CPPFLAGS -I/usr/afsws/include"
  LIBS="$LIBS -L/usr/afsws/lib -L/usr/afsws/lib/afs -lsys -lrx -llwp"])
AC_ARG_PROGRAM

dnl Checks for programs.
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_RANLIB
AC_PROG_MAKE_SET

dnl Try to get a POSIX.1 environment.
AC_AIX
AC_MINIX
AC_ISC_POSIX

dnl Checks for libraries.
AC_CHECK_LIB(sun, getpwnam)

dnl Checks for header files.
AC_CHECK_HEADERS(fcntl.h string.h limits.h unistd.h)
AC_HEADER_STDC
AC_HEADER_MAJOR
AC_HEADER_DIRENT
AC_HEADER_STAT
AC_HEADER_SYS_WAIT

AC_MSG_CHECKING(how to get filesystem type)
fstype=no
# The order of these tests is important.
AC_TRY_CPP([#include <sys/statvfs.h>
#include <sys/fstyp.h>], AC_DEFINE(FSTYPE_STATVFS) fstype=SVR4)
if test $fstype = no; then
AC_TRY_CPP([#include <sys/statfs.h>
#include <sys/fstyp.h>], AC_DEFINE(FSTYPE_USG_STATFS) fstype=SVR3)
fi
if test $fstype = no; then
AC_TRY_CPP([#include <sys/statfs.h>
#include <sys/vmount.h>], AC_DEFINE(FSTYPE_AIX_STATFS) fstype=AIX)
fi
if test $fstype = no; then  
AC_TRY_CPP([#include <mntent.h>], AC_DEFINE(FSTYPE_MNTENT) fstype=4.3BSD)
fi
if test $fstype = no; then  
AC_EGREP_HEADER(f_type;, sys/mount.h, AC_DEFINE(FSTYPE_STATFS) fstype=4.4BSD/OSF1)
fi
if test $fstype = no; then  
AC_TRY_CPP([#include <sys/mount.h>
#include <sys/fs_types.h>], AC_DEFINE(FSTYPE_GETMNT) fstype=Ultrix)
fi
AC_MSG_RESULT($fstype)

dnl Checks for typedefs, structures, and compiler characteristics.

AC_TYPE_UID_T
AC_TYPE_SIZE_T
AC_TYPE_PID_T
AC_CHECK_TYPE(ino_t, unsigned long)
AC_CHECK_TYPE(dev_t, unsigned long)
AC_STRUCT_ST_BLOCKS
AC_STRUCT_ST_RDEV
AC_STRUCT_TM
AC_STRUCT_TIMEZONE
AC_C_CONST

dnl Checks for library functions.

AC_REPLACE_FUNCS(memcmp memset mktime stpcpy strdup strftime strspn strstr strtol)
AC_CHECK_FUNCS(fchdir getcwd strerror)
AC_FUNC_STRFTIME
AC_FUNC_VPRINTF
AC_FUNC_ALLOCA
AC_FUNC_GETMNTENT
AC_FUNC_CLOSEDIR_VOID

AC_OUTPUT(Makefile lib/Makefile find/Makefile xargs/Makefile \
locate/Makefile doc/Makefile testsuite/Makefile,
  date > stamp-h)
