added some debug information to ssl.c
[ircu2.10.12-pk.git] / configure.in
1 dnl Prefered emacs editing mode: -*- shell-script -*-
2 dnl
3 dnl Process this file with autoconf to produce a configure script.
4 dnl
5 dnl Copyright (c) 1997, by Carlo Wood <carlo@runaway.xs4all.nl>
6 dnl Copyright (C) 2001  Kevin L. Mitchell <klmitch@mit.edu>
7 dnl
8 dnl This program is free software; you can redistribute it and/or modify
9 dnl it under the terms of the GNU General Public License as published by
10 dnl the Free Software Foundation; either version 1, or (at your option)
11 dnl any later version.
12 dnl
13 dnl This program is distributed in the hope that it will be useful,
14 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
15 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 dnl GNU General Public License for more details.
17 dnl
18 dnl You should have received a copy of the GNU General Public License
19 dnl along with this program; if not, write to the Free Software
20 dnl Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 dnl
22 dnl $Id$
23
24 dnl Make sure we are in the correct directory (someone could have run
25 dnl 'configure' with a wrong '--srcdir').
26 AC_INIT(ircd/ircd.c)
27
28 dnl Set the default prefix
29 AC_PREFIX_DEFAULT([$HOME])
30 AC_MSG_CHECKING([for installation prefix])
31 AC_CACHE_VAL(unet_cv_prefix, [unet_cv_prefix=$HOME])
32 if test x"$prefix" != xNONE; then
33     unet_cv_prefix=$prefix
34 fi
35 AC_MSG_RESULT([$unet_cv_prefix])
36 dnl HACK WARNING: We are referencing an autoconf internal variable.  This is
37 dnl the only way to force the prefix to be retrieved from the config.cache
38 dnl file!
39 ac_default_prefix=$unet_cv_prefix
40
41 dnl Define the input and output configuration header file.
42 AC_CONFIG_HEADER([config.h])
43
44 dnl Demand at least version 2.59 of autoconf (for AS_HELP_STRING)
45 AC_PREREQ(2.59)
46
47 dnl Find out what type of system we are
48 AC_CANONICAL_HOST
49
50 dnl This should be done early.
51 AC_PROG_CC
52
53 dnl ANSIfy the C compiler whenever possible.
54 AM_PROG_CC_STDC
55
56 dnl Checks for libraries.
57
58 dnl Locate the library containing crypt
59 AC_SEARCH_LIBS(crypt, descrypt crypt, ,
60 [AC_MSG_ERROR([Unable to find library containing crypt()])])
61
62 dnl Do all the checks necessary to figure out -lnsl / -lsocket stuff
63 AC_LIBRARY_NET
64
65 dnl Checks for header files.
66 AC_HEADER_STDC
67 AC_CHECK_HEADERS(crypt.h poll.h inttypes.h stdint.h sys/devpoll.h sys/epoll.h sys/event.h sys/param.h sys/resource.h sys/socket.h)
68
69 dnl Checks for typedefs, structures, and compiler characteristics
70 dnl AC_C_CONST
71 AC_C_BIGENDIAN
72 AC_TYPE_SIZE_T
73 AC_HEADER_TIME
74 AC_STRUCT_TM
75 AC_TYPE_UID_T
76 unet_CHECK_TYPE_SIZES
77 AC_CHECK_TYPE(struct sockaddr_in6, [unet_have_sockaddr_in6="yes"], [unet_have_sockaddr_in6="no"], [#include <sys/types.h>
78 #include <netinet/in.h>])
79
80 dnl Check for socklen_t.  In traditional BSD this is an int, but some
81 dnl OSes use a different type.  Test until we find something that will
82 dnl work properly.  Test borrowed from a patch submitted for Python.
83 AC_CHECK_TYPE([socklen_t], ,[
84   AC_MSG_CHECKING([for socklen_t equivalent])
85   AC_CACHE_VAL([curl_cv_socklen_t_equiv],
86   [
87 dnl Systems have either "struct sockaddr*" or "void*" as second
88 dnl arg to getpeername.
89     curl_cv_socklen_t_equiv=
90     for arg2 in "struct sockaddr" void ; do
91       for t in int size_t unsigned long "unsigned long" ; do
92         AC_TRY_COMPILE([#include <sys/types.h>
93 #include <sys/socket.h>
94 int getpeername (int $arg2 *, $t *);],[$t len;
95   getpeername(0, 0, &len);], [curl_cv_socklen_t_equiv="$t"
96   break])
97       done
98     done
99   ])
100   AC_MSG_RESULT($curl_cv_socklen_t_equiv)
101   AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
102       [type to use in place of socklen_t if not defined])],
103   [#include <sys/types.h>
104 #include<sys/socket.h>])
105
106 dnl Checks for library functions.
107 AC_CHECK_FUNCS([kqueue setrlimit getrusage times])
108
109 dnl Check for required features for admins?
110 AC_MSG_CHECKING([for donuts])
111 AC_MSG_RESULT([yes])
112
113 dnl Test for programs
114 AC_PROG_AWK
115 AC_PROG_MAKE_SET
116 AC_PROG_INSTALL
117 AC_PROG_LN_S
118 AC_PATH_PROGS(RMPROG, rm, /bin/rm)
119 AC_PATH_PROGS(SHPROG, sh, /bin/sh)
120
121 dnl (F)LEX - needed for the new conf file parser
122 AC_PROG_LEX
123 dnl The autoconf docs say $LEX defaults to 'lex'.  They lie.
124 if test "$LEX" = ":" ; then
125   AC_MSG_ERROR([Cannot find flex.])
126 elif echo "" | $LEX -V -v --version > /dev/null 2>&1 ; then
127   :
128 else
129   AC_MSG_ERROR([Cannot use $LEX as flex.])
130 fi
131
132 dnl YACC - ditto
133 AC_PROG_YACC
134 dnl The autoconf docs say $YACC defaults to 'yacc'.  This seems to be true,
135 dnl but judging from AC_PROG_LEX, it may not stay true.
136 if test "$YACC" = ":" ; then
137   AC_MSG_ERROR([Cannot find yacc.])
138 elif echo "" | $YACC -V -v --version > /dev/null 2>&1 ; then
139   :
140 else
141 dnl byacc does not seem to have any way to test for workingness, so only warn.
142   AC_MSG_WARN([$YACC may not work as yacc.])
143 fi
144
145 unet_NONBLOCKING
146 unet_SIGNALS
147
148 dnl Check OS for os_dep files.
149 AC_MSG_CHECKING(for OS-dependent information)
150 case "$host" in
151     *-linux*)
152         AC_MSG_RESULT([Linux ($host) found.])
153         unet_poll_syscall=yes
154         ;;
155
156     *-solaris*)
157         AC_MSG_RESULT([Solaris ($host) found.])
158         if test x"$ac_cv_header_poll_h" = xyes; then
159             unet_poll_syscall=yes
160         else
161             unet_poll_syscall=no
162         fi
163         AC_DEFINE([IRCU_SOLARIS], 1, [Define if building on Solaris])
164         ;;
165
166     *-sunos*)
167         AC_MSG_RESULT([Solaris ($host) found.])
168         unet_poll_syscall=no
169         ;;
170
171     *-openbsd*)
172         AC_MSG_RESULT([OpenBSD ($host) found.])
173         if test x"$ac_cv_header_poll_h" = xyes; then
174             unet_poll_syscall=yes
175         else
176             unet_poll_syscall=no
177         fi
178         ;;
179
180     *-*bsd*)
181         AC_MSG_RESULT([Generic BSD ($host) found.])
182         if test x"$ac_cv_header_poll_h" = xyes; then
183             unet_poll_syscall=yes
184         else
185             unet_poll_syscall=no
186         fi
187         ;;
188
189     *-darwin*)
190         AC_MSG_RESULT([Darwin (Mac OS X) ($host) found.])
191         unet_poll_syscall=no
192         AC_DEFINE([_DARWIN_C_SOURCE], 1, [Define to enable POSIX compatibility on Darwin.])
193         ;;
194
195     *)
196         AC_MSG_RESULT([Unknown system type $host found.])
197         AC_MSG_WARN([Unknown OS type; using generic routines.])
198         unet_poll_syscall=no
199         ;;
200 esac
201
202 dnl Check user configuration options
203 dnl Start with --enable-poll
204 AC_MSG_CHECKING([whether to enable use of poll()])
205 AC_ARG_ENABLE([poll],
206 [  --enable-poll           Force poll to be used regardless of whether or not
207                           it is a system call],
208 [unet_cv_enable_poll=$enable_poll],
209 [AC_CACHE_VAL(unet_cv_enable_poll,
210 [unet_cv_enable_poll=$unet_poll_syscall])])
211
212 # Force poll to be disabled if there is no poll.h
213 if test x"$ac_cv_header_poll_h" != xyes; then
214     unet_cv_enable_poll=no
215 fi
216
217 AC_MSG_RESULT([$unet_cv_enable_poll])
218
219 if test x"$unet_cv_enable_poll" = xyes; then
220     AC_DEFINE([USE_POLL], 1, [Specify whether or not to use poll()])
221     ENGINE_C=engine_poll.c
222 else
223     ENGINE_C=engine_select.c
224 fi
225 AC_SUBST(ENGINE_C)
226
227 dnl Now look for --enable-debug
228 AC_MSG_CHECKING([whether to enable debug mode])
229 AC_ARG_ENABLE([debug],
230 [  --enable-debug          Turn on debugging mode],
231 [unet_cv_enable_debug=$enable_debug],
232 [AC_CACHE_VAL(unet_cv_enable_debug,
233 [unet_cv_enable_debug=no])])
234 AC_MSG_RESULT([$unet_cv_enable_debug])
235
236 if test x"$unet_cv_enable_debug" = xyes; then
237     AC_DEFINE([DEBUGMODE], 1, [Enable debugging code])
238     CFLAGS="$CFLAGS -O0 -g"
239 fi
240
241 dnl Now look for --enable-leak-detect
242 AC_MSG_CHECKING([whether to enable leak detection])
243 AC_ARG_WITH([leak-detect],
244 [  --with-leak-detect          Turn on the leak detector(requires patched boehm)],
245 [unet_cv_with_leak_detect=$with_leak_detect],
246 [AC_CACHE_VAL(unet_cv_with_leak_detect,
247 [unet_cv_with_leak_detect=no])])
248 AC_MSG_RESULT([$unet_cv_enable_leak_detect])
249
250 if test x"$unet_cv_with_leak_detect" != xno; then
251     LIBS="-lgc $LIBS"
252     CFLAGS="-DMDEBUG $CFLAGS"
253     if test x"$unet_cv_with_leak_detect" != xyes; then
254        LIBS="-L$unet_cv_with_leak_detect $LIBS"
255     fi
256 fi
257
258 AC_ARG_WITH([ipv6],
259     AS_HELP_STRING([--without-ipv6], [disable IPv6 support (default is autodetect)]),
260     [ac_cv_use_ipv6=$withval],
261     [ac_cv_use_ipv6=$unet_have_sockaddr_in6])
262 AC_CACHE_CHECK([whether to use IPv6], [ac_cv_use_ipv6], [ac_cv_use_ipv6=no])
263 if test x"$ac_cv_use_ipv6" != "xno" ; then
264     AC_DEFINE([IPV6], 1, [Enable IPv6 support])
265 fi
266
267 dnl And now for --disable-asserts
268 AC_MSG_CHECKING([whether to enable asserts])
269 AC_ARG_ENABLE([asserts],
270 [  --disable-asserts       Disable assertion checking],
271 [unet_cv_enable_asserts=$enable_asserts],
272 [AC_CACHE_VAL(unet_cv_enable_asserts,
273 [unet_cv_enable_asserts=yes])])
274 AC_MSG_RESULT([$unet_cv_enable_asserts])
275
276 if test x"$unet_cv_enable_asserts" = xno; then
277     AC_DEFINE([NDEBUG], 1, [Disable assertions])
278 fi
279
280 dnl Now check for --enable-profile
281 AC_MSG_CHECKING([whether to enable profiling support (gprof)])
282 AC_ARG_ENABLE([profile],
283 [  --enable-profile        Enable profiling support (add -pg to CFLAGS and LDFLAGS)],
284 [unet_cv_enable_profile=$enable_profile],
285 [AC_CACHE_VAL(unet_cv_enable_profile,
286 [unet_cv_enable_profile=no])])
287 AC_MSG_RESULT([$unet_cv_enable_profile])
288
289 if test x"$unet_cv_enable_profile" = xyes; then
290     CFLAGS="-pg $CFLAGS"
291     LDFLAGS="-pg $LDFLAGS"
292 fi
293
294 dnl Now check for --enable-pedantic
295 AC_MSG_CHECKING([whether to enable pedantic compiler warnings])
296 AC_ARG_ENABLE([pedantic],
297 [  --enable-pedantic       Enable pedantic warnings (add -pedantic to CFLAGS)],
298 [unet_cv_enable_pedantic=$enable_pedantic],
299 [AC_CACHE_VAL(unet_cv_enable_pedantic,
300 [unet_cv_enable_pedantic=no])])
301 AC_MSG_RESULT([$unet_cv_enable_pedantic])
302
303 if test x"$unet_cv_enable_pedantic" = xyes; then
304     CFLAGS="-pedantic $CFLAGS"
305 fi
306
307 dnl Now check for --enable-warnings
308 AC_MSG_CHECKING([whether to enable compiler warnings])
309 AC_ARG_ENABLE([warnings],
310 [  --enable-warnings       Enable warnings (add -Wall to CFLAGS)],
311 [unet_cv_enable_warnings=$enable_warnings],
312 [AC_CACHE_VAL(unet_cv_enable_warnings,
313 [unet_cv_enable_warnings=no])])
314 AC_MSG_RESULT([$unet_cv_enable_warnings])
315
316 if test x"$unet_cv_enable_warnings" = xyes; then
317     CFLAGS="-Wall $CFLAGS"
318 fi
319
320 dnl --disable-inlines check...
321 AC_MSG_CHECKING([whether to enable inlining for a few critical functions])
322 AC_ARG_ENABLE([inlines],
323 [  --disable-inlines       Disable inlining for a few critical functions],
324 [unet_cv_enable_inlines=$enable_inlines],
325 [AC_CACHE_VAL(unet_cv_enable_inlines,
326 [unet_cv_enable_inlines=yes])])
327 AC_MSG_RESULT([$unet_cv_enable_inlines])
328
329 if test x"$unet_cv_enable_inlines" = xyes; then
330     AC_DEFINE([FORCEINLINE], 1, [Force inlining for a few critical functions])
331 fi
332
333 dnl --disable-devpoll check...
334 AC_MSG_CHECKING([whether to enable the /dev/poll event engine])
335 AC_ARG_ENABLE([devpoll],
336 [  --disable-devpoll       Disable the /dev/poll-based engine],
337 [unet_cv_enable_devpoll=$enable_devpoll],
338 [AC_CACHE_VAL(unet_cv_enable_devpoll,
339 [unet_cv_enable_devpoll=yes])])
340
341 if test x"$ac_cv_header_sys_devpoll_h" = xno; then
342     unet_cv_enable_devpoll=no
343 fi
344
345 AC_MSG_RESULT([$unet_cv_enable_devpoll])
346
347 if test x"$unet_cv_enable_devpoll" != xno; then
348     AC_DEFINE([USE_DEVPOLL], 1, [Define to enable the /dev/poll engine])
349     ENGINE_C="engine_devpoll.c $ENGINE_C"
350 fi
351
352 dnl --disable-kqueue check...
353 AC_MSG_CHECKING([whether to enable the kqueue event engine])
354 AC_ARG_ENABLE([kqueue],
355 [  --disable-kqueue        Disable the kqueue-based engine],
356 [unet_cv_enable_kqueue=$enable_kqueue],
357 [AC_CACHE_VAL(unet_cv_enable_kqueue,
358 [unet_cv_enable_kqueue=yes])])
359
360 if test x"$ac_cv_header_sys_event_h" = xno -o x"$ac_cv_func_kqueue" = xno; then
361     unet_cv_enable_kqueue=no
362 fi
363
364 AC_MSG_RESULT([$unet_cv_enable_kqueue])
365
366 if test x"$unet_cv_enable_kqueue" != xno; then
367     AC_DEFINE([USE_KQUEUE], 1, [Define to enable the kqueue engine])
368     ENGINE_C="engine_kqueue.c $ENGINE_C"
369 fi
370
371 dnl --disable-epoll check
372 AC_MSG_CHECKING([whether to enable the epoll event engine])
373 AC_ARG_ENABLE([epoll],
374 [  --disable-epoll         Disable the epoll-based engine],
375 [unet_cv_enable_epoll=$enable_epoll],
376 [AC_CACHE_VAL(unet_cv_enable_epoll,
377 [unet_cv_enable_epoll=yes])])
378
379 if test x"$ac_cv_header_sys_epoll_h" = xno -o x"$ac_cv_func_epoll" = xno; then
380     unet_cv_enable_epoll=no
381 fi
382
383 AC_MSG_RESULT([$unet_cv_enable_epoll])
384
385 dnl If we have the header and user has not refused epoll, we still need
386 dnl to check whether the functions are properly defined.
387 if test x"$unet_cv_enable_epoll" != xno; then
388     AC_MSG_CHECKING([whether epoll functions are properly defined])
389     AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <sys/epoll.h>], [epoll_create(10);])],
390         [AC_MSG_RESULT([yes])],
391         [AC_MSG_RESULT([no])
392          AC_DEFINE([EPOLL_NEED_BODY], 1, [Define to implement epoll system calls])])
393     AC_DEFINE([USE_EPOLL], 1, [Define to enable the epoll engine])
394     ENGINE_C="engine_epoll.c $ENGINE_C"
395 fi
396
397 dnl How to copy one va_list to another?
398 AC_CACHE_CHECK([for va_copy], unet_cv_c_va_copy, [AC_LINK_IFELSE(
399   [AC_LANG_PROGRAM([#include <stdarg.h>], [va_list ap1, ap2; va_copy(ap1, ap2);])],
400   [unet_cv_c_va_copy="yes"],
401   [unet_cv_c_va_copy="no"]
402 )])
403 if test "$unet_cv_c_va_copy" = "yes" ; then
404   AC_DEFINE(HAVE_VA_COPY, 1, [Define if we have va_copy])
405 fi
406
407 AC_CACHE_CHECK([for __va_copy], unet_cv_c___va_copy, [AC_LINK_IFELSE(
408   [AC_LANG_PROGRAM([#include <stdarg.h>], [va_list ap1, ap2; __va_copy(ap1, ap2);])],
409   [unet_cv_c___va_copy="yes"],
410   [unet_cv_c___va_copy="no"]
411 )])
412 if test "$unet_cv_c___va_copy" = "yes" ; then
413   AC_DEFINE(HAVE___VA_COPY, 1, [Define if we have __va_copy])
414 fi
415
416 dnl --with-symlink lets us set the name of the symlink; defaults to "ircd"
417 AC_MSG_CHECKING([what name to give the symlink])
418 AC_ARG_WITH([symlink],
419 [  --with-symlink=name     Name to give the symlink; if name is "no," no
420                           symlink will be created.],
421 [unet_cv_with_symlink=$with_symlink],
422 [AC_CACHE_VAL(unet_cv_with_symlink,
423 [unet_cv_with_symlink="ircd"])])
424
425 if test x"$unet_cv_with_symlink" = xyes; then
426     unet_cv_with_symlink="ircd"
427 fi
428
429 AC_MSG_RESULT([$unet_cv_with_symlink])
430
431 if test x"$unet_cv_with_symlink" = xno; then
432     INSTALL_RULE=install-no-symlink
433     SYMLINK=
434 else
435     INSTALL_RULE=install-with-symlink
436     SYMLINK=$unet_cv_with_symlink
437 fi
438 AC_SUBST(INSTALL_RULE)
439 AC_SUBST(SYMLINK)
440
441 dnl --with-mode lets us set the permissions on the binary
442 AC_MSG_CHECKING([what permissions to set on the installed binary])
443 AC_ARG_WITH([mode],
444 [  --with-mode=mode        Permissions (in octal) to give the binary],
445 [unet_cv_with_mode=$with_mode],
446 [AC_CACHE_VAL(unet_cv_with_mode,
447 [unet_cv_with_mode=711])])
448
449 if test x"$unet_cv_with_mode" = xyes -o x"$unet_cv_with_mode" = xno; then
450     unet_cv_with_mode=711
451 fi
452
453 AC_MSG_RESULT([$unet_cv_with_mode])
454
455 IRCDMODE=$unet_cv_with_mode
456 AC_SUBST(IRCDMODE)
457
458 dnl --with-owner lets us set the owner of the binary
459 changequote(,)dnl
460 unet_uid=`id | sed -e 's/.*uid=[0-9]*(//' -e 's/).*//' 2> /dev/null`
461 changequote([,])dnl
462 AC_MSG_CHECKING([which user should own the installed binary])
463 AC_ARG_WITH([owner],
464 [  --with-owner=owner      Specify owner of the installed binary],
465 [unet_cv_with_owner=$with_owner],
466 [AC_CACHE_VAL(unet_cv_with_owner,
467 [unet_cv_with_owner=$unet_uid])])
468
469 if test x"$unet_cv_with_owner" = xyes -o x"$unet_cv_with_owner" = xno; then
470     unet_cv_with_owner=$unet_uid
471 fi
472
473 AC_MSG_RESULT([$unet_cv_with_owner])
474
475 IRCDOWN=$unet_cv_with_owner
476 AC_SUBST(IRCDOWN)
477
478 dnl --with-group lets us set the group owner of the binary
479 changequote(,)dnl
480 unet_gid=`id | sed -e 's/.*gid=[0-9]*(//' -e 's/).*//' 2> /dev/null`
481 changequote([,])dnl
482 AC_MSG_CHECKING([which group should own the installed binary])
483 AC_ARG_WITH([group],
484 [  --with-group=group      Specify group owner of the installed binary],
485 [unet_cv_with_group=$with_group],
486 [AC_CACHE_VAL(unet_cv_with_group,
487 [unet_cv_with_group=$unet_gid])])
488
489 if test x"$unet_cv_with_group" = xyes -o x"$unet_cv_with_group" = xno; then
490     unet_cv_with_group=$unet_gid
491 fi
492
493 AC_MSG_RESULT([$unet_cv_with_group])
494
495 IRCDGRP=$unet_cv_with_group
496 AC_SUBST(IRCDGRP)
497
498 dnl --with-domain lets us set the domain name for some statistics-gathering
499 unet_domain=
500 if test -f /etc/resolv.conf; then
501     unet_domain=`awk '/^domain/ { print $2; exit }' /etc/resolv.conf`
502     if test x"$unet_domain" = x; then
503         unet_domain=`awk '/^search/ { print $2; exit }' /etc/resolv.conf`
504     fi
505 fi
506 AC_MSG_CHECKING([for site domain name])
507 AC_ARG_WITH([domain],
508 [  --with-domain=domain    Domain name to use in local statistics gathering],
509 [unet_cv_with_domain=$with_domain],
510 [AC_CACHE_VAL(unet_cv_with_domain,
511 [unet_cv_with_domain=$unet_domain])])
512
513 if test x"$unet_cv_with_domain" = xyes -o x"$unet_cv_with_domain" = xno; then
514     unet_cv_with_domain=$unet_domain
515 fi
516 if test x"$unet_cv_with_domain" = xno; then
517     AC_MSG_ERROR([Unable to determine server DNS domain; use --with-domain to set it])
518 fi
519
520 AC_MSG_RESULT([$unet_cv_with_domain])
521
522 AC_DEFINE_UNQUOTED(DOMAINNAME, "*$unet_cv_with_domain",
523 [Domain name to be used for some statistics gathering])
524
525 dnl --with-chroot lets us define a directory that we are going to be using
526 dnl as the root of our filesystem
527 AC_MSG_CHECKING([if chroot operation is desired])
528 AC_ARG_WITH([chroot],
529 [  --with-chroot=dir       Specify that the server will be operated under
530                           a different root directory given by dir.  See
531                           doc/readme.chroot for more information.],
532 [unet_cv_with_chroot=$with_chroot],
533 [AC_CACHE_VAL(unet_cv_with_chroot,
534 [unet_cv_with_chroot=no])])
535
536 if test x"$unet_cv_with_chroot" = xyes; then
537     AC_MSG_ERROR([--with-chroot given with no directory.  See doc/readme.chroot.])
538 fi
539
540 # Ensure there are no trailing /'s to mess us up
541 unet_cv_with_chroot=`echo "$unet_cv_with_chroot" | sed 's%/*$%%'`
542
543 AC_MSG_RESULT([$unet_cv_with_chroot])
544
545 dnl Determine some default directory names
546 dnl
547 dnl HACK WARNING: We are referencing an autoconf internal variable.  This is
548 dnl the only way to figure out what value $prefix will have when we go to do
549 dnl the install--and the only way we can stick that value in our definitions
550 dnl of SPATH, etc.
551 # Deal with the annoying value "NONE" here
552 unet_save_prefix=$prefix
553 if test x"$prefix" = xNONE; then
554     prefix=$ac_default_prefix
555 else
556     prefix=$prefix
557 fi
558
559 unet_save_exec_prefix=$exec_prefix
560 if test x"$exec_prefix" = xNONE; then
561     exec_prefix=$prefix
562 else
563     exec_prefix=$exec_prefix
564 fi
565
566 # Obtain the actual interesting directories
567 unet_bindir=`eval echo "$bindir"`
568 unet_libdir=`eval echo "$libdir"`
569
570 # Restore the original settings of $prefix and $exec_prefix
571 prefix=$unet_save_prefix
572 exec_prefix=$unet_save_exec_prefix
573
574 dnl Now compute the name of the binary and verify that it will work under
575 dnl chroot operation
576 AC_MSG_CHECKING([where the binary will be for /restart])
577 if test x"$unet_cv_with_symlink" = xno; then
578     unet_spath="$unet_bindir/ircd"
579 else
580     unet_spath="$unet_bindir/$unet_cv_with_symlink"
581 fi
582 AC_MSG_RESULT([$unet_spath])
583
584 if test x"$unet_cv_with_chroot" != xno; then
585     if echo "$unet_spath" | grep "^$unet_cv_with_chroot" > /dev/null 2>&1; then
586         unet_spath=`echo "$unet_spath" | sed "s%^$unet_cv_with_chroot%%"`
587     else
588         AC_MSG_WARN([Binary $unet_spath not relative to root directory $unet_cv_with_chroot; restarts will probably fail])
589     fi
590 fi
591
592 AC_DEFINE_UNQUOTED(SPATH, "$unet_spath", [Path to executable for restarts])
593
594 dnl --with-dpath sets the all-important DPATH
595 AC_MSG_CHECKING([what the data directory should be])
596 AC_ARG_WITH([dpath],
597 [  --with-dpath=dir        Directory for all server data files],
598 [unet_cv_with_dpath=$with_dpath],
599 [AC_CACHE_VAL(unet_cv_with_dpath,
600 [unet_cv_with_dpath=$unet_libdir])])
601
602 if test x"$unet_cv_with_dpath" = xyes -o x"$unet_cv_with_dpath" = xno; then
603     unet_cv_with_dpath=$unet_libdir
604 fi
605
606 # Ensure there are no trailing /'s to mess us up
607 unet_cv_with_dpath=`echo "$unet_cv_with_dpath" | sed 's%/*$%%'`
608
609 AC_MSG_RESULT([$unet_cv_with_dpath])
610
611 if test x"$unet_cv_with_chroot" != xno; then
612     if echo "$unet_cv_with_dpath" | grep "^$unet_cv_with_chroot" > /dev/null 2>&1; then
613         unet_dpath=`echo "$unet_cv_with_dpath" | sed "s%^$unet_cv_with_chroot%%"`
614     else
615         AC_MSG_ERROR([Data directory $unet_cv_with_dpath not relative to root directory $unet_cv_with_chroot])
616     fi
617 else
618     unet_dpath=$unet_cv_with_dpath
619 fi
620
621 AC_DEFINE_UNQUOTED(DPATH, "$unet_dpath", [Path to data directory])
622
623 DPATH=$unet_cv_with_dpath
624 AC_SUBST(DPATH)
625
626 dnl --with-cpath allows us to specify the configuration file
627 AC_MSG_CHECKING([where the default configuration file resides])
628 AC_ARG_WITH([cpath],
629 [  --with-cpath=file       Set server configuration file],
630 [unet_cv_with_cpath=$with_cpath],
631 [AC_CACHE_VAL(unet_cv_with_cpath,
632 [unet_cv_with_cpath="ircd.conf"])])
633
634 if test x"$unet_cv_with_cpath" = xyes -o x"$unet_cv_with_cpath" = xno; then
635     unet_cv_with_cpath="ircd.conf"
636 fi
637
638 AC_MSG_RESULT([$unet_cv_with_cpath])
639
640 if echo "$unet_cv_with_cpath" | grep '^/' > /dev/null 2>&1; then
641     # Absolute path; check against chroot stuff
642     if test x"$unet_cv_with_chroot" != xno; then
643         if echo "$unet_cv_with_cpath" | grep "^$unet_cv_with_chroot" > /dev/null 2>&1; then
644             unet_cpath=`echo "$unet_cv_with_cpath" | sed "s%^$unet_cv_with_chroot%%"`
645         else
646             AC_MSG_ERROR([Configuration file $unet_cv_with_cpath not relative to root directory $unet_cv_with_chroot])
647         fi
648     else
649         unet_cpath=$unet_cv_with_cpath
650     fi
651 else
652     unet_cpath=$unet_cv_with_cpath
653 fi
654
655 AC_DEFINE_UNQUOTED(CPATH, "$unet_cpath", [Configuration file name])
656
657 dnl --with-lpath allows us to specify the default debugging log file
658 AC_MSG_CHECKING([where to put the debugging log if debugging enabled])
659 AC_ARG_WITH([lpath],
660 [  --with-lpath=file       Set the debugging log file],
661 [unet_cv_with_lpath=$with_lpath],
662 [AC_CACHE_VAL(unet_cv_with_lpath,
663 [unet_cv_with_lpath="ircd.log"])])
664
665 if test x"$unet_cv_with_lpath" = xyes -o x"$unet_cv_with_lpath" = xno; then
666     unet_cv_with_lpath="ircd.log"
667 fi
668
669 AC_MSG_RESULT([$unet_cv_with_lpath])
670
671 if echo "$unet_cv_with_lpath" | grep '^/' > /dev/null 2>&1; then
672     # Absolute path; check against chroot stuff
673     if test x"$unet_cv_with_chroot" != xno; then
674         if echo "$unet_cv_with_lpath" | grep "^$unet_cv_with_chroot" > /dev/null 2>&1; then
675             unet_lpath=`echo "$unet_cv_with_lpath" | sed "s%^$unet_cv_with_chroot%%"`
676         else
677             AC_MSG_WARN([Log file $unet_cv_with_lpath not relative to root directory $unet_cv_with_chroot; using default ircd.log instead])
678             unet_cv_with_lpath="ircd.log"
679             unet_lpath="ircd.log"
680         fi
681     else
682         unet_lpath=$unet_cv_with_lpath
683     fi
684 else
685     unet_lpath=$unet_cv_with_lpath
686 fi
687
688 AC_DEFINE_UNQUOTED(LPATH, "$unet_lpath", [Path to debugging log file])
689
690 dnl --with-maxcon allows us to set the maximum connections
691 unet_maxcon=`ulimit -Hn`
692 if test x"$unet_maxcon" = xunlimited; then
693     unet_maxcon=`ulimit -Sn`
694 fi
695 unet_maxcon=`expr $unet_maxcon - 4`
696 AC_MSG_CHECKING([max connections])
697 AC_ARG_WITH([maxcon],
698 [  --with-maxcon=maxcon    Maximum number of connections server will accept],
699 [unet_cv_with_maxcon=$with_maxcon],
700 [AC_CACHE_VAL(unet_cv_with_maxcon,
701 [unet_cv_with_maxcon=$unet_maxcon])])
702
703 if test x"$unet_cv_with_maxcon" = xyes -o x"$unet_cv_with_maxcon" = xno; then
704     if test "$unet_maxcon" -lt 32; then
705       AC_MSG_ERROR([Maximum connections (number of open files minus 4) must be at least 32.])
706     fi
707     unet_cv_with_maxcon=$unet_maxcon
708 elif test "$unet_cv_with_maxcon" -lt 32; then
709     AC_MSG_ERROR([Maximum connections (--with-maxcon) must be at least 32.])
710 fi
711
712 AC_MSG_RESULT([$unet_cv_with_maxcon])
713
714 AC_DEFINE_UNQUOTED(MAXCONNECTIONS, $unet_cv_with_maxcon,
715 [Maximum number of network connections])
716
717 unet_cv_enable_gnutls="no"
718 unet_cv_enable_openssl="yes"
719
720 AC_MSG_CHECKING([for GnuTLS])
721 AC_ARG_ENABLE([gnutls],
722   [  --enable-gnutls          Enables GnuTLS ssl backend.],
723   [unet_cv_enable_gnutls=$enable_gnutls],
724 )
725 AC_MSG_RESULT([$unet_cv_enable_gnutls])
726
727 AC_MSG_CHECKING([for OpenSSL])
728 AC_ARG_ENABLE([openssl],
729   [  --enable-openssl          Enables OpenSSL ssl backend.],
730   [unet_cv_enable_openssl=$enable_openssl],
731 )
732 AC_MSG_RESULT([$unet_cv_enable_openssl])
733
734 if test x"$unet_cv_enable_gnutls" = xyes; then
735   unet_cv_enable_gnutls="no";
736   AC_CHECK_LIB(gnutls, gnutls_init, [
737     AC_CHECK_HEADERS(gnutls/gnutls.h, [
738       unet_cv_enable_gnutls="yes";
739     ])
740   ])
741 fi
742
743 if test x"$unet_cv_enable_openssl" = xyes; then
744   unet_cv_enable_openssl="no";
745   AC_CHECK_LIB(ssl, SSL_read, [
746     AC_CHECK_LIB(crypto, X509_new, [
747       AC_CHECK_HEADERS(openssl/ssl.h openssl/err.h, [
748         unet_cv_enable_openssl="yes";
749       ])
750     ])
751   ])
752 fi
753
754 if test x"$unet_cv_enable_gnutls" = xyes; then
755     LIBS="$LIBS -lgnutls"
756     AC_DEFINE([HAVE_GNUTLS], 1, [Define if you are using GnuTLS])
757 fi
758
759 if test x"$unet_cv_enable_openssl" = xyes ; then
760     LIBS="$LIBS -lssl -lcrypto"
761     AC_DEFINE([HAVE_OPENSSL], 1, [Define if you are using OpenSSL])
762 fi
763
764 dnl Finally really generate all output files:
765 AC_OUTPUT(Makefile ircd/Makefile ircd/test/Makefile, [echo timestamp > stamp-h])
766
767 dnl Report configuration
768 AC_MSG_RESULT([
769 ircu is now hopefully configured for your system.
770
771   Host system:         $host_os
772   Prefix:              $prefix
773   Asserts:             $unet_cv_enable_asserts
774   Warnings:            $unet_cv_enable_warnings
775   Debug:               $unet_cv_enable_debug
776   Profile:             $unet_cv_enable_profile
777   Owner/mode:          $unet_cv_with_owner.$unet_cv_with_group ($unet_cv_with_mode)
778   Chroot:              $unet_cv_with_chroot
779   OpenSSL:             $unet_cv_enable_openssl
780   GnuTLS:              $unet_cv_enable_gnutls
781
782   Domain:              $unet_cv_with_domain
783   DPath:               $unet_cv_with_dpath
784   CPath:               $unet_cv_with_cpath
785   LPath:               $unet_cv_with_lpath
786   Maximum connections: $unet_cv_with_maxcon
787
788   poll() engine:       $unet_cv_enable_poll
789   kqueue() engine:     $unet_cv_enable_kqueue
790   /dev/poll engine:    $unet_cv_enable_devpoll
791   epoll() engine:      $unet_cv_enable_epoll
792 ])