]> jfr.im git - irc/DALnet/bahamut.git/blob - configure.in
Merge branch 'master' into show-uhm-in-info
[irc/DALnet/bahamut.git] / configure.in
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
4
5 AC_INIT
6
7 AC_CONFIG_HEADER(include/setup.h)
8
9 PACKAGE=bahamut-release
10 VERSION=1.8
11 AC_SUBST(PACKAGE)
12 AC_SUBST(VERSION)
13
14 # autoheader templates
15
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()])
27
28 dnl Put our options of here for ease of reading.
29
30 AC_ARG_ENABLE(hookmodules,
31 [ --disable-hookmodules disable support for loadable hook modules],,
32 [ check_hmodules="yes" ])
33
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" ])
39
40 AC_ARG_WITH(socketengine,
41 [ --with-socketengine=TYPE Set the socketengine type. Choices are:
42 kqueue poll select ],
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" ])
49
50 dnl -------------------------------------------------------------------
51 # ===========================================================================
52 # http://www.gnu.org/software/autoconf-archive/ax_cflags_warn_all.html
53 # ===========================================================================
54 #
55 # SYNOPSIS
56 #
57 # AX_CFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])]
58 #
59 # DESCRIPTION
60 #
61 # Try to find a compiler option that enables most reasonable warnings.
62 #
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.
65 #
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
69 # compiler.
70 #
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
75 #
76 # LICENSE
77 #
78 # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
79 #
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.
84 #
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.
89 #
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/>.
92 #
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.
100 #
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.
105
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"
111 AC_LANG_PUSH([C])
112 ac_save_[]FLAGS="$[]FLAGS"
113 for ac_arg dnl
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)
122 #
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],[])
125 done
126 FLAGS="$ac_save_[]FLAGS"
127 AC_LANG_POP([])
128 ])
129 case ".$VAR" in
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"])]) ;;
134 *) m4_ifvaln($3,$3,[
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"
139 fi ]) ;;
140 esac
141 AS_VAR_POPDEF([VAR])dnl
142 AS_VAR_POPDEF([FLAGS])dnl
143 ])
144
145 dnl the only difference - the LANG selection... and the default FLAGS
146
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"
152 AC_LANG_PUSH([C++])
153 ac_save_[]FLAGS="$[]FLAGS"
154 for ac_arg dnl
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)
163 #
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],[])
166 done
167 FLAGS="$ac_save_[]FLAGS"
168 AC_LANG_POP([])
169 ])
170 case ".$VAR" in
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"])]) ;;
175 *) m4_ifvaln($3,$3,[
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"
180 fi ]) ;;
181 esac
182 AS_VAR_POPDEF([VAR])dnl
183 AS_VAR_POPDEF([FLAGS])dnl
184 ])
185
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.
196
197 dnl -------------------------------------------------------------------
198
199 # ===========================================================================
200 # https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
201 # ===========================================================================
202 #
203 # SYNOPSIS
204 #
205 # AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
206 #
207 # DESCRIPTION
208 #
209 # Check whether the given FLAG works with the current language's compiler
210 # or gives an error. (Warnings, however, are ignored)
211 #
212 # ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
213 # success/failure.
214 #
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.
219 #
220 # INPUT gives an alternative input source to AC_COMPILE_IFELSE.
221 #
222 # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
223 # macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
224 #
225 # LICENSE
226 #
227 # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
228 # Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
229 #
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
233 # warranty.
234
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
250
251 dnl -------------------------------------------------------------------
252
253 # ===========================================================================
254 # http://www.gnu.org/software/autoconf-archive/ax_have_epoll.html
255 # ===========================================================================
256 #
257 # SYNOPSIS
258 #
259 # AX_HAVE_EPOLL([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
260 # AX_HAVE_EPOLL_PWAIT([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
261 #
262 # DESCRIPTION
263 #
264 # This macro determines whether the system supports the epoll I/O event
265 # interface. A neat usage example would be:
266 #
267 # AX_HAVE_EPOLL(
268 # [AX_CONFIG_FEATURE_ENABLE(epoll)],
269 # [AX_CONFIG_FEATURE_DISABLE(epoll)])
270 # AX_CONFIG_FEATURE(
271 # [epoll], [This platform supports epoll(7)],
272 # [HAVE_EPOLL], [This platform supports epoll(7).])
273 #
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.
281 #
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
286 # other way round.
287 #
288 # LICENSE
289 #
290 # Copyright (c) 2008 Peter Simons <simons@cryp.to>
291 #
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
295 # warranty.
296
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
302 AC_LINK_IFELSE([dnl
303 AC_LANG_PROGRAM([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
309 # endif
310 #endif
311 ], [dnl
312 int fd, rc;
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])
322 $2])
323 ])dnl
324
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
331 AC_LINK_IFELSE([dnl
332 AC_LANG_PROGRAM([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
337 # endif
338 #endif
339 #include <sys/epoll.h>
340 #include <signal.h>
341 ], [dnl
342 int fd, rc;
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])
353 $2])
354 ])dnl
355
356
357 dnl -------------------------------------------------
358
359 dnl Checks for programs.
360 AC_PROG_CC
361 AX_CFLAGS_WARN_ALL
362 AX_CHECK_COMPILE_FLAG([-fno-strict-aliasing], [CFLAGS="$CFLAGS -fno-strict-aliasing"])
363 AX_CHECK_COMPILE_FLAG([-fgnu89-inline], [CFLAGS="$CFLAGS -fgnu89-inline"])
364 AC_CANONICAL_TARGET
365 AC_SEARCH_LIBS([strerror],[cposix])
366 AC_PROG_MAKE_SET
367 AC_PATH_PROG(RM, rm)
368 AC_PATH_PROG(CP, cp)
369 AC_PATH_PROG(MV, mv)
370 AC_PATH_PROG(SED, sed)
371 AC_PROG_INSTALL
372 AC_C_INLINE
373
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,,)))
381
382 dnl Checks for header files.
383 AC_HEADER_STDC
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)
390 AC_EGREP_CPP(yes,
391 [
392 #if defined( HAVE_SYS_PARAM_H )
393 #include <sys/param.h>
394 #ifdef MIN
395 yes
396 #endif
397 #endif
398 ], AC_DEFINE(HAVE_MINMAX) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
399
400
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])
409
410 dnl check for various OSes
411
412 case "$target" in
413 *-solaris2*)
414 solaris2="yes"
415 AC_DEFINE(OS_SOLARIS2)
416 AC_DEFINE(OS_SOLARIS)
417 AC_DEFINE_UNQUOTED(WRITEV_IOV, 16)
418 ;;
419 *-freebsd*)
420 freebsd="yes"
421 AC_DEFINE_UNQUOTED(WRITEV_IOV, 32)
422 ;;
423 *-netbsd*)
424 AC_DEFINE_UNQUOTED(WRITEV_IOV, 32)
425 ;;
426 *-openbsd*)
427 AC_DEFINE_UNQUOTED(WRITEV_IOV, 32)
428 ;;
429 *-linux*)
430 linux="yes"
431 AC_DEFINE_UNQUOTED(WRITEV_IOV, 32)
432 ;;
433 *aix*)
434 aix="yes"
435 AC_DEFINE(AIX)
436 ;;
437 *-darwin*)
438 check_hmodules="no"
439 AC_DEFINE_UNQUOTED(WRITEV_IOV, 32)
440 ;;
441 esac
442
443 dnl Checks for loadable hook module support
444
445 set_hmodules="disabled"
446
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"
454 fi
455 fi
456
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>
462 #include <stdio.h>
463 #include <errno.h>
464 main()
465 {
466 char *s = sys_errlist[0];
467 exit(0);
468 }
469 ]])],[AC_MSG_RESULT(yes)
470 AC_DEFINE(SYS_ERRLIST_DECLARED)],[AC_MSG_RESULT(no)],[AC_MSG_RESULT(cross compiling)])
471
472 dnl Openssl checks - combination of our old way and the hybrid7 method
473
474 save_LIBS="$LIBS"
475
476 AC_MSG_CHECKING(for OpenSSL)
477
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}"
484 else
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}"
490 break
491 fi
492 done
493 unset dirs
494 fi
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"
502 fi
503 else
504 dnl OpenSSL wasn't found in the directory specified. Naughty
505 dnl administrator...
506 cf_openssl_basedir=""
507 fi
508 else
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"
517 fi
518 fi
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"
527 encryption="enabled"
528 AC_DEFINE(HAVE_ENCRYPTION_ON)
529 ENCRYPT_SRC="rc4.c dh.c libcrypto-compat.c"
530 AC_SUBST(ENCRYPT_SRC)
531 else
532 AC_MSG_RESULT(not found. Please check your path.)
533 cf_enable_openssl="no"
534 encryption="disabled"
535 fi
536 unset cf_openssl_basedir
537 else
538 dnl If --disable-openssl was specified
539 encryption="disabled"
540 AC_MSG_RESULT(disabled)
541 fi
542
543 unset save_LIBS
544
545 dnl end of openssl library test
546
547 dnl select a socket engine
548
549 if test "$check_sengine" = "yes"; then
550 engine="select"
551 if test "$freebsd" = "yes"; then
552 AC_CHECK_FUNC(kevent, [ engine="kqueue" ], )
553 elif test "$solaris2" = "yes"; then
554 engine="poll"
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>
568 # #include <errno.h>
569 #
570 # #include <asm/unistd.h>
571 #
572 # _syscall1(int, epoll_create, int, size)
573 #
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)
579 # fi
580 # fi
581 # if test "$HAVE_EPOLL_H $have_epoll_lib" = "yes yes"; then
582 # engine="epoll";
583 # fi
584 else
585 AC_CHECK_FUNC(poll, [ engine="poll"], )
586 fi
587 elif test "$check_sengine" = "kqueue"; then
588 AC_CHECK_FUNC(kevent, [ engine="kqueue" ], )
589 if test "X$engine" = "X"; then
590 AC_MSG_NOTICE()
591 AC_MSG_NOTICE(kqueue not supported on this platform!)
592 AC_MSG_ERROR()
593 fi
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
598 AC_MSG_NOTICE()
599 AC_MSG_NOTICE(poll not supported on this platform!)
600 AC_MSG_ERROR()
601 fi
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
606 AC_MSG_NOTICE()
607 AC_MSG_NOTICE(/dev/poll not supported on this system)
608 AC_MSG_ERROR()
609 fi
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"],
615 have_epoll_lib="no")
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([[
619 #include <stdint.h>
620 #include <sys/epoll.h>
621 #include <errno.h>
622
623 #include <asm/unistd.h>
624
625 _syscall1(int, epoll_create, int, size)
626
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)
632 fi
633 fi
634 if test "$HAVE_EPOLL_H $have_epoll_lib" != "yes yes"; then
635 AC_MSG_NOTICE()
636 AC_MSG_ERROR(epoll is not supported on this machine)
637 AC_MSG_ERROR()
638 fi
639 AC_MSG_NOTICE(setting socketengine type to epoll)
640 engine="epoll";
641 elif test "$check_sengine" = "select"; then
642 AC_MSG_NOTICE(setting socketengine type to select.. for some stupid reason)
643 engine="select"
644 else
645 AC_MSG_NOTICE()
646 AC_MSG_NOTICE(socket engine type incorrect!)
647 AC_MSG_ERROR()
648 fi
649
650 SENGINE="socketengine_$engine.c"
651
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>
659
660 int main()
661 {
662 if(FD_SETSIZE != 666)
663 exit(1);
664 exit(0);
665 }
666 ]])],[AC_MSG_RESULT(no)],[
667 AC_MSG_RESULT(YES)
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)])
673 fi
674
675 if test "$solaris2" != "yes" && test "$aix" != "yes" &&
676 test "$set_hmodules" = "enabled"; then
677 LDFLAGS="$LDFLAGS $MOD_LDFLAGS"
678 fi
679
680 if test "$check_maxconnections" = "auto"; then
681
682 AC_MSG_CHECKING(Maximum file descriptors);
683 AC_CACHE_VAL(bh_cv_maxconnections,
684 [
685
686 AC_LANG_CONFTEST(
687 [AC_LANG_SOURCE([[
688 #include <sys/types.h>
689 #include <sys/time.h>
690 #include <sys/resource.h>
691 #include <stdio.h>
692 #ifdef RLIMIT_FDMAX
693 #define RLIMIT_FD_MAX RLIMIT_FDMAX
694 #else
695 #ifdef RLIMIT_NOFILE
696 #define RLIMIT_FD_MAX RLIMIT_NOFILE
697 #else
698 #ifdef RLIMIT_OPEN_MAX
699 #define RLIMIT_FD_MAX RLIMIT_OPEN_MAX
700 #else
701 #undef RLIMIT_FD_MAX
702 #endif
703 #endif
704 #endif
705
706
707 int main()
708 {
709 #ifndef BROKEN_FD_SETSIZE
710
711 #ifdef RLIMIT_FD_MAX
712 struct rlimit limit;
713
714 if(!getrlimit(RLIMIT_FD_MAX, &limit))
715 {
716 if(limit.rlim_max > 32768)
717 printf("32768");
718 else
719 printf("%ld", (long) limit.rlim_max);
720 }
721 else
722 #endif
723 printf("256");
724
725 #else
726 printf("%d", FD_SETSIZE);
727 #endif
728 return 0;
729 }
730 ]])
731 ])
732
733 $CC -o conftest conftest.c >/dev/null 2>&1
734 maxconnections=`./conftest`
735 AC_MSG_RESULT($maxconnections)
736 $RM -f conftest conftest.c
737 ])
738 AC_DEFINE_UNQUOTED(MAXCONNECTIONS, ${maxconnections})
739
740 else
741 maxconnections=$check_maxconnections
742 AC_DEFINE_UNQUOTED(MAXCONNECTIONS, ${maxconnections})
743 fi
744
745 # zlib test
746 # ripped from http://autoconf-archive.cryp.to/check_zlib.html
747 #
748 ZLIB_HOME=/usr/local
749 if test ! -f "${ZLIB_HOME}/include/zlib.h"
750 then
751 ZLIB_HOME=/usr
752 fi
753 if test -n "${ZLIB_HOME}"
754 then
755 ZLIB_OLD_CPPFLAGS="$CPPFLAGS"
756 ZLIB_OLD_LDFLAGS="$LDFLAGS"
757 if test "x$ZLIB_HOME" = "x/usr"; then
758 :
759 else
760 CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
761 LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
762 fi
763 AC_LANG_PUSH([C])
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])
766 AC_LANG_POP([])
767 if test "$zlib_cv_libz" = "yes" -a "$zlib_cv_zlib_h" = "yes"
768 then
769 #
770 # If both library and header were found, use them
771 #
772 AC_CHECK_LIB(z, inflateEnd)
773 AC_MSG_CHECKING(zlib in ${ZLIB_HOME})
774 AC_MSG_RESULT(ok)
775 else
776 #
777 # If either header or library was not found, revert and bomb
778 #
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)
784 fi
785 fi
786
787 if test "$engine" = "select" && test "$broken_fd_setsize" != "yes"; then
788 CFLAGS="$CFLAGS -DFD_SETSIZE=$maxconnections"
789 fi
790
791 if test $prefix = NONE; then
792 prefix=${HOME}/ircd
793 if test -f "${HOME}/bahamut/ircd" ; then
794 prefix=${HOME}/bahamut
795 fi
796 if test -f "${HOME}/dalnet/ircd" ; then
797 prefix=${HOME}/dalnet
798 fi
799 fi
800
801 INSTALL_DIR="${prefix}"
802
803 AC_SUBST(LIBS)
804 AC_SUBST(SENGINE)
805 AC_SUBST(INSTALL_DIR)
806
807 AC_CONFIG_FILES([Makefile src/Makefile tools/Makefile doc/Makefile])
808 AC_OUTPUT
809
810 echo ""
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"
818 echo ""