1 |
stu |
908 |
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_CHECK_FUNCS([inet_aton inet_ntop inet_pton]) |
7 |
|
|
AC_CHECK_TYPES([struct sockaddr_in, struct sockaddr_storage, struct addrinfo],,,[#include <netdb.h>]) |
8 |
|
|
AC_CHECK_MEMBERS([struct sockaddr_in.sin_len],,,[#include <netdb.h>]) |
9 |
|
|
])dnl }}} |
10 |
|
|
dnl {{{ ax_check_lib_ipv6 |
11 |
|
|
AC_DEFUN([AX_CHECK_LIB_IPV6],[ |
12 |
|
|
AC_CHECK_TYPES([struct sockaddr_in6],,[AC_DEFINE([IPV6],[1],[Define to 1 if you have IPv6 support.])],,[#include <netdb.h>]) |
13 |
|
|
])dnl }}} |
14 |
|
|
dnl {{{ ax_arg_enable_ioloop_mechanism (FIXME) |
15 |
|
|
AC_DEFUN([AX_ARG_ENABLE_IOLOOP_MECHANISM],[ |
16 |
|
|
dnl {{{ allow the user to specify desired mechanism |
17 |
|
|
desired_iopoll_mechanism="none" |
18 |
|
|
dnl FIXME need to handle arguments a bit better (see ac_arg_disable_block_alloc) |
19 |
|
|
AC_ARG_ENABLE([kqueue], [AC_HELP_STRING([--enable-kqueue], [Force kqueue usage.])], [desired_iopoll_mechanism="kqueue"]) |
20 |
|
|
AC_ARG_ENABLE([epoll], [AC_HELP_STRING([--enable-epoll], [Force epoll usage.])], [desired_iopoll_mechanism="epoll"]) |
21 |
|
|
AC_ARG_ENABLE([devpoll],[AC_HELP_STRING([--enable-devpoll],[Force devpoll usage.])],[desired_iopoll_mechanism="devpoll"]) |
22 |
|
|
AC_ARG_ENABLE([rtsigio],[AC_HELP_STRING([--enable-rtsigio],[Force rtsigio usage.])],[desired_iopoll_mechanism="rtsigio"]) |
23 |
|
|
AC_ARG_ENABLE([poll], [AC_HELP_STRING([--enable-poll], [Force poll usage.])], [desired_iopoll_mechanism="poll"]) |
24 |
|
|
AC_ARG_ENABLE([select], [AC_HELP_STRING([--enable-select], [Force select usage.])], [desired_iopoll_mechanism="select"]) |
25 |
|
|
dnl }}} |
26 |
|
|
dnl {{{ preamble |
27 |
|
|
AC_MSG_CHECKING([for optimal/desired iopoll mechanism]) |
28 |
|
|
iopoll_mechanism_none=0 |
29 |
|
|
AC_DEFINE_UNQUOTED([__IOPOLL_MECHANISM_NONE],[$iopoll_mechanism_none],[no iopoll mechanism]) |
30 |
|
|
dnl }}} |
31 |
|
|
dnl {{{ check for kqueue mechanism support |
32 |
|
|
iopoll_mechanism_kqueue=1 |
33 |
|
|
AC_DEFINE_UNQUOTED([__IOPOLL_MECHANISM_KQUEUE],[$iopoll_mechanism_kqueue],[kqueue mechanism]) |
34 |
|
|
AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([kevent])],[is_kqueue_mechanism_available="yes"],[is_kqueue_mechanism_available="no"]) |
35 |
|
|
dnl }}} |
36 |
|
|
dnl {{{ check for epoll oechanism support |
37 |
|
|
iopoll_mechanism_epoll=2 |
38 |
|
|
AC_DEFINE_UNQUOTED([__IOPOLL_MECHANISM_EPOLL],[$iopoll_mechanism_epoll],[epoll mechanism]) |
39 |
|
|
AC_RUN_IFELSE([ |
40 |
|
|
#include <sys/epoll.h> |
41 |
|
|
#include <sys/syscall.h> |
42 |
|
|
#if defined(__stub_epoll_create) || defined(__stub___epoll_create) || defined(EPOLL_NEED_BODY) |
43 |
|
|
#if !defined(__NR_epoll_create) |
44 |
|
|
#if defined(__ia64__) |
45 |
|
|
#define __NR_epoll_create 1243 |
46 |
|
|
#elif defined(__x86_64__) |
47 |
|
|
#define __NR_epoll_create 214 |
48 |
|
|
#elif defined(__sparc64__) || defined(__sparc__) |
49 |
|
|
#define __NR_epoll_create 193 |
50 |
|
|
#elif defined(__s390__) || defined(__m68k__) |
51 |
|
|
#define __NR_epoll_create 249 |
52 |
|
|
#elif defined(__ppc64__) || defined(__ppc__) |
53 |
|
|
#define __NR_epoll_create 236 |
54 |
|
|
#elif defined(__parisc__) || defined(__arm26__) || defined(__arm__) |
55 |
|
|
#define __NR_epoll_create 224 |
56 |
|
|
#elif defined(__alpha__) |
57 |
|
|
#define __NR_epoll_create 407 |
58 |
|
|
#elif defined(__sh64__) |
59 |
|
|
#define __NR_epoll_create 282 |
60 |
|
|
#elif defined(__i386__) || defined(__sh__) || defined(__m32r__) || defined(__h8300__) || defined(__frv__) |
61 |
|
|
#define __NR_epoll_create 254 |
62 |
|
|
#else |
63 |
|
|
#error No system call numbers defined for epoll family. |
64 |
|
|
#endif |
65 |
|
|
#endif |
66 |
|
|
_syscall1(int, epoll_create, int, size) |
67 |
|
|
#endif |
68 |
|
|
main() { return epoll_create(256) == -1 ? 1 : 0; } |
69 |
|
|
],[is_epoll_mechanism_available="yes"],[is_epoll_mechanism_available="no"]) |
70 |
|
|
dnl }}} |
71 |
|
|
dnl {{{ check for devpoll mechanism support |
72 |
|
|
iopoll_mechanism_devpoll=3 |
73 |
|
|
AC_DEFINE_UNQUOTED([__IOPOLL_MECHANISM_DEVPOLL],[$iopoll_mechanism_devpoll],[devpoll mechanism]) |
74 |
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <devpoll.h>])],[is_devpoll_mechanism_available="yes"],[is_devpoll_mechanism_available="no"]) |
75 |
|
|
if test "$is_devpoll_mechanism_available" = "yes" ; then |
76 |
|
|
AC_DEFINE([HAVE_DEVPOLL_H],[1],[Define to 1 if you have the <devpoll.h> header file.]) |
77 |
|
|
fi |
78 |
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/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_SYS_DEVPOLL_H],[1],[Define to 1 if you have the <sys/devpoll.h> header file.]) |
81 |
|
|
fi |
82 |
|
|
dnl }}} |
83 |
|
|
dnl {{{ check for rtsigio mechanism support |
84 |
|
|
iopoll_mechanism_rtsigio=4 |
85 |
|
|
AC_DEFINE_UNQUOTED([__IOPOLL_MECHANISM_RTSIGIO],[$iopoll_mechanism_rtsigio],[rtsigio mechanism]) |
86 |
|
|
AC_RUN_IFELSE([AC_LANG_PROGRAM([ |
87 |
|
|
#include <fcntl.h> |
88 |
|
|
#ifdef F_SETSIG |
89 |
|
|
main () { return 0; } /* F_SETSIG defined */ |
90 |
|
|
#else |
91 |
|
|
main () { return 1; } /* F_SETSIG not defined */ |
92 |
|
|
#endif |
93 |
|
|
])],[is_rtsigio_mechanism_available="yes"],[is_rtsigio_mechanism_available="no"]) |
94 |
|
|
dnl }}} |
95 |
|
|
dnl {{{ check for poll mechanism support |
96 |
|
|
iopoll_mechanism_poll=5 |
97 |
|
|
AC_DEFINE_UNQUOTED([__IOPOLL_MECHANISM_POLL],[$iopoll_mechanism_poll],[poll mechanism]) |
98 |
|
|
AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([poll])],[is_poll_mechanism_available="yes"],[is_poll_mechanism_available="no"]) |
99 |
|
|
dnl }}} |
100 |
|
|
dnl {{{ check for select mechanism support |
101 |
|
|
iopoll_mechanism_select=6 |
102 |
|
|
AC_DEFINE_UNQUOTED([__IOPOLL_MECHANISM_SELECT],[$iopoll_mechanism_select],[select mechanism]) |
103 |
|
|
AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([select])],[is_select_mechanism_available="yes"],[is_select_mechanism_available="no"]) |
104 |
|
|
dnl }}} |
105 |
|
|
dnl {{{ determine the optimal mechanism |
106 |
|
|
optimal_iopoll_mechanism="none" |
107 |
|
|
for mechanism in "kqueue" "epoll" "devpoll" "rtsigio" "poll" "select" ; do # order is important |
108 |
|
|
eval "is_optimal_iopoll_mechanism_available=\$is_${mechanism}_mechanism_available" |
109 |
|
|
if test "$is_optimal_iopoll_mechanism_available" = "yes" ; then |
110 |
|
|
optimal_iopoll_mechanism="$mechanism" |
111 |
|
|
break |
112 |
|
|
fi |
113 |
|
|
done |
114 |
|
|
dnl }}} |
115 |
|
|
dnl {{{ select between optimal mechanism and desired mechanism (if specified) |
116 |
|
|
if test "$desired_iopoll_mechanism" = "none" ; then |
117 |
|
|
if test "$optimal_iopoll_mechanism" = "none" ; then |
118 |
|
|
AC_MSG_RESULT([none]) |
119 |
|
|
AC_MSG_ERROR([no iopoll mechanism found!]) |
120 |
|
|
else |
121 |
|
|
selected_iopoll_mechanism=$optimal_iopoll_mechanism |
122 |
|
|
AC_MSG_RESULT([$selected_iopoll_mechanism]) |
123 |
|
|
fi |
124 |
|
|
else |
125 |
|
|
eval "is_desired_iopoll_mechanism_available=\$is_${desired_iopoll_mechanism}_mechanism_available" |
126 |
|
|
if test "$is_desired_iopoll_mechanism_available" = "yes" ; then |
127 |
|
|
selected_iopoll_mechanism=$desired_iopoll_mechanism |
128 |
|
|
AC_MSG_RESULT([$selected_iopoll_mechanism]) |
129 |
|
|
else |
130 |
|
|
AC_MSG_RESULT([none]) |
131 |
|
|
AC_MSG_ERROR([desired iopoll mechanism, $desired_iopoll_mechanism, is not available]) |
132 |
|
|
fi |
133 |
|
|
fi |
134 |
|
|
dnl }}} |
135 |
|
|
dnl {{{ postamble |
136 |
|
|
eval "use_iopoll_mechanism=\$iopoll_mechanism_${selected_iopoll_mechanism}" |
137 |
|
|
AC_DEFINE_UNQUOTED([USE_IOPOLL_MECHANISM],[$use_iopoll_mechanism],[use this iopoll mechanism]) |
138 |
|
|
dnl }}} |
139 |
|
|
])dnl }}} |
140 |
|
|
dnl {{{ ax_arg_with_topiclen |
141 |
|
|
AC_DEFUN([AX_ARG_WITH_TOPICLEN],[ |
142 |
|
|
AC_ARG_WITH([topiclen],[AC_HELP_STRING([--with-topiclen=<value>],[Set topic length (default 160).])],[topiclen="$withval"],[topiclen="160"]) |
143 |
|
|
AC_DEFINE_UNQUOTED([TOPICLEN],[($topiclen+1)],[Length of topics.]) |
144 |
|
|
])dnl }}} |
145 |
|
|
dnl {{{ ax_arg_with_nicklen |
146 |
|
|
AC_DEFUN([AX_ARG_WITH_NICKLEN],[ |
147 |
|
|
AC_ARG_WITH([nicklen],[AC_HELP_STRING([--with-nicklen=<value>],[Set nickname length (default 9).])],[nicklen="$withval"],[nicklen="9"]) |
148 |
|
|
AC_DEFINE_UNQUOTED([NICKLEN],[($nicklen+1)],[Length of nicknames.]) |
149 |
|
|
])dnl }}} |
150 |
|
|
dnl {{{ ax_arg_with_lclient_heap_size |
151 |
|
|
AC_DEFUN([AX_ARG_WITH_LCLIENT_HEAP_SIZE],[ |
152 |
|
|
AC_ARG_WITH([lclient-heap-size],[AC_HELP_STRING([--lclient-heap-size=<value>],[Set local client heap size (default 256).])],[lclient_heap_size="$withval"],[lclient_heap_size="256"]) |
153 |
|
|
AC_DEFINE_UNQUOTED([LCLIENT_HEAP_SIZE],[$lclient_heap_size],[Size of the local client heap.]) |
154 |
|
|
])dnl }}} |
155 |
|
|
dnl {{{ ax_arg_with_nickname_history_length |
156 |
|
|
AC_DEFUN([AX_ARG_WITH_NICKNAME_HISTORY_LENGTH],[ |
157 |
|
|
AC_ARG_WITH([nickname-history-length],[AC_HELP_STRING([--nickname-history-length=<value>],[Set length of nickname history list (default 1500).])],[nickname_history_length="$withval"],[nickname_history_length="1500"]) |
158 |
|
|
AC_DEFINE_UNQUOTED([NICKNAMEHISTORYLENGTH],[$nickname_history_length],[Size of the nickname history list.]) |
159 |
|
|
])dnl }}} |
160 |
|
|
dnl {{{ ax_arg_with_client_heap_size |
161 |
|
|
AC_DEFUN([AX_ARG_WITH_CLIENT_HEAP_SIZE],[ |
162 |
|
|
AC_ARG_WITH([client-heap-size],[AC_HELP_STRING([--client-heap-size=<value>],[Set client heap size (default 256).])],[client_heap_size="$withval"],[client_heap_size="256"]) |
163 |
|
|
AC_DEFINE_UNQUOTED([CLIENT_HEAP_SIZE],[$client_heap_size],[Size of the client heap.]) |
164 |
|
|
])dnl }}} |
165 |
|
|
dnl {{{ ax_arg_with_channel_heap_size |
166 |
|
|
AC_DEFUN([AX_ARG_WITH_CHANNEL_HEAP_SIZE],[ |
167 |
|
|
AC_ARG_WITH([channel-heap-size],[AC_HELP_STRING([--channel-heap-size=<value>],[Set channel heap size (default 256).])],[channel_heap_size="$withval"],[channel_heap_size="256"]) |
168 |
|
|
AC_DEFINE_UNQUOTED([CHANNEL_HEAP_SIZE],[$channel_heap_size],[Size of the channel heap.]) |
169 |
|
|
])dnl }}} |
170 |
|
|
dnl {{{ ax_arg_with_dbuf_heap_size |
171 |
|
|
AC_DEFUN([AX_ARG_WITH_DBUF_HEAP_SIZE],[ |
172 |
|
|
AC_ARG_WITH([dbuf-heap-size],[AC_HELP_STRING([--dbuf-heap-size=<value>],[Set dbuf heap size (default 64).])],[dbuf_heap_size="$withval"],[dbuf_heap_size="64"]) |
173 |
|
|
AC_DEFINE_UNQUOTED([DBUF_HEAP_SIZE],[$dbuf_heap_size],[Size of the dbuf heap.]) |
174 |
|
|
])dnl }}} |
175 |
|
|
dnl {{{ ax_arg_with_dnode_heap_size |
176 |
|
|
AC_DEFUN([AX_ARG_WITH_DNODE_HEAP_SIZE],[ |
177 |
|
|
AC_ARG_WITH([dnode-heap-size],[AC_HELP_STRING([--dnode-heap-size=<value>],[Set dnode heap size (default 256).])],[dnode_heap_size="$withval"],[dnode_heap_size="256"]) |
178 |
|
|
AC_DEFINE_UNQUOTED([DNODE_HEAP_SIZE],[$dnode_heap_size],[Size of the dlink_node heap.]) |
179 |
|
|
])dnl }}} |
180 |
|
|
dnl {{{ ax_arg_with_ban_heap_size |
181 |
|
|
AC_DEFUN([AX_ARG_WITH_BAN_HEAP_SIZE],[ |
182 |
|
|
AC_ARG_WITH([ban-heap-size],[AC_HELP_STRING([--ban-heap-size=<value>],[Set ban heap size (default 128).])],[ban_heap_size="$withval"],[ban_heap_size="128"]) |
183 |
|
|
AC_DEFINE_UNQUOTED([BAN_HEAP_SIZE],[$ban_heap_size],[Size of the ban heap.]) |
184 |
|
|
])dnl }}} |
185 |
|
|
dnl {{{ ax_arg_with_topic_heap_size |
186 |
|
|
AC_DEFUN([AX_ARG_WITH_TOPIC_HEAP_SIZE],[ |
187 |
|
|
AC_ARG_WITH([topic-heap-size],[AC_HELP_STRING([--topic-heap-size=<value>],[Set topic heap size (default 256).])],[topic_heap_size="$withval"],[topic_heap_size="256"]) |
188 |
|
|
AC_DEFINE_UNQUOTED([TOPIC_HEAP_SIZE],[$topic_heap_size],[Size of the topic heap.]) |
189 |
|
|
])dnl }}} |
190 |
|
|
dnl {{{ ax_arg_enable_efnet |
191 |
|
|
AC_DEFUN([AX_ARG_ENABLE_EFNET],[ |
192 |
|
|
AC_ARG_ENABLE([efnet],[AC_HELP_STRING([--enable-efnet],[For IRCDs running on EFnet.])],[efnet="$enableval"],[efnet="no"]) |
193 |
|
|
if test "$efnet" = "yes" ; then |
194 |
|
|
use_efnet="yes" |
195 |
|
|
AC_DEFINE([EFNET],[1],[Define to 1 if this server will be an EFnet server.]) |
196 |
|
|
AC_DEFINE([TS5_ONLY],[1],[If Defined to 1 server links to your network must have a minimum of TS5.]) |
197 |
|
|
else |
198 |
|
|
AC_DEFINE([INVARIANTS],[1],[Miscellaneous sanity checks for the IRCd. Makes it slightly slower]) |
199 |
|
|
use_efnet="no" |
200 |
|
|
fi |
201 |
|
|
AM_CONDITIONAL([EFNET],[test "$use_efnet" = "yes"]) |
202 |
|
|
])dnl }}} |
203 |
|
|
dnl {{{ ax_arg_enable_halfops |
204 |
|
|
AC_DEFUN([AX_ARG_ENABLE_HALFOPS],[ |
205 |
|
|
AC_ARG_ENABLE([halfops],[AC_HELP_STRING([--enable-halfops],[Enable halfops support.])],[halfops="$enableval"],[halfops="no"]) |
206 |
|
|
if test "$halfops" = "yes" ; then |
207 |
|
|
AC_DEFINE([HALFOPS],[1],[Define to 1 if you want halfops support.]) |
208 |
|
|
fi |
209 |
|
|
])dnl }}} |
210 |
|
|
dnl {{{ ax_arg_enable_debugging |
211 |
|
|
AC_DEFUN([AX_ARG_ENABLE_DEBUGGING],[ |
212 |
|
|
AC_ARG_ENABLE([debugging],[AC_HELP_STRING([--enable-debugging],[Enable debugging.])],[debugging="$enableval"],[debugging="no"]) |
213 |
|
|
if test "$debugging" = "yes" ; then |
214 |
|
|
AC_DEFINE([DEBUG],[1],[Define to 1 to enable debugging.]) |
215 |
|
|
CFLAGS="$CFLAGS -Wall -Werror -g -O0" |
216 |
|
|
else |
217 |
|
|
AC_DEFINE([NDEBUG],[1],[Define to 1 to disable debugging.]) |
218 |
|
|
fi |
219 |
|
|
])dnl }}} |
220 |
|
|
dnl {{{ ax_arg_enable_warnings |
221 |
|
|
AC_DEFUN([AX_ARG_ENABLE_WARNINGS],[ |
222 |
|
|
AC_ARG_ENABLE([warnings],[AC_HELP_STRING([--enable-warnings],[Enable compiler warnings.])],[warnings="$enableval"],[warnings="no"]) |
223 |
|
|
if test "$warnings" = "yes" ; then |
224 |
|
|
CFLAGS="-Wcast-qual -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wredundant-decls -Wshadow -Wwrite-strings -Wno-unused" |
225 |
|
|
fi |
226 |
|
|
])dnl }}} |
227 |
|
|
dnl {{{ ax_arg_enable_syslog |
228 |
|
|
AC_DEFUN([AX_ARG_ENABLE_SYSLOG],[ |
229 |
|
|
AC_CHECK_HEADERS([syslog.h sys/syslog.h]) |
230 |
|
|
AC_ARG_ENABLE([syslog],[AC_HELP_STRING([--enable-syslog="EVENTS"],[Enable syslog for events: users oper (space separated in quotes; default: disabled).])],[syslog="$enableval"],[syslog="no"]) |
231 |
|
|
if test "$enableval" != "no" ; then |
232 |
|
|
for option in $enableval ; do |
233 |
|
|
case "$option" in |
234 |
|
|
users) AC_DEFINE([SYSLOG_USERS],[1],[Send user log stuff to syslog.]) ;; |
235 |
|
|
oper) AC_DEFINE([SYSLOG_OPER],[1],[Send oper log stuff to syslog.]) ;; |
236 |
|
|
yes) : ;; |
237 |
|
|
*) AC_MSG_ERROR([invalid value for --enable-syslog: $option]) ;; |
238 |
|
|
esac |
239 |
|
|
done |
240 |
|
|
AC_DEFINE([USE_SYSLOG],[1],[Define to 1 if you want to use syslog.]) |
241 |
|
|
fi |
242 |
|
|
])dnl }}} |
243 |
|
|
dnl {{{ ax_arg_with_syslog_facility |
244 |
|
|
AC_DEFUN([AX_ARG_WITH_SYSLOG],[ |
245 |
|
|
AC_ARG_WITH([syslog-facility],[AC_HELP_STRING([--with-syslog-facility=LOG],[Define the syslog facility to use (default: LOG_LOCAL4)])],[syslog_facility="$withval"],[syslog_facility="LOG_LOCAL4"]) |
246 |
|
|
AC_DEFINE_UNQUOTED([LOG_FACILITY],[$syslog_facility],[Set to syslog facility to use.]) |
247 |
|
|
])dnl }}} |
248 |
|
|
dnl {{{ ac_define_dir |
249 |
|
|
dnl http://autoconf-archive.cryp.to/ac_define_dir.html |
250 |
|
|
AC_DEFUN([AC_DEFINE_DIR], [ |
251 |
|
|
prefix_NONE= |
252 |
|
|
exec_prefix_NONE= |
253 |
|
|
test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix |
254 |
|
|
test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix |
255 |
|
|
eval ac_define_dir="\"[$]$2\"" |
256 |
|
|
eval ac_define_dir="\"$ac_define_dir\"" |
257 |
|
|
AC_SUBST($1, "$ac_define_dir") |
258 |
|
|
AC_DEFINE_UNQUOTED($1, "$ac_define_dir", [$3]) |
259 |
|
|
test "$prefix_NONE" && prefix=NONE |
260 |
|
|
test "$exec_prefix_NONE" && exec_prefix=NONE |
261 |
|
|
])dnl }}} |
262 |
|
|
]) dnl }}} |