1 dnl Process this file with autoconf to produce a configure script.
2 dnl rewritten for my own personal sanity, and for more extensive
3 dnl checks - feb04 -epi
7 AC_CONFIG_HEADER(include/setup.h)
9 PACKAGE=bahamut-release
14 # autoheader templates
16 AH_TEMPLATE([BROKEN_FD_SETSIZE],[If on a system with a broken FD_SETSIZE])
17 AH_TEMPLATE([HAVE_ENCRYPTION_ON],[If we support encryption])
18 AH_TEMPLATE([HAVE_MINMAX],[If we have the MIN and MAX macros])
19 AH_TEMPLATE([OS_SOLARIS2],[If we're running on Solaris])
20 AH_TEMPLATE([OS_SOLARIS],[Not quite sure why we have two of these])
21 AH_TEMPLATE([SYS_ERRLIST_DECLARED],[If the sys_errlist array is defined])
22 AH_TEMPLATE([USE_HOOKMODULES],[Do we support loadable modules])
23 AH_TEMPLATE([MAXCONNECTIONS],[Maximum Connections we allow])
24 AH_TEMPLATE([NEED_EPOLL_DEFS],[epoll behavior])
25 AH_TEMPLATE([AIX],[AIX support])
26 AH_TEMPLATE([WRITEV_IOV],[Maxmimum number of iovecs supported by writev()])
28 dnl Put our options of here for ease of reading.
30 AC_ARG_ENABLE(hookmodules,
31 [ --disable-hookmodules disable support for loadable hook modules],,
32 [ check_hmodules="yes" ])
34 AC_ARG_ENABLE(openssl,
35 [ --enable-openssl[=DIR] Enable OpenSSL support (DIR optional).
36 --disable-openssl Disable OpenSSL support. ],
37 [ cf_enable_openssl=$enableval ],
38 [ cf_enable_openssl="auto" ])
40 AC_ARG_WITH(socketengine,
41 [ --with-socketengine=TYPE Set the socketengine type. Choices are:
43 [ check_sengine=$withval ],
44 [ check_sengine="yes" ])
45 AC_ARG_WITH(maxconnections,
46 [ --with-maxconnections=NUMBER Set the maximum number of sockets.],
47 [ check_maxconnections=$withval ],
48 [ check_maxconnections="auto" ])
50 dnl -------------------------------------------------------------------
51 # ===========================================================================
52 # http://www.gnu.org/software/autoconf-archive/ax_cflags_warn_all.html
53 # ===========================================================================
57 # AX_CFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])]
61 # Try to find a compiler option that enables most reasonable warnings.
63 # For the GNU CC compiler it will be -Wall (and -ansi -pedantic) The
64 # result is added to the shellvar being CFLAGS by default.
66 # Currently this macro knows about GCC, Solaris C compiler, Digital Unix C
67 # compiler, C for AIX Compiler, HP-UX C compiler, IRIX C compiler, NEC
68 # SX-5 (Super-UX 10) C compiler, and Cray J90 (Unicos 10.0.0.8) C
71 # - $1 shell-variable-to-add-to : CFLAGS
72 # - $2 add-value-if-not-found : nothing
73 # - $3 action-if-found : add value to shellvariable
74 # - $4 action-if-not-found : nothing
78 # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
80 # This program is free software; you can redistribute it and/or modify it
81 # under the terms of the GNU General Public License as published by the
82 # Free Software Foundation; either version 2 of the License, or (at your
83 # option) any later version.
85 # This program is distributed in the hope that it will be useful, but
86 # WITHOUT ANY WARRANTY; without even the implied warranty of
87 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
88 # Public License for more details.
90 # You should have received a copy of the GNU General Public License along
91 # with this program. If not, see <http://www.gnu.org/licenses/>.
93 # As a special exception, the respective Autoconf Macro's copyright owner
94 # gives unlimited permission to copy, distribute and modify the configure
95 # scripts that are the output of Autoconf when processing the Macro. You
96 # need not follow the terms of the GNU General Public License when using
97 # or distributing such scripts, even though portions of the text of the
98 # Macro appear in them. The GNU General Public License (GPL) does govern
99 # all other use of the material that constitutes the Autoconf Macro.
101 # This special exception to the GPL applies to versions of the Autoconf
102 # Macro released by the Autoconf Archive. When you make and distribute a
103 # modified version of the Autoconf Macro, you may extend this special
104 # exception to the GPL to apply to your modified version as well.
106 AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl
107 AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
108 AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_warn_all])dnl
109 AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings],
110 VAR,[VAR="no, unknown"
112 ac_save_[]FLAGS="$[]FLAGS"
114 in "-pedantic % -Wall" dnl GCC
115 "-xstrconst % -v" dnl Solaris C
116 "-std1 % -verbose -w0 -warnprotos" dnl Digital Unix
117 "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX
118 "-ansi -ansiE % -fullwarn" dnl IRIX
119 "+ESlit % +w1" dnl HP-UX C
120 "-Xc % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10)
121 "-h conform % -h msglevel 2" dnl Cray C (Unicos)
123 do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
124 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[return 0;]])],[VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break],[])
126 FLAGS="$ac_save_[]FLAGS"
130 .ok|.ok,*) m4_ifvaln($3,$3) ;;
131 .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[
132 AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])
133 m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;;
135 if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
136 then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
137 else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
138 m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
141 AS_VAR_POPDEF([VAR])dnl
142 AS_VAR_POPDEF([FLAGS])dnl
145 dnl the only difference - the LANG selection... and the default FLAGS
147 AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl
148 AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
149 AS_VAR_PUSHDEF([VAR],[ax_cv_cxxflags_warn_all])dnl
150 AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings],
151 VAR,[VAR="no, unknown"
153 ac_save_[]FLAGS="$[]FLAGS"
155 in "-pedantic % -Wall" dnl GCC
156 "-xstrconst % -v" dnl Solaris C
157 "-std1 % -verbose -w0 -warnprotos" dnl Digital Unix
158 "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX
159 "-ansi -ansiE % -fullwarn" dnl IRIX
160 "+ESlit % +w1" dnl HP-UX C
161 "-Xc % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10)
162 "-h conform % -h msglevel 2" dnl Cray C (Unicos)
164 do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
165 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[return 0;]])],[VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break],[])
167 FLAGS="$ac_save_[]FLAGS"
171 .ok|.ok,*) m4_ifvaln($3,$3) ;;
172 .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[
173 AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])
174 m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;;
176 if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
177 then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
178 else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
179 m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
182 AS_VAR_POPDEF([VAR])dnl
183 AS_VAR_POPDEF([FLAGS])dnl
186 dnl implementation tactics:
187 dnl the for-argument contains a list of options. The first part of
188 dnl these does only exist to detect the compiler - usually it is
189 dnl a global option to enable -ansi or -extrawarnings. All other
190 dnl compilers will fail about it. That was needed since a lot of
191 dnl compilers will give false positives for some option-syntax
192 dnl like -Woption or -Xoption as they think of it is a pass-through
193 dnl to later compile stages or something. The "%" is used as a
194 dnl delimimiter. A non-option comment can be given after "%%" marks
195 dnl which will be shown but not added to the respective C/CXXFLAGS.
197 dnl -------------------------------------------------------------------
199 # ===========================================================================
200 # https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
201 # ===========================================================================
205 # AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
209 # Check whether the given FLAG works with the current language's compiler
210 # or gives an error. (Warnings, however, are ignored)
212 # ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
215 # If EXTRA-FLAGS is defined, it is added to the current language's default
216 # flags (e.g. CFLAGS) when the check is done. The check is thus made with
217 # the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
218 # force the compiler to issue an error when a bad flag is given.
220 # INPUT gives an alternative input source to AC_COMPILE_IFELSE.
222 # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
223 # macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
227 # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
228 # Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
230 # Copying and distribution of this file, with or without modification, are
231 # permitted in any medium without royalty provided the copyright notice
232 # and this notice are preserved. This file is offered as-is, without any
235 AC_DEFUN([AX_CHECK_COMPILE_FLAG],
236 [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
237 AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
238 AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
239 ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
240 _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
241 AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
242 [AS_VAR_SET(CACHEVAR,[yes])],
243 [AS_VAR_SET(CACHEVAR,[no])])
244 _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
245 AS_VAR_IF(CACHEVAR,yes,
246 [m4_default([$2], :)],
247 [m4_default([$3], :)])
248 AS_VAR_POPDEF([CACHEVAR])dnl
249 ])dnl AX_CHECK_COMPILE_FLAGS
251 dnl -------------------------------------------------------------------
253 # ===========================================================================
254 # http://www.gnu.org/software/autoconf-archive/ax_have_epoll.html
255 # ===========================================================================
259 # AX_HAVE_EPOLL([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
260 # AX_HAVE_EPOLL_PWAIT([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
264 # This macro determines whether the system supports the epoll I/O event
265 # interface. A neat usage example would be:
268 # [AX_CONFIG_FEATURE_ENABLE(epoll)],
269 # [AX_CONFIG_FEATURE_DISABLE(epoll)])
271 # [epoll], [This platform supports epoll(7)],
272 # [HAVE_EPOLL], [This platform supports epoll(7).])
274 # The epoll interface was added to the Linux kernel in version 2.5.45, and
275 # the macro verifies that a kernel newer than this is installed. This
276 # check is somewhat unreliable if <linux/version.h> doesn't match the
277 # running kernel, but it is necessary regardless, because glibc comes with
278 # stubs for the epoll_create(), epoll_wait(), etc. that allow programs to
279 # compile and link even if the kernel is too old; the problem would then
280 # be detected only at runtime.
282 # Linux kernel version 2.6.19 adds the epoll_pwait() call in addition to
283 # epoll_wait(). The availability of that function can be tested with the
284 # second macro. Generally speaking, it is safe to assume that
285 # AX_HAVE_EPOLL would succeed if AX_HAVE_EPOLL_PWAIT has, but not the
290 # Copyright (c) 2008 Peter Simons <simons@cryp.to>
292 # Copying and distribution of this file, with or without modification, are
293 # permitted in any medium without royalty provided the copyright notice
294 # and this notice are preserved. This file is offered as-is, without any
297 AC_DEFUN([AX_HAVE_EPOLL], [dnl
298 ax_have_epoll_cppflags="${CPPFLAGS}"
299 AC_CHECK_HEADER([linux/version.h], [CPPFLAGS="${CPPFLAGS} -DHAVE_LINUX_VERSION_H"])
300 AC_MSG_CHECKING([for Linux epoll(7) interface])
301 AC_CACHE_VAL([ax_cv_have_epoll], [dnl
304 #include <sys/epoll.h>
305 #ifdef HAVE_LINUX_VERSION_H
306 # include <linux/version.h>
307 # if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,45)
308 # error linux kernel version is too old to have epoll
313 struct epoll_event ev;
314 fd = epoll_create(128);
315 rc = epoll_wait(fd, &ev, 1, 0);])],
316 [ax_cv_have_epoll=yes],
317 [ax_cv_have_epoll=no])])
318 CPPFLAGS="${ax_have_epoll_cppflags}"
319 AS_IF([test "${ax_cv_have_epoll}" = "yes"],
320 [AC_MSG_RESULT([yes])
321 $1],[AC_MSG_RESULT([no])
325 AC_DEFUN([AX_HAVE_EPOLL_PWAIT], [dnl
326 ax_have_epoll_cppflags="${CPPFLAGS}"
327 AC_CHECK_HEADER([linux/version.h],
328 [CPPFLAGS="${CPPFLAGS} -DHAVE_LINUX_VERSION_H"])
329 AC_MSG_CHECKING([for Linux epoll(7) interface with signals extension])
330 AC_CACHE_VAL([ax_cv_have_epoll_pwait], [dnl
333 #ifdef HAVE_LINUX_VERSION_H
334 # include <linux/version.h>
335 # if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
336 # error linux kernel version is too old to have epoll_pwait
339 #include <sys/epoll.h>
343 struct epoll_event ev;
344 fd = epoll_create(128);
345 rc = epoll_wait(fd, &ev, 1, 0);
346 rc = epoll_pwait(fd, &ev, 1, 0, (sigset_t const *)(0));])],
347 [ax_cv_have_epoll_pwait=yes],
348 [ax_cv_have_epoll_pwait=no])])
349 CPPFLAGS="${ax_have_epoll_cppflags}"
350 AS_IF([test "${ax_cv_have_epoll_pwait}" = "yes"],
351 [AC_MSG_RESULT([yes])
352 $1],[AC_MSG_RESULT([no])
357 dnl -------------------------------------------------
359 dnl Checks for programs.
362 AX_CHECK_COMPILE_FLAG([-fno-strict-aliasing], [CFLAGS="$CFLAGS -fno-strict-aliasing"])
363 AX_CHECK_COMPILE_FLAG([-fgnu89-inline], [CFLAGS="$CFLAGS -fgnu89-inline"])
365 AC_SEARCH_LIBS([strerror],[cposix])
370 AC_PATH_PROG(SED, sed)
374 dnl Checks for libraries.
375 dnl Replace `main' with a function in -lnsl:
376 AC_CHECK_LIB(nsl, gethostbyname)
377 AC_CHECK_FUNC(res_mkquery,, AC_CHECK_LIB(resolv, res_mkquery))
378 AC_CHECK_FUNC(__res_mkquery,, AC_CHECK_LIB(resolv, __res_mkquery))
379 AC_CHECK_LIB(socket, socket, zlib)
380 AC_CHECK_FUNC(crypt,, AC_CHECK_LIB(descrypt, crypt,,AC_CHECK_LIB(crypt, crypt,,)))
382 dnl Checks for header files.
384 AC_CHECK_HEADERS([fcntl.h limits.h malloc.h netdb.h netinet/in.h stddef.h])
385 AC_CHECK_HEADERS([stdlib.h string.h strings.h sys/file.h sys/ioctl.h])
386 AC_CHECK_HEADERS([sys/param.h sys/socket.h sys/time.h syslog.h unistd.h])
387 AC_CHECK_HEADERS([zlib.h])
388 AC_CHECK_HEADERS(inttypes.h sys/resource.h errno.h stdlib.h stddef.h getopt.h)
389 AC_MSG_CHECKING(MIN and MAX definition)
392 #if defined( HAVE_SYS_PARAM_H )
393 #include <sys/param.h>
398 ], AC_DEFINE(HAVE_MINMAX) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
401 dnl Checks for library functions.
402 AC_PROG_GCC_TRADITIONAL
403 AC_CHECK_FUNCS([alarm dup2 gethostbyname gethostname getpass gettimeofday])
404 AC_CHECK_FUNCS([inet_ntoa isascii memmove memset munmap setenv socket])
405 AC_CHECK_FUNCS([strcasecmp strchr strdup strerror strncasecmp strrchr strtol])
406 AC_CHECK_FUNCS([strtoul index strerror strtoken strtok inet_addr inet_netof])
407 AC_CHECK_FUNCS([inet_aton gettimeofday lrand48 sigaction bzero bcmp bcopy])
408 AC_CHECK_FUNCS([dn_skipname __dn_skipname getrusage times break])
410 dnl check for various OSes
415 AC_DEFINE(OS_SOLARIS2)
416 AC_DEFINE(OS_SOLARIS)
417 AC_DEFINE_UNQUOTED(WRITEV_IOV, 16)
421 AC_DEFINE_UNQUOTED(WRITEV_IOV, 32)
424 AC_DEFINE_UNQUOTED(WRITEV_IOV, 32)
427 AC_DEFINE_UNQUOTED(WRITEV_IOV, 32)
431 AC_DEFINE_UNQUOTED(WRITEV_IOV, 32)
439 AC_DEFINE_UNQUOTED(WRITEV_IOV, 32)
443 dnl Checks for loadable hook module support
445 set_hmodules="disabled"
447 if test "$check_hmodules" = "yes"; then
448 AC_CHECK_LIB(dl, dlopen)
449 AC_CHECK_HEADER(dlfcn.h)
450 AC_CHECK_FUNCS(dlopen dlsym, [set_hmodules="enabled"])
451 if test "$set_hmodules" = "enabled"; then
452 AC_DEFINE(USE_HOOKMODULES)
453 MOD_LDFLAGS="-Wl,-export-dynamic"
457 dnl Check for sys_errlist
458 dnl Stolen from BitchX
459 AC_MSG_CHECKING(for sys_errlist declaration)
460 AC_RUN_IFELSE([AC_LANG_SOURCE([[
461 #include <sys/types.h>
466 char *s = sys_errlist[0];
469 ]])],[AC_MSG_RESULT(yes)
470 AC_DEFINE(SYS_ERRLIST_DECLARED)],[AC_MSG_RESULT(no)],[AC_MSG_RESULT(cross compiling)])
472 dnl Openssl checks - combination of our old way and the hybrid7 method
476 AC_MSG_CHECKING(for OpenSSL)
478 if test "X$cf_enable_openssl" != "Xno" ; then
479 cf_openssl_basedir=""
480 if test "X$cf_enable_openssl" != "Xauto" &&
481 test "X$cf_enable_openssl" != "Xyes"; then
482 dnl Support for --enable-openssl=/some/place
483 cf_openssl_basedir="${cf_enable_openssl}"
485 dnl Do the auto-probe here. Check some common directory paths.
486 for dirs in $HOME/openssl /usr/local/ssl /usr/pkg /usr/local /usr/lib /usr/lib/ssl\
487 /opt /opt/openssl /usr/local/openssl ; do
488 if test -f "${dirs}/include/openssl/opensslv.h" ; then
489 cf_openssl_basedir="${dirs}"
495 dnl Now check cf_openssl_found to see if we found anything.
496 if test "X$cf_openssl_basedir" != "X" ; then
497 if test -f "${cf_openssl_basedir}/include/openssl/opensslv.h" ; then
498 SSL_INCLUDES="-I${cf_openssl_basedir}/include"
499 SSL_LDFLAGS="-L${cf_openssl_basedir}/lib"
500 if test "$cf_openssl_basedir" = "$HOME/openssl"; then
501 SSL_LDFLAGS="-L${cf_openssl_basedir}/lib -Wl,-rpath,${cf_openssl_basedir}/lib"
504 dnl OpenSSL wasn't found in the directory specified. Naughty
506 cf_openssl_basedir=""
509 dnl Check for stock FreeBSD 4.x and 5.x systems, since their files
510 dnl are in /usr/include and /usr/lib. In this case, we don't want to
511 dnl change INCLUDES or LIBS, but still want to enable OpenSSL.
512 dnl We can't do this check above, because some people want two versions
513 dnl of OpenSSL installed (stock FreeBSD 4.x/5.x and /usr/local/ssl)
514 dnl and they want /usr/local/ssl to have preference.
515 if test -f "/usr/include/openssl/opensslv.h" ; then
516 cf_openssl_basedir="/usr"
519 dnl If we have a basedir defined, then everything is okay. Otherwise,
520 dnl we have a problem.
521 if test "X$cf_openssl_basedir" != "X" ; then
522 CPPFLAGS="$CPPFLAGS $SSL_INCLUDES"
523 LDFLAGS="$LDFLAGS $SSL_LDFLAGS"
524 LIBS="-lssl -lcrypto $save_LIBS"
525 AC_MSG_RESULT($cf_openssl_basedir)
526 cf_enable_openssl="yes"
528 AC_DEFINE(HAVE_ENCRYPTION_ON)
529 ENCRYPT_SRC="rc4.c dh.c libcrypto-compat.c"
530 AC_SUBST(ENCRYPT_SRC)
532 AC_MSG_RESULT(not found. Please check your path.)
533 cf_enable_openssl="no"
534 encryption="disabled"
536 unset cf_openssl_basedir
538 dnl If --disable-openssl was specified
539 encryption="disabled"
540 AC_MSG_RESULT(disabled)
545 dnl end of openssl library test
547 dnl select a socket engine
549 if test "$check_sengine" = "yes"; then
551 if test "$freebsd" = "yes"; then
552 AC_CHECK_FUNC(kevent, [ engine="kqueue" ], )
553 elif test "$solaris2" = "yes"; then
555 AC_CHECK_HEADER(sys/devpoll.h, engine="devpoll", )
556 elif test "$linux" = "yes"; then
557 AC_CHECK_FUNC(poll, [ engine="poll" ], )
558 AX_HAVE_EPOLL([ engine="epoll" ], )
559 AC_CHECK_HEADER(sys/epoll.h, HAVE_EPOLL_H=yes, HAVE_EPOLL_H=no)
560 # AC_CHECK_LIB(epoll, epoll_create,
561 # [LIBS="$LIBS -lepoll"; have_epoll_lib="yes"; engine="epoll"],
562 # have_epoll_lib="no")
563 # if test "$HAVE_EPOLL_H $have_epoll_lib" = "yes no"; then
564 # AC_MSG_CHECKING(for epoll_create [without -lepoll])
565 # AC_RUN_IFELSE([AC_LANG_SOURCE([[
566 # #include <stdint.h>
567 # #include <sys/epoll.h>
570 # #include <asm/unistd.h>
572 # _syscall1(int, epoll_create, int, size)
574 # int main(int argc, char **argv) { return epoll_create(5) < 1; }
575 # ]])],[have_epoll_lib="yes"],[have_epoll_lib="no"],[])
576 # AC_MSG_RESULT($have_epoll_lib)
577 # if test "$have_epoll_lib" = "yes"; then
578 # AC_DEFINE(NEED_EPOLL_DEFS)
581 # if test "$HAVE_EPOLL_H $have_epoll_lib" = "yes yes"; then
585 AC_CHECK_FUNC(poll, [ engine="poll"], )
587 elif test "$check_sengine" = "kqueue"; then
588 AC_CHECK_FUNC(kevent, [ engine="kqueue" ], )
589 if test "X$engine" = "X"; then
591 AC_MSG_NOTICE(kqueue not supported on this platform!)
594 AC_MSG_NOTICE(setting socketengine type to kqueue)
595 elif test "$check_sengine" = "poll"; then
596 AC_CHECK_FUNC(poll, [ engine="poll" ], )
597 if test "X$engine" = "X"; then
599 AC_MSG_NOTICE(poll not supported on this platform!)
602 AC_MSG_NOTICE(setting socketengine type to poll)
603 elif test "$check_sengine" = "devpoll"; then
604 AC_CHECK_HEADER(sys/devpoll.h, engine="devpoll", )
605 if test "X$engine" = "X"; then
607 AC_MSG_NOTICE(/dev/poll not supported on this system)
610 AC_MSG_NOTICE(setting socketengine to devpoll)
611 elif test "$check_sengine" = "epoll"; then
612 AC_CHECK_HEADER(sys/epoll.h, HAVE_EPOLL_H=yes, HAVE_EPOLL_H=no)
613 AC_CHECK_LIB(epoll, epoll_create,
614 [LIBS="$LIBS -lepoll"; have_epoll_lib="yes"; engine="epoll"],
616 if test "$HAVE_EPOLL_H $have_epoll_lib" = "yes no"; then
617 AC_MSG_CHECKING(for epoll_create [without -lepoll])
618 AC_RUN_IFELSE([AC_LANG_SOURCE([[
620 #include <sys/epoll.h>
623 #include <asm/unistd.h>
625 _syscall1(int, epoll_create, int, size)
627 int main(int argc, char **argv) { return epoll_create(5) < 1; }
628 ]])],[have_epoll_lib="yes"],[have_epoll_lib="no"],[])
629 AC_MSG_RESULT($have_epoll_lib)
630 if test "$have_epoll_lib" = "yes"; then
631 AC_DEFINE(NEED_EPOLL_DEFS)
634 if test "$HAVE_EPOLL_H $have_epoll_lib" != "yes yes"; then
636 AC_MSG_ERROR(epoll is not supported on this machine)
639 AC_MSG_NOTICE(setting socketengine type to epoll)
641 elif test "$check_sengine" = "select"; then
642 AC_MSG_NOTICE(setting socketengine type to select.. for some stupid reason)
646 AC_MSG_NOTICE(socket engine type incorrect!)
650 SENGINE="socketengine_$engine.c"
652 dnl Check to see if we have a broken FD_SETSIZE
653 if test $engine = "select"; then
654 AC_MSG_CHECKING(to see if FD_SETSIZE is broken)
655 AC_RUN_IFELSE([AC_LANG_SOURCE([[
656 #define FD_SETSIZE 666
657 #include <sys/types.h>
658 #include <sys/time.h>
662 if(FD_SETSIZE != 666)
666 ]])],[AC_MSG_RESULT(no)],[
668 AC_MSG_WARN(FD_SETSIZE is hard set by your operating system)
669 AC_MSG_WARN(MAXCONNECTIONS must be no higher than the hardwired FD_SETSIZE)
670 AC_DEFINE(BROKEN_FD_SETSIZE)
671 broken_fd_setsize="yes"
672 ],[AC_MSG_RESULT(can't tell)])
675 if test "$solaris2" != "yes" && test "$aix" != "yes" &&
676 test "$set_hmodules" = "enabled"; then
677 LDFLAGS="$LDFLAGS $MOD_LDFLAGS"
680 if test "$check_maxconnections" = "auto"; then
682 AC_MSG_CHECKING(Maximum file descriptors);
683 AC_CACHE_VAL(bh_cv_maxconnections,
688 #include <sys/types.h>
689 #include <sys/time.h>
690 #include <sys/resource.h>
693 #define RLIMIT_FD_MAX RLIMIT_FDMAX
696 #define RLIMIT_FD_MAX RLIMIT_NOFILE
698 #ifdef RLIMIT_OPEN_MAX
699 #define RLIMIT_FD_MAX RLIMIT_OPEN_MAX
709 #ifndef BROKEN_FD_SETSIZE
714 if(!getrlimit(RLIMIT_FD_MAX, &limit))
716 if(limit.rlim_max > 32768)
719 printf("%ld", (long) limit.rlim_max);
726 printf("%d", FD_SETSIZE);
733 $CC -o conftest conftest.c >/dev/null 2>&1
734 maxconnections=`./conftest`
735 AC_MSG_RESULT($maxconnections)
736 $RM -f conftest conftest.c
738 AC_DEFINE_UNQUOTED(MAXCONNECTIONS, ${maxconnections})
741 maxconnections=$check_maxconnections
742 AC_DEFINE_UNQUOTED(MAXCONNECTIONS, ${maxconnections})
746 # ripped from http://autoconf-archive.cryp.to/check_zlib.html
749 if test ! -f "${ZLIB_HOME}/include/zlib.h"
753 if test -n "${ZLIB_HOME}"
755 ZLIB_OLD_CPPFLAGS="$CPPFLAGS"
756 ZLIB_OLD_LDFLAGS="$LDFLAGS"
757 if test "x$ZLIB_HOME" = "x/usr"; then
760 CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
761 LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
764 AC_CHECK_LIB(z, inflateEnd, [zlib_cv_libz=yes], [zlib_cv_libz=no])
765 AC_CHECK_HEADER(zlib.h, [zlib_cv_zlib_h=yes], [zlib_cv_zlib_h=no])
767 if test "$zlib_cv_libz" = "yes" -a "$zlib_cv_zlib_h" = "yes"
770 # If both library and header were found, use them
772 AC_CHECK_LIB(z, inflateEnd)
773 AC_MSG_CHECKING(zlib in ${ZLIB_HOME})
777 # If either header or library was not found, revert and bomb
779 AC_MSG_CHECKING(zlib in ${ZLIB_HOME})
780 CPPFLAGS="$ZLIB_OLD_CPPFLAGS"
781 LDFLAGS="$ZLIB_OLD_LDFLAGS"
782 AC_MSG_RESULT(failed)
783 AC_MSG_ERROR(either specify a valid zlib installation with --with-zlib=DIR or disable zlib usage with --without-zlib)
787 if test "$engine" = "select" && test "$broken_fd_setsize" != "yes"; then
788 CFLAGS="$CFLAGS -DFD_SETSIZE=$maxconnections"
791 if test $prefix = NONE; then
793 if test -f "${HOME}/bahamut/ircd" ; then
794 prefix=${HOME}/bahamut
796 if test -f "${HOME}/dalnet/ircd" ; then
797 prefix=${HOME}/dalnet
801 INSTALL_DIR="${prefix}"
805 AC_SUBST(INSTALL_DIR)
807 AC_CONFIG_FILES([Makefile src/Makefile tools/Makefile doc/Makefile])
811 echo " ******* Bahamut Configuration Settings *******"
812 echo " System Build Type: $target"
813 echo " Socket Engine Type: $engine"
814 echo " Encryption: $encryption"
815 echo " Loadable Modules: $set_hmodules"
816 echo " Maximum Connections: $maxconnections"
817 echo " Install Directory: $prefix"