LIBS="${save_LIBS}"
AC_SUBST(CURSES_LIBS)
+# people tend to forget about curses until the build breaks
+if test "$ac_cv_search_initscr" = no; then
+ AC_MSG_ERROR([curses or ncurses is required])
+fi
+
save_LIBS="${LIBS}"
LIBS=""
AC_SEARCH_LIBS(pthread_create, [thr pthread c_r])
AC_CHECK_FUNCS([clock_gettime])
LIBS="${save_LIBS}"
-# Check which mechanism to use for the acceptor
-AC_CHECK_FUNCS([kqueue])
-AC_CHECK_FUNCS([epoll_ctl])
-AC_CHECK_FUNCS([poll])
+# Check which mechanism to use for the acceptor. We look for kqueue
+# only on platforms on which we know that it works, because there are
+# platforms where a simple AC_CHECK_FUNCS([kqueue]) would succeed but
+# the build would fail. We also allow the user to disable mechanisms
+# he doesn't want to use.
+
+# --enable-kqueue
+AC_ARG_ENABLE(kqueue,
+ AS_HELP_STRING([--enable-kqueue],
+ [use kqueue if available (default is YES)]),
+ ,
+ [enable_kqueue=yes])
+
+if test "$enable_kqueue" = yes; then
+ case $host in
+ *-*-freebsd*)
+ AC_CHECK_FUNCS([kqueue])
+ ;;
+ *-*-bsd*)
+ # No other BSD has a sufficiently recent implementation
+ AC_MSG_WARN([won't look for kqueue() on $host])
+ ac_cv_func_kqueue=no
+ ;;
+ esac
+else
+ ac_cv_func_kqueue=no
+fi
+
+# --enable-epoll
+AC_ARG_ENABLE(epoll,
+ AS_HELP_STRING([--enable-epoll],
+ [use epoll if available (default is YES)]),
+ ,
+ [enable_epoll=yes])
+
+if test "$enable_epoll" = yes; then
+ AC_CHECK_FUNCS([epoll_ctl])
+else
+ ac_cv_func_epoll_ctl=no
+fi
+
+# --enable-poll
+AC_ARG_ENABLE(poll,
+ AS_HELP_STRING([--enable-poll],
+ [use poll if available (default is YES)]),
+ ,
+ [enable_poll=yes])
+
+if test "$enable_poll" = yes; then
+ AC_CHECK_FUNCS([poll])
+else
+ ac_cv_func_poll=no
+fi
+
+if test "$ac_cv_func_kqueue" != yes &&
+ test "$ac_cv_func_epoll_ctl" != yes &&
+ test "$ac_cv_func_poll" != yes; then
+ AC_MSG_ERROR([no usable acceptor mechanism])
+fi
+
+# Solaris defines SO_{RCV,SND}TIMEO, but does not implement them.
+# Varnish will build and run without these, but connections will not
+# time out, which may leave Varnish vulnerable to denail-of-service
+# attacks which would not be possible on other platforms.
-# Solaris defines SO_{RCV,SND}TIMEO, but does not implement them
AC_CACHE_CHECK([whether SO_RCVTIMEO works],
[ac_cv_so_rcvtimeo_works],
[AC_RUN_IFELSE(
AC_DEFINE([SO_SNDTIMEO_WORKS], [1], [Define if SO_SNDTIMEO works])
fi
+if test "$ac_cv_so_rcvtimeo_works" = no ||
+ test "$ac_cv_so_sndtimeo_works" = no; then
+ AC_MSG_WARN([connection timeouts will not work])
+fi
+
# Run-time directory
VARNISH_STATE_DIR='${localstatedir}/varnish'
AC_SUBST(VARNISH_STATE_DIR)
# Additional flags for GCC 4
EXTRA_DEVELOPER_CFLAGS="-Wextra -Wno-missing-field-initializers -Wno-sign-compare"
+# --enable-developer-warnings
AC_ARG_ENABLE(developer-warnings,
AS_HELP_STRING([--enable-developer-warnings],[enable strict warnings (default is NO)]),
CFLAGS="${CFLAGS} ${DEVELOPER_CFLAGS}")
+
+# --enable-debugging-symbols
AC_ARG_ENABLE(debugging-symbols,
AS_HELP_STRING([--enable-debugging-symbols],[enable debugging symbols (default is NO)]),
CFLAGS="${CFLAGS} -O0 -g -fno-inline")
+
+# --enable-diagnostics
AC_ARG_ENABLE(diagnostics,
AS_HELP_STRING([--enable-diagnostics],[enable run-time diagnostics (default is NO)]),
CFLAGS="${CFLAGS} -DDIAGNOSTICS")
+
+# --enable-extra-developer-warnings
AC_ARG_ENABLE(extra-developer-warnings,
AS_HELP_STRING([--enable-extra-developer-warnings],[enable even stricter warnings (default is NO)]),
CFLAGS="${CFLAGS} ${EXTRA_DEVELOPER_CFLAGS}")
+
+# --enable-stack-protector
AC_ARG_ENABLE(stack-protector,
AS_HELP_STRING([--enable-stack-protector],[enable stack protector (default is NO)]),
CFLAGS="${CFLAGS} -fstack-protector-all")
+
+# --enable-werror
AC_ARG_ENABLE(werror,
AS_HELP_STRING([--enable-werror],[use -Werror (default is NO)]),
CFLAGS="${CFLAGS} -Werror")