dnl Process this file with autoconf to produce a configure script.
AC_INIT(acconfig.h)

AC_CONFIG_HEADER(autoconfig.h)

CHESSD_CFLAGS=""

dnl Checks for programs.
AC_PROG_CC
AC_PROG_LN_S
AC_PROG_INSTALL

dnl Checks for libraries.
dnl Replace `main' with a function in -lm:
AC_CHECK_LIB(m, main)

dnl Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h strings.h sys/file.h sys/ioctl.h sys/md5.h sys/time.h unistd.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_STRUCT_TM

dnl we need dlopen() for 'areload'
AC_CHECK_FUNCS(dlopen)
if test x"$ac_cv_func_dlopen" = x"no"; then
    AC_CHECK_LIB(dl, dlopen, [LIBS="$LIBS -ldl";
	AC_DEFINE(HAVE_DLOPEN)])
fi

AC_CACHE_CHECK([for compar_fn_t in stdlib.h],ccache_cv_COMPAR_FN_T, [
    AC_TRY_COMPILE(
[#include <stdlib.h>],
[
void test_fn(void) { qsort(NULL, 0, 0, (__compar_fn_t)NULL); }
],
	ccache_cv_COMPAR_FN_T=yes,ccache_cv_COMPAR_FN_T=no)])
if test x"$ccache_cv_COMPAR_FN_T" = x"yes"; then
   AC_DEFINE(HAVE_COMPAR_FN_T, 1, [ ])
fi

dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_TYPE_SIGNAL
AC_FUNC_STRFTIME
AC_FUNC_VPRINTF
AC_FUNC_WAIT3
AC_CHECK_FUNCS(gethostname gettimeofday select socket strcspn strdup strstr dprintf)
AC_CHECK_FUNCS(strnlen strlcpy strlcat)

AC_SUBST(CHESSD_CFLAGS)

AC_OUTPUT(Makefile)
