| 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_SEARCH_LIBS([socket],[socket],,[AC_MSG_ERROR([socket library not found])]) |
| 6 |
AC_SEARCH_LIBS([inet_ntoa], [nsl]) |
| 7 |
AC_SEARCH_LIBS([inet_aton], [resolv]) |
| 8 |
AC_CHECK_FUNCS([inet_aton inet_ntop inet_pton]) |
| 9 |
AC_CHECK_TYPES([struct sockaddr_in, struct sockaddr_storage, struct addrinfo],,,[#include <sys/types.h> |
| 10 |
#include <sys/socket.h> |
| 11 |
#include <netdb.h> |
| 12 |
]) |
| 13 |
AC_CHECK_MEMBERS([struct sockaddr_in.sin_len],,,[#include <sys/types.h> |
| 14 |
<sys/socket.h>]) |
| 15 |
])dnl }}} |
| 16 |
dnl {{{ ax_check_lib_ipv6 |
| 17 |
AC_DEFUN([AX_CHECK_LIB_IPV6],[ |
| 18 |
AC_CHECK_TYPE([struct sockaddr_in6],[AC_DEFINE([IPV6],[1],[Define to 1 if you have IPv6 support.])],,[#include <netinet/in.h>]) |
| 19 |
])dnl }}} |
| 20 |
dnl {{{ ax_arg_enable_ioloop_mechanism (FIXME) |
| 21 |
AC_DEFUN([AX_ARG_ENABLE_IOLOOP_MECHANISM],[ |
| 22 |
dnl {{{ allow the user to specify desired mechanism |
| 23 |
desired_iopoll_mechanism="none" |
| 24 |
dnl FIXME need to handle arguments a bit better (see ac_arg_disable_block_alloc) |
| 25 |
AC_ARG_ENABLE([kqueue], [AS_HELP_STRING([--enable-kqueue], [Force kqueue usage.])], [desired_iopoll_mechanism="kqueue"]) |
| 26 |
AC_ARG_ENABLE([epoll], [AS_HELP_STRING([--enable-epoll], [Force epoll usage.])], [desired_iopoll_mechanism="epoll"]) |
| 27 |
AC_ARG_ENABLE([devpoll],[AS_HELP_STRING([--enable-devpoll],[Force devpoll usage.])],[desired_iopoll_mechanism="devpoll"]) |
| 28 |
AC_ARG_ENABLE([rtsigio],[AS_HELP_STRING([--enable-rtsigio],[Force rtsigio usage.])],[desired_iopoll_mechanism="rtsigio"]) |
| 29 |
AC_ARG_ENABLE([poll], [AS_HELP_STRING([--enable-poll], [Force poll usage.])], [desired_iopoll_mechanism="poll"]) |
| 30 |
AC_ARG_ENABLE([select], [AS_HELP_STRING([--enable-select], [Force select usage.])], [desired_iopoll_mechanism="select"]) |
| 31 |
dnl }}} |
| 32 |
dnl {{{ preamble |
| 33 |
AC_MSG_CHECKING([for optimal/desired iopoll mechanism]) |
| 34 |
iopoll_mechanism_none=0 |
| 35 |
AC_DEFINE_UNQUOTED([__IOPOLL_MECHANISM_NONE],[$iopoll_mechanism_none],[no iopoll mechanism]) |
| 36 |
dnl }}} |
| 37 |
dnl {{{ check for kqueue mechanism support |
| 38 |
iopoll_mechanism_kqueue=1 |
| 39 |
AC_DEFINE_UNQUOTED([__IOPOLL_MECHANISM_KQUEUE],[$iopoll_mechanism_kqueue],[kqueue mechanism]) |
| 40 |
AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([kevent])],[is_kqueue_mechanism_available="yes"],[is_kqueue_mechanism_available="no"]) |
| 41 |
dnl }}} |
| 42 |
dnl {{{ check for epoll oechanism support |
| 43 |
iopoll_mechanism_epoll=2 |
| 44 |
AC_DEFINE_UNQUOTED([__IOPOLL_MECHANISM_EPOLL],[$iopoll_mechanism_epoll],[epoll mechanism]) |
| 45 |
AC_RUN_IFELSE([AC_LANG_PROGRAM([[ |
| 46 |
#include <sys/epoll.h> |
| 47 |
#include <sys/syscall.h> |
| 48 |
#if defined(__stub_epoll_create) || defined(__stub___epoll_create) || defined(EPOLL_NEED_BODY) |
| 49 |
#if !defined(__NR_epoll_create) |
| 50 |
#if defined(__ia64__) |
| 51 |
#define __NR_epoll_create 1243 |
| 52 |
#elif defined(__x86_64__) |
| 53 |
#define __NR_epoll_create 214 |
| 54 |
#elif defined(__sparc64__) || defined(__sparc__) |
| 55 |
#define __NR_epoll_create 193 |
| 56 |
#elif defined(__s390__) || defined(__m68k__) |
| 57 |
#define __NR_epoll_create 249 |
| 58 |
#elif defined(__ppc64__) || defined(__ppc__) |
| 59 |
#define __NR_epoll_create 236 |
| 60 |
#elif defined(__parisc__) || defined(__arm26__) || defined(__arm__) |
| 61 |
#define __NR_epoll_create 224 |
| 62 |
#elif defined(__alpha__) |
| 63 |
#define __NR_epoll_create 407 |
| 64 |
#elif defined(__sh64__) |
| 65 |
#define __NR_epoll_create 282 |
| 66 |
#elif defined(__i386__) || defined(__sh__) || defined(__m32r__) || defined(__h8300__) || defined(__frv__) |
| 67 |
#define __NR_epoll_create 254 |
| 68 |
#else |
| 69 |
#error No system call numbers defined for epoll family. |
| 70 |
#endif |
| 71 |
#endif |
| 72 |
_syscall1(int, epoll_create, int, size) |
| 73 |
#endif |
| 74 |
]], [[ return epoll_create(256) == -1 ? 1 : 0 ]])], |
| 75 |
[is_epoll_mechanism_available="yes"],[is_epoll_mechanism_available="no"]) |
| 76 |
dnl }}} |
| 77 |
dnl {{{ check for devpoll mechanism support |
| 78 |
iopoll_mechanism_devpoll=3 |
| 79 |
AC_DEFINE_UNQUOTED([__IOPOLL_MECHANISM_DEVPOLL],[$iopoll_mechanism_devpoll],[devpoll mechanism]) |
| 80 |
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <devpoll.h>])],[is_devpoll_mechanism_available="yes"],[is_devpoll_mechanism_available="no"]) |
| 81 |
if test "$is_devpoll_mechanism_available" = "yes" ; then |
| 82 |
AC_DEFINE([HAVE_DEVPOLL_H],[1],[Define to 1 if you have the <devpoll.h> header file.]) |
| 83 |
fi |
| 84 |
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/devpoll.h>])],[is_devpoll_mechanism_available="yes"],[is_devpoll_mechanism_available="no"]) |
| 85 |
if test "$is_devpoll_mechanism_available" = "yes" ; then |
| 86 |
AC_DEFINE([HAVE_SYS_DEVPOLL_H],[1],[Define to 1 if you have the <sys/devpoll.h> header file.]) |
| 87 |
fi |
| 88 |
dnl }}} |
| 89 |
dnl {{{ check for rtsigio mechanism support |
| 90 |
iopoll_mechanism_rtsigio=4 |
| 91 |
AC_DEFINE_UNQUOTED([__IOPOLL_MECHANISM_RTSIGIO],[$iopoll_mechanism_rtsigio],[rtsigio mechanism]) |
| 92 |
AC_RUN_IFELSE([AC_LANG_PROGRAM([[ |
| 93 |
#define _GNU_SOURCE |
| 94 |
#include <fcntl.h> |
| 95 |
static unsigned int have_f_setsig = 0; |
| 96 |
]], [[ |
| 97 |
#ifdef F_SETSIG |
| 98 |
have_f_setsig = 1; |
| 99 |
#endif |
| 100 |
return have_f_setsig == 0; |
| 101 |
]])], [is_rtsigio_mechanism_available="yes"],[is_rtsigio_mechanism_available="no"]) |
| 102 |
dnl }}} |
| 103 |
dnl {{{ check for poll mechanism support |
| 104 |
iopoll_mechanism_poll=5 |
| 105 |
AC_DEFINE_UNQUOTED([__IOPOLL_MECHANISM_POLL],[$iopoll_mechanism_poll],[poll mechanism]) |
| 106 |
AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([poll])],[is_poll_mechanism_available="yes"],[is_poll_mechanism_available="no"]) |
| 107 |
dnl }}} |
| 108 |
dnl {{{ check for select mechanism support |
| 109 |
iopoll_mechanism_select=6 |
| 110 |
AC_DEFINE_UNQUOTED([__IOPOLL_MECHANISM_SELECT],[$iopoll_mechanism_select],[select mechanism]) |
| 111 |
AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([select])],[is_select_mechanism_available="yes"],[is_select_mechanism_available="no"]) |
| 112 |
dnl }}} |
| 113 |
dnl {{{ determine the optimal mechanism |
| 114 |
optimal_iopoll_mechanism="none" |
| 115 |
for mechanism in "kqueue" "epoll" "devpoll" "rtsigio" "poll" "select" ; do # order is important |
| 116 |
eval "is_optimal_iopoll_mechanism_available=\$is_${mechanism}_mechanism_available" |
| 117 |
if test "$is_optimal_iopoll_mechanism_available" = "yes" ; then |
| 118 |
optimal_iopoll_mechanism="$mechanism" |
| 119 |
break |
| 120 |
fi |
| 121 |
done |
| 122 |
dnl }}} |
| 123 |
dnl {{{ select between optimal mechanism and desired mechanism (if specified) |
| 124 |
if test "$desired_iopoll_mechanism" = "none" ; then |
| 125 |
if test "$optimal_iopoll_mechanism" = "none" ; then |
| 126 |
AC_MSG_RESULT([none]) |
| 127 |
AC_MSG_ERROR([no iopoll mechanism found!]) |
| 128 |
else |
| 129 |
selected_iopoll_mechanism=$optimal_iopoll_mechanism |
| 130 |
AC_MSG_RESULT([$selected_iopoll_mechanism]) |
| 131 |
fi |
| 132 |
else |
| 133 |
eval "is_desired_iopoll_mechanism_available=\$is_${desired_iopoll_mechanism}_mechanism_available" |
| 134 |
if test "$is_desired_iopoll_mechanism_available" = "yes" ; then |
| 135 |
selected_iopoll_mechanism=$desired_iopoll_mechanism |
| 136 |
AC_MSG_RESULT([$selected_iopoll_mechanism]) |
| 137 |
else |
| 138 |
AC_MSG_RESULT([none]) |
| 139 |
AC_MSG_ERROR([desired iopoll mechanism, $desired_iopoll_mechanism, is not available]) |
| 140 |
fi |
| 141 |
fi |
| 142 |
dnl }}} |
| 143 |
dnl {{{ postamble |
| 144 |
eval "use_iopoll_mechanism=\$iopoll_mechanism_${selected_iopoll_mechanism}" |
| 145 |
AC_DEFINE_UNQUOTED([USE_IOPOLL_MECHANISM],[$use_iopoll_mechanism],[use this iopoll mechanism]) |
| 146 |
dnl }}} |
| 147 |
])dnl }}} |
| 148 |
dnl {{{ ax_arg_with_topiclen |
| 149 |
AC_DEFUN([AX_ARG_WITH_TOPICLEN],[ |
| 150 |
AC_ARG_WITH([topiclen],[AS_HELP_STRING([--with-topiclen=<value>],[Set topic length (default 160).])],[topiclen="$withval"],[topiclen="160"]) |
| 151 |
AC_DEFINE_UNQUOTED([TOPICLEN],[($topiclen)],[Length of topics.]) |
| 152 |
])dnl }}} |
| 153 |
dnl {{{ ax_arg_with_nicklen |
| 154 |
AC_DEFUN([AX_ARG_WITH_NICKLEN],[ |
| 155 |
AC_ARG_WITH([nicklen],[AS_HELP_STRING([--with-nicklen=<value>],[Set nickname length (default 9).])],[nicklen="$withval"],[nicklen="9"]) |
| 156 |
AC_DEFINE_UNQUOTED([NICKLEN],[($nicklen)],[Length of nicknames.]) |
| 157 |
])dnl }}} |
| 158 |
dnl {{{ ax_arg_enable_halfops |
| 159 |
AC_DEFUN([AX_ARG_ENABLE_HALFOPS],[ |
| 160 |
AC_ARG_ENABLE([halfops],[AS_HELP_STRING([--enable-halfops],[Enable halfops support.])],[halfops="$enableval"],[halfops="no"]) |
| 161 |
if test "$halfops" = "yes" ; then |
| 162 |
AC_DEFINE([HALFOPS],[1],[Define to 1 if you want halfops support.]) |
| 163 |
fi |
| 164 |
])dnl }}} |
| 165 |
dnl {{{ ax_arg_enable_debugging |
| 166 |
AC_DEFUN([AX_ARG_ENABLE_DEBUGGING],[ |
| 167 |
AC_ARG_ENABLE([debugging],[AS_HELP_STRING([--enable-debugging],[Enable debugging.])],[debugging="$enableval"],[debugging="no"]) |
| 168 |
if test "$debugging" = "yes" ; then |
| 169 |
CFLAGS="-Wall -g -O0" |
| 170 |
fi |
| 171 |
])dnl }}} |
| 172 |
dnl {{{ ax_arg_enable_warnings |
| 173 |
AC_DEFUN([AX_ARG_ENABLE_WARNINGS],[ |
| 174 |
AC_ARG_ENABLE([warnings],[AS_HELP_STRING([--enable-warnings],[Enable compiler warnings.])],[warnings="$enableval"],[warnings="no"]) |
| 175 |
if test "$warnings" = "yes" ; then |
| 176 |
CFLAGS="-Wall -Wextra -Wno-unused -Wcast-qual -Wcast-align -Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wredundant-decls -Wshadow -Wwrite-strings -Wundef" |
| 177 |
fi |
| 178 |
])dnl }}} |
| 179 |
dnl {{{ ac_define_dir |
| 180 |
dnl http://autoconf-archive.cryp.to/ac_define_dir.html |
| 181 |
AC_DEFUN([AC_DEFINE_DIR], [ |
| 182 |
prefix_NONE= |
| 183 |
exec_prefix_NONE= |
| 184 |
test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix |
| 185 |
test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix |
| 186 |
eval ac_define_dir="\"[$]$2\"" |
| 187 |
eval ac_define_dir="\"$ac_define_dir\"" |
| 188 |
AC_SUBST($1, "$ac_define_dir") |
| 189 |
AC_DEFINE_UNQUOTED($1, "$ac_define_dir", [$3]) |
| 190 |
test "$prefix_NONE" && prefix=NONE |
| 191 |
test "$exec_prefix_NONE" && exec_prefix=NONE |
| 192 |
])dnl }}} |
| 193 |
]) dnl }}} |