AC_INIT()
AM_INIT_AUTOMAKE(tinyproxy,1.3.1)
AM_CONFIG_HEADER(src/defines.h)

dnl Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(fcntl.h sys/time.h syslog.h unistd.h)

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

dnl Checks for library functions.
AC_TYPE_SIGNAL
AC_FUNC_STRFTIME
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(socket select strerror strdup vsyslog vsnprintf)

dnl Check to see if the debuging code is turned on
AC_ARG_ENABLE(debug, \
  [--enable-debug          turn on additional debugging code], \
  CFLAGS="$CFLAGS -g", CFLAGS="$CFLAGS -DNDEBUG")

AC_ARG_ENABLE(socks, \
  [--enable-socks          enable SOCKS support], \
  AC_CHECK_HEADER(socks.h,
    [CFLAGS="$CFLAGS -I/usr/include/sock.h -DSOCKS"]
    AC_CHECK_LIB(socks, main, [LIBS="$LIBS -lsocks"])))

AC_ARG_ENABLE(xtinyproxy, \
  [--enable-xtinyproxy     enable the use of the XTinyproxy header], \
  AC_DEFINE(XTINYPROXY)
)

CFLAGS="-Wall -Wshadow -Wcast-qual -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wpointer-arith -Waggregate-return -Wnested-externs $CFLAGS"

AC_CHECK_LIB(nsl, gethostname, [LIBS="$LIBS -lnsl"])
AC_CHECK_LIB(socket, setsockopt, [LIBS="$LIBS -lsocket"])

AC_OUTPUT(Makefile src/Makefile doc/Makefile)
