2004-05-09 Michael Poole <mdpoole@troilus.org>
[ircu2.10.12-pk.git] / configure.in
index 81bda6c283b9319c9d3aa8cd9d10bb8747d42dc8..35a68eff75c885731c7b797f1d7ec7d7968bf9e2 100644 (file)
@@ -113,7 +113,7 @@ AC_SEARCH_LIBS(res_mkquery, resolv, ,
 
 dnl Checks for header files.
 AC_HEADER_STDC
-AC_CHECK_HEADERS(poll.h sys/devpoll.h sys/event.h)
+AC_CHECK_HEADERS(poll.h sys/devpoll.h sys/epoll.h sys/event.h)
 
 dnl Checks for typedefs, structures, and compiler characteristics
 dnl AC_C_CONST
@@ -379,6 +379,32 @@ if test x"$unet_cv_enable_kqueue" != xno; then
     ENGINE_C="engine_kqueue.c $ENGINE_C"
 fi
 
+dnl --disable-epoll check
+AC_MSG_CHECKING([whether to enable the epoll event engine])
+AC_ARG_ENABLE([epoll],
+[  --disable-epoll         Disable the epoll-based engine],
+[unet_cv_enable_epoll=$enable_epoll],
+[AC_CACHE_VAL(unet_cv_enable_epoll,
+[unet_cv_enable_epoll=yes])])
+
+if test x"$ac_cv_header_sys_epoll_h" = xno -o x"$ac_cv_func_epoll" = xno; then
+    unet_cv_enable_epoll=no
+fi
+
+AC_MSG_RESULT([$unet_cv_enable_epoll])
+
+dnl If we have the header and user has not refused epoll, we still need
+dnl to check whether the functions are properly defined.
+if test x"$unet_cv_enable_epoll" != xno; then
+    AC_MSG_CHECKING([whether epoll functions are properly defined])
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <sys/epoll.h>], [epoll_create(10);])],
+        [AC_MSG_RESULT([yes])],
+        [AC_MSG_RESULT([no])
+         AC_DEFINE([EPOLL_NEED_BODY],,[Define to implement epoll system calls])])
+    AC_DEFINE([USE_EPOLL], , [Define to enable the epoll engine])
+    ENGINE_C="engine_epoll.c $ENGINE_C"
+fi
+
 dnl --disable-adns check...
 AC_MSG_CHECKING([whether to enable the adns resolver engine])
 AC_ARG_ENABLE([adns],