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

dnl Checks for programs.
AC_PROG_CC

AM_INIT_AUTOMAKE(pgpool, 3.1.1)

AM_PROG_LEX

dnl Checks for libraries.
AC_CHECK_LIB(m,        main)
AC_CHECK_LIB(nsl,      main)
AC_CHECK_LIB(socket,   main)
AC_CHECK_LIB(ipc,      main)
AC_CHECK_LIB(IPC,      main)
AC_CHECK_LIB(lc,       main)
AC_CHECK_LIB(compat,   main)
AC_CHECK_LIB(BSD,      main)
AC_CHECK_LIB(gen,      main)
AC_CHECK_LIB(PW,       main)
AC_CHECK_LIB(resolv,   main)

dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h unistd.h getopt.h netinet/tcp.h netinet/in.h sys/param.h sys/types.h sys/time.h)

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

dnl Checks for library functions.
AC_TYPE_SIGNAL
AC_FUNC_VPRINTF
AC_FUNC_WAIT3
AC_CHECK_FUNCS(setsid select socket sigprocmask strdup strerror strftime strtok asprintf)

PGSQL_INCLUDE_DIR=/usr/local/pgsql/include
AC_ARG_WITH(pgsql,
    [  --with-pgsql=DIR     site header files for PostgreSQL in DIR],
    [
	case "$withval" in
	"" | y | ye | yes | n | no)
	    AC_MSG_ERROR([*** You must supply an argument to the --with-pgsql option.])
	  ;;
	esac
	PGSQL_INCLUDE_DIR="$withval"
    ])

AC_SUBST(PGSQL_INCLUDE_DIR)

AM_CONFIG_HEADER(config.h)

AC_OUTPUT(Makefile)
