dnl Process this file with autoconf to produce a configure script.

AC_INIT(src/nap.c)
AM_INIT_AUTOMAKE(nap, 1.5.4)
DATE="November 2006"
AM_CONFIG_HEADER(config.h)

dnl Check for programs.
AC_PROG_CC
AC_PROG_INSTALL

dnl Check for libraries.
AC_CHECK_LIB(socket, gethostbyname)
AC_CHECK_LIB(dl, dlopen)

AC_CHECK_LIB(ncurses, initscr)
if test "$ac_cv_lib_ncurses_initscr" != yes; then
AC_MSG_ERROR(ncurses not found. See README.ncurses)
fi

AC_CHECK_LIB(socket, socket)
AC_CHECK_LIB(resolv, inet_aton)
AC_CHECK_LIB(nsl, connect)

dnl Check for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(ncurses.h)

dnl Check for library functions
AC_CHECK_FUNCS(memcpy)
AC_CHECK_FUNCS(hstrerror)
AC_CHECK_FUNCS(assume_default_colors)
AC_CHECK_FUNCS(vasprintf)
AC_CHECK_FUNCS(strcasestr)
AC_CHECK_FUNCS(strsep)

dnl Check for size of types [not currently used]
dnl AC_CHECK_SIZEOF(int, 4)

dnl Check for socklen_t in sys/socket.h
AC_MSG_CHECKING([for socklen_t])
AC_TRY_COMPILE(
	#include <sys/socket.h>
, socklen_t s, AC_DEFINE(HAVE_SOCKLEN_T, 1, Define if socklen_t is defined in sys/socket.h.) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_SUBST(EXTRA_OBJS)

AC_OUTPUT([Makefile src/Makefile doc/Makefile doc/nap.1])
