ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-7.2/acinclude.m4
Revision: 948
Committed: Tue Jul 21 17:34:06 2009 UTC (14 years, 8 months ago) by michael
File size: 10860 byte(s)
Log Message:
- lp64\llp64\ilp32 portability fixes

File Contents

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