| 1 |
dnl Inspired by work Copyright (C) 2006 Luca Filipozzi |
| 2 |
dnl vim: set fdm=marker sw=2 ts=2 et si: |
| 3 |
dnl {{{ ax_check_lib_ipv4 |
| 4 |
AC_DEFUN([AX_CHECK_LIB_IPV4],[ |
| 5 |
AC_CHECK_FUNC(getaddrinfo, [], AC_SEARCH_LIBS(getaddrinfo, nsl)) |
| 6 |
AC_CHECK_FUNC(getnameinfo, [], AC_SEARCH_LIBS(getnameinfo, nsl)) |
| 7 |
AC_SEARCH_LIBS([socket],[socket],,[AC_MSG_ERROR([socket library not found])]) |
| 8 |
AC_CHECK_TYPES([struct sockaddr_in, struct sockaddr_storage, struct addrinfo],,,[#include <sys/types.h> |
| 9 |
#include <sys/socket.h> |
| 10 |
#include <netdb.h> |
| 11 |
]) |
| 12 |
AC_CHECK_MEMBERS([struct sockaddr_in.sin_len],,,[#include <sys/types.h> |
| 13 |
<sys/socket.h>]) |
| 14 |
])dnl }}} |
| 15 |
dnl {{{ ax_check_lib_ipv6 |
| 16 |
AC_DEFUN([AX_CHECK_LIB_IPV6],[ |
| 17 |
AC_CHECK_TYPE([struct sockaddr_in6],[AC_DEFINE([IPV6],[1],[Define to 1 if you have IPv6 support.])],,[#include <netinet/in.h>]) |
| 18 |
])dnl }}} |
| 19 |
dnl {{{ ax_arg_enable_ioloop_mechanism (FIXME) |
| 20 |
AC_DEFUN([AX_ARG_ENABLE_IOLOOP_MECHANISM],[ |
| 21 |
dnl {{{ allow the user to specify desired mechanism |
| 22 |
desired_iopoll_mechanism="none" |
| 23 |
dnl FIXME need to handle arguments a bit better (see ac_arg_disable_block_alloc) |
| 24 |
AC_ARG_ENABLE([kqueue], [AS_HELP_STRING([--enable-kqueue], [Force kqueue usage.])], [desired_iopoll_mechanism="kqueue"]) |
| 25 |
AC_ARG_ENABLE([epoll], [AS_HELP_STRING([--enable-epoll], [Force epoll usage.])], [desired_iopoll_mechanism="epoll"]) |
| 26 |
AC_ARG_ENABLE([devpoll],[AS_HELP_STRING([--enable-devpoll],[Force devpoll usage.])],[desired_iopoll_mechanism="devpoll"]) |
| 27 |
AC_ARG_ENABLE([poll], [AS_HELP_STRING([--enable-poll], [Force poll usage.])], [desired_iopoll_mechanism="poll"]) |
| 28 |
AC_ARG_ENABLE([select], [AS_HELP_STRING([--enable-select], [Force select usage.])], [desired_iopoll_mechanism="select"]) |
| 29 |
dnl }}} |
| 30 |
dnl {{{ preamble |
| 31 |
AC_MSG_CHECKING([for optimal/desired iopoll mechanism]) |
| 32 |
iopoll_mechanism_none=0 |
| 33 |
AC_DEFINE_UNQUOTED([__IOPOLL_MECHANISM_NONE],[$iopoll_mechanism_none],[no iopoll mechanism]) |
| 34 |
dnl }}} |
| 35 |
dnl {{{ check for kqueue mechanism support |
| 36 |
iopoll_mechanism_kqueue=1 |
| 37 |
AC_DEFINE_UNQUOTED([__IOPOLL_MECHANISM_KQUEUE],[$iopoll_mechanism_kqueue],[kqueue mechanism]) |
| 38 |
AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([kevent])],[is_kqueue_mechanism_available="yes"],[is_kqueue_mechanism_available="no"]) |
| 39 |
dnl }}} |
| 40 |
dnl {{{ check for epoll oechanism support |
| 41 |
iopoll_mechanism_epoll=2 |
| 42 |
AC_DEFINE_UNQUOTED([__IOPOLL_MECHANISM_EPOLL],[$iopoll_mechanism_epoll],[epoll mechanism]) |
| 43 |
AC_RUN_IFELSE([AC_LANG_PROGRAM([[ |
| 44 |
#include <sys/epoll.h> |
| 45 |
#include <sys/syscall.h> |
| 46 |
#if defined(__stub_epoll_create) || defined(__stub___epoll_create) || defined(EPOLL_NEED_BODY) |
| 47 |
#if !defined(__NR_epoll_create) |
| 48 |
#if defined(__ia64__) |
| 49 |
#define __NR_epoll_create 1243 |
| 50 |
#elif defined(__x86_64__) |
| 51 |
#define __NR_epoll_create 214 |
| 52 |
#elif defined(__sparc64__) || defined(__sparc__) |
| 53 |
#define __NR_epoll_create 193 |
| 54 |
#elif defined(__s390__) || defined(__m68k__) |
| 55 |
#define __NR_epoll_create 249 |
| 56 |
#elif defined(__ppc64__) || defined(__ppc__) |
| 57 |
#define __NR_epoll_create 236 |
| 58 |
#elif defined(__parisc__) || defined(__arm26__) || defined(__arm__) |
| 59 |
#define __NR_epoll_create 224 |
| 60 |
#elif defined(__alpha__) |
| 61 |
#define __NR_epoll_create 407 |
| 62 |
#elif defined(__sh64__) |
| 63 |
#define __NR_epoll_create 282 |
| 64 |
#elif defined(__i386__) || defined(__sh__) || defined(__m32r__) || defined(__h8300__) || defined(__frv__) |
| 65 |
#define __NR_epoll_create 254 |
| 66 |
#else |
| 67 |
#error No system call numbers defined for epoll family. |
| 68 |
#endif |
| 69 |
#endif |
| 70 |
_syscall1(int, epoll_create, int, size) |
| 71 |
#endif |
| 72 |
]], [[ return epoll_create(256) == -1 ? 1 : 0 ]])], |
| 73 |
[is_epoll_mechanism_available="yes"],[is_epoll_mechanism_available="no"]) |
| 74 |
dnl }}} |
| 75 |
dnl {{{ check for devpoll mechanism support |
| 76 |
iopoll_mechanism_devpoll=3 |
| 77 |
AC_DEFINE_UNQUOTED([__IOPOLL_MECHANISM_DEVPOLL],[$iopoll_mechanism_devpoll],[devpoll mechanism]) |
| 78 |
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <devpoll.h>])],[is_devpoll_mechanism_available="yes"],[is_devpoll_mechanism_available="no"]) |
| 79 |
if test "$is_devpoll_mechanism_available" = "yes" ; then |
| 80 |
AC_DEFINE([HAVE_DEVPOLL_H],[1],[Define to 1 if you have the <devpoll.h> header file.]) |
| 81 |
fi |
| 82 |
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/devpoll.h>])],[is_devpoll_mechanism_available="yes"],[is_devpoll_mechanism_available="no"]) |
| 83 |
if test "$is_devpoll_mechanism_available" = "yes" ; then |
| 84 |
AC_DEFINE([HAVE_SYS_DEVPOLL_H],[1],[Define to 1 if you have the <sys/devpoll.h> header file.]) |
| 85 |
fi |
| 86 |
dnl }}} |
| 87 |
dnl {{{ check for poll mechanism support |
| 88 |
iopoll_mechanism_poll=4 |
| 89 |
AC_DEFINE_UNQUOTED([__IOPOLL_MECHANISM_POLL],[$iopoll_mechanism_poll],[poll mechanism]) |
| 90 |
AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([poll])],[is_poll_mechanism_available="yes"],[is_poll_mechanism_available="no"]) |
| 91 |
dnl }}} |
| 92 |
dnl {{{ check for select mechanism support |
| 93 |
iopoll_mechanism_select=5 |
| 94 |
AC_DEFINE_UNQUOTED([__IOPOLL_MECHANISM_SELECT],[$iopoll_mechanism_select],[select mechanism]) |
| 95 |
AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([select])],[is_select_mechanism_available="yes"],[is_select_mechanism_available="no"]) |
| 96 |
dnl }}} |
| 97 |
dnl {{{ determine the optimal mechanism |
| 98 |
optimal_iopoll_mechanism="none" |
| 99 |
for mechanism in "kqueue" "epoll" "devpoll" "poll" "select" ; do # order is important |
| 100 |
eval "is_optimal_iopoll_mechanism_available=\$is_${mechanism}_mechanism_available" |
| 101 |
if test "$is_optimal_iopoll_mechanism_available" = "yes" ; then |
| 102 |
optimal_iopoll_mechanism="$mechanism" |
| 103 |
break |
| 104 |
fi |
| 105 |
done |
| 106 |
dnl }}} |
| 107 |
dnl {{{ select between optimal mechanism and desired mechanism (if specified) |
| 108 |
if test "$desired_iopoll_mechanism" = "none" ; then |
| 109 |
if test "$optimal_iopoll_mechanism" = "none" ; then |
| 110 |
AC_MSG_RESULT([none]) |
| 111 |
AC_MSG_ERROR([no iopoll mechanism found!]) |
| 112 |
else |
| 113 |
selected_iopoll_mechanism=$optimal_iopoll_mechanism |
| 114 |
AC_MSG_RESULT([$selected_iopoll_mechanism]) |
| 115 |
fi |
| 116 |
else |
| 117 |
eval "is_desired_iopoll_mechanism_available=\$is_${desired_iopoll_mechanism}_mechanism_available" |
| 118 |
if test "$is_desired_iopoll_mechanism_available" = "yes" ; then |
| 119 |
selected_iopoll_mechanism=$desired_iopoll_mechanism |
| 120 |
AC_MSG_RESULT([$selected_iopoll_mechanism]) |
| 121 |
else |
| 122 |
AC_MSG_RESULT([none]) |
| 123 |
AC_MSG_ERROR([desired iopoll mechanism, $desired_iopoll_mechanism, is not available]) |
| 124 |
fi |
| 125 |
fi |
| 126 |
dnl }}} |
| 127 |
dnl {{{ postamble |
| 128 |
eval "use_iopoll_mechanism=\$iopoll_mechanism_${selected_iopoll_mechanism}" |
| 129 |
AC_DEFINE_UNQUOTED([USE_IOPOLL_MECHANISM],[$use_iopoll_mechanism],[use this iopoll mechanism]) |
| 130 |
dnl }}} |
| 131 |
])dnl }}} |
| 132 |
dnl {{{ ax_arg_enable_halfops |
| 133 |
AC_DEFUN([AX_ARG_ENABLE_HALFOPS],[ |
| 134 |
AC_ARG_ENABLE([halfops],[AS_HELP_STRING([--enable-halfops],[Enable halfops support.])],[halfops="$enableval"],[halfops="no"]) |
| 135 |
if test "$halfops" = "yes" ; then |
| 136 |
AC_DEFINE([HALFOPS],[1],[Define to 1 if you want halfops support.]) |
| 137 |
fi |
| 138 |
])dnl }}} |
| 139 |
dnl {{{ ax_arg_enable_debugging |
| 140 |
AC_DEFUN([AX_ARG_ENABLE_DEBUGGING],[ |
| 141 |
AC_ARG_ENABLE([debugging],[AS_HELP_STRING([--enable-debugging],[Enable debugging.])],[debugging="$enableval"],[debugging="no"]) |
| 142 |
if test "$debugging" = "yes" ; then |
| 143 |
CFLAGS="-Wall -g -O0" |
| 144 |
fi |
| 145 |
])dnl }}} |
| 146 |
dnl {{{ ax_arg_enable_warnings |
| 147 |
AC_DEFUN([AX_ARG_ENABLE_WARNINGS],[ |
| 148 |
AC_ARG_ENABLE([warnings],[AS_HELP_STRING([--enable-warnings],[Enable compiler warnings.])],[warnings="$enableval"],[warnings="no"]) |
| 149 |
if test "$warnings" = "yes" ; then |
| 150 |
AX_APPEND_COMPILE_FLAGS([-Wall]) |
| 151 |
AX_APPEND_COMPILE_FLAGS([-Wextra]) |
| 152 |
AX_APPEND_COMPILE_FLAGS([-Wno-unused]) |
| 153 |
AX_APPEND_COMPILE_FLAGS([-Wcast-qual]) |
| 154 |
AX_APPEND_COMPILE_FLAGS([-Wcast-align]) |
| 155 |
AX_APPEND_COMPILE_FLAGS([-Wbad-function-cast]) |
| 156 |
AX_APPEND_COMPILE_FLAGS([-Wmissing-declarations]) |
| 157 |
AX_APPEND_COMPILE_FLAGS([-Wmissing-prototypes]) |
| 158 |
AX_APPEND_COMPILE_FLAGS([-Wnested-externs]) |
| 159 |
AX_APPEND_COMPILE_FLAGS([-Wredundant-decls]) |
| 160 |
AX_APPEND_COMPILE_FLAGS([-Wshadow]) |
| 161 |
AX_APPEND_COMPILE_FLAGS([-Wwrite-strings]) |
| 162 |
AX_APPEND_COMPILE_FLAGS([-Wundef]) |
| 163 |
fi |
| 164 |
])dnl }}} |
| 165 |
]) dnl }}} |