added basic ssl support to ircu
[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 Do we have restarting syscalls ?
110 AC_SYS_RESTARTABLE_SYSCALLS
111
112 dnl Check for required features for admins?
113 AC_MSG_CHECKING([for donuts])
114 AC_MSG_RESULT([yes])
115
116 dnl Test for programs
117 AC_PROG_AWK
118 AC_PROG_MAKE_SET
119 AC_PROG_INSTALL
120 AC_PROG_LN_S
121 AC_PATH_PROGS(RMPROG, rm, /bin/rm)
122 AC_PATH_PROGS(SHPROG, sh, /bin/sh)
123
124 dnl (F)LEX - needed for the new conf file parser
125 AC_PROG_LEX
126 dnl The autoconf docs say $LEX defaults to 'lex'.  They lie.
127 if test "$LEX" = ":" ; then
128   AC_MSG_ERROR([Cannot find flex.])
129 elif echo "" | $LEX -V -v --version > /dev/null 2>&1 ; then
130   :
131 else
132   AC_MSG_ERROR([Cannot use $LEX as flex.])
133 fi
134
135 dnl YACC - ditto
136 AC_PROG_YACC
137 dnl The autoconf docs say $YACC defaults to 'yacc'.  This seems to be true,
138 dnl but judging from AC_PROG_LEX, it may not stay true.
139 if test "$YACC" = ":" ; then
140   AC_MSG_ERROR([Cannot find yacc.])
141 elif echo "" | $YACC -V -v --version > /dev/null 2>&1 ; then
142   :
143 else
144 dnl byacc does not seem to have any way to test for workingness, so only warn.
145   AC_MSG_WARN([$YACC may not work as yacc.])
146 fi
147
148 unet_NONBLOCKING
149 unet_SIGNALS
150
151 dnl Check OS for os_dep files.
152 AC_MSG_CHECKING(for OS-dependent information)
153 case "$host" in
154     *-linux*)
155         AC_MSG_RESULT([Linux ($host) found.])
156         unet_poll_syscall=yes
157         ;;
158
159     *-solaris*)
160         AC_MSG_RESULT([Solaris ($host) found.])
161         if test x"$ac_cv_header_poll_h" = xyes; then
162             unet_poll_syscall=yes
163         else
164             unet_poll_syscall=no
165         fi
166         AC_DEFINE([IRCU_SOLARIS], 1, [Define if building on Solaris])
167         ;;
168
169     *-sunos*)
170         AC_MSG_RESULT([Solaris ($host) found.])
171         unet_poll_syscall=no
172         ;;
173
174     *-openbsd*)
175         AC_MSG_RESULT([OpenBSD ($host) found.])
176         if test x"$ac_cv_header_poll_h" = xyes; then
177             unet_poll_syscall=yes
178         else
179             unet_poll_syscall=no
180         fi
181         ;;
182
183     *-*bsd*)
184         AC_MSG_RESULT([Generic BSD ($host) found.])
185         if test x"$ac_cv_header_poll_h" = xyes; then
186             unet_poll_syscall=yes
187         else
188             unet_poll_syscall=no
189         fi
190         ;;
191
192     *-darwin*)
193         AC_MSG_RESULT([Darwin (Mac OS X) ($host) found.])
194         unet_poll_syscall=no
195         ;;
196
197     *)
198         AC_MSG_RESULT([Unknown system type $host found.])
199         AC_MSG_WARN([Unknown OS type; using generic routines.])
200         unet_poll_syscall=no
201         ;;
202 esac
203
204 dnl Check user configuration options
205 dnl Start with --enable-poll
206 AC_MSG_CHECKING([whether to enable use of poll()])
207 AC_ARG_ENABLE([poll],
208 [  --enable-poll           Force poll to be used regardless of whether or not
209                           it is a system call],
210 [unet_cv_enable_poll=$enable_poll],
211 [AC_CACHE_VAL(unet_cv_enable_poll,
212 [unet_cv_enable_poll=$unet_poll_syscall])])
213
214 # Force poll to be disabled if there is no poll.h
215 if test x"$ac_cv_header_poll_h" != xyes; then
216     unet_cv_enable_poll=no
217 fi
218
219 AC_MSG_RESULT([$unet_cv_enable_poll])
220
221 if test x"$unet_cv_enable_poll" = xyes; then
222     AC_DEFINE([USE_POLL], 1, [Specify whether or not to use poll()])
223     ENGINE_C=engine_poll.c
224 else
225     ENGINE_C=engine_select.c
226 fi
227 AC_SUBST(ENGINE_C)
228
229 have_gnutls="no"
230 AC_CHECK_LIB(gnutls, gnutls_init, [
231   AC_CHECK_HEADERS(gnutls/gnutls.h, [
232     LIBS="$LIBS -lgnutls"
233     have_gnutls="yes"
234   ])
235 ])
236 if test x"$have_gnutls" = xno; then
237   if test x$is_win32 = xyes ; then
238     openssl_deps="-lcrypto -lgdi32"
239   else
240     openssl_deps="-lcrypto"
241   fi
242   AC_CHECK_LIB([ssl],[SSL_library_init], [
243     LIBS="$LIBS -lssl $openssl_deps"
244   ], [], $openssl_deps)
245 fi
246
247 dnl Now look for --enable-debug
248 AC_MSG_CHECKING([whether to enable debug mode])
249 AC_ARG_ENABLE([debug],
250 [  --enable-debug          Turn on debugging mode],
251 [unet_cv_enable_debug=$enable_debug],
252 [AC_CACHE_VAL(unet_cv_enable_debug,
253 [unet_cv_enable_debug=no])])
254 AC_MSG_RESULT([$unet_cv_enable_debug])
255
256 if test x"$unet_cv_enable_debug" = xyes; then
257     AC_DEFINE([DEBUGMODE], 1, [Enable debugging code])
258 fi
259
260 dnl Now look for --enable-leak-detect
261 AC_MSG_CHECKING([whether to enable leak detection])
262 AC_ARG_WITH([leak-detect],
263 [  --with-leak-detect          Turn on the leak detector(requires patched boehm)],
264 [unet_cv_with_leak_detect=$with_leak_detect],
265 [AC_CACHE_VAL(unet_cv_with_leak_detect,
266 [unet_cv_with_leak_detect=no])])
267 AC_MSG_RESULT([$unet_cv_enable_leak_detect])
268
269 if test x"$unet_cv_with_leak_detect" != xno; then
270     LIBS="-lgc $LIBS"
271     CFLAGS="-DMDEBUG $CFLAGS"
272     if test x"$unet_cv_with_leak_detect" != xyes; then
273        LIBS="-L$unet_cv_with_leak_detect $LIBS"
274     fi
275 fi
276
277 AC_ARG_WITH([ipv6],
278     AS_HELP_STRING([--without-ipv6], [disable IPv6 support (default is autodetect)]),
279     [ac_cv_use_ipv6=$withval],
280     [ac_cv_use_ipv6=$unet_have_sockaddr_in6])
281 AC_CACHE_CHECK([whether to use IPv6], [ac_cv_use_ipv6], [ac_cv_use_ipv6=no])
282 if test x"$ac_cv_use_ipv6" != "xno" ; then
283     AC_DEFINE([IPV6], 1, [Enable IPv6 support])
284 fi
285
286 dnl And now for --disable-asserts
287 AC_MSG_CHECKING([whether to enable asserts])
288 AC_ARG_ENABLE([asserts],
289 [  --disable-asserts       Disable assertion checking],
290 [unet_cv_enable_asserts=$enable_asserts],
291 [AC_CACHE_VAL(unet_cv_enable_asserts,
292 [unet_cv_enable_asserts=yes])])
293 AC_MSG_RESULT([$unet_cv_enable_asserts])
294
295 if test x"$unet_cv_enable_asserts" = xno; then
296     AC_DEFINE([NDEBUG], 1, [Disable assertions])
297 fi
298
299 dnl Now check for --enable-profile
300 AC_MSG_CHECKING([whether to enable profiling support (gprof)])
301 AC_ARG_ENABLE([profile],
302 [  --enable-profile        Enable profiling support (add -pg to CFLAGS and LDFLAGS)],
303 [unet_cv_enable_profile=$enable_profile],
304 [AC_CACHE_VAL(unet_cv_enable_profile,
305 [unet_cv_enable_profile=no])])
306 AC_MSG_RESULT([$unet_cv_enable_profile])
307
308 if test x"$unet_cv_enable_profile" = xyes; then
309     CFLAGS="-pg $CFLAGS"
310     LDFLAGS="-pg $LDFLAGS"
311 fi
312
313 dnl Now check for --enable-pedantic
314 AC_MSG_CHECKING([whether to enable pedantic compiler warnings])
315 AC_ARG_ENABLE([pedantic],
316 [  --enable-pedantic       Enable pedantic warnings (add -pedantic to CFLAGS)],
317 [unet_cv_enable_pedantic=$enable_pedantic],
318 [AC_CACHE_VAL(unet_cv_enable_pedantic,
319 [unet_cv_enable_pedantic=no])])
320 AC_MSG_RESULT([$unet_cv_enable_pedantic])
321
322 if test x"$unet_cv_enable_pedantic" = xyes; then
323     CFLAGS="-pedantic $CFLAGS"
324 fi
325
326 dnl Now check for --enable-warnings
327 AC_MSG_CHECKING([whether to enable compiler warnings])
328 AC_ARG_ENABLE([warnings],
329 [  --enable-warnings       Enable warnings (add -Wall to CFLAGS)],
330 [unet_cv_enable_warnings=$enable_warnings],
331 [AC_CACHE_VAL(unet_cv_enable_warnings,
332 [unet_cv_enable_warnings=no])])
333 AC_MSG_RESULT([$unet_cv_enable_warnings])
334
335 if test x"$unet_cv_enable_warnings" = xyes; then
336     CFLAGS="-Wall $CFLAGS"
337 fi
338
339 dnl --disable-inlines check...
340 AC_MSG_CHECKING([whether to enable inlining for a few critical functions])
341 AC_ARG_ENABLE([inlines],
342 [  --disable-inlines       Disable inlining for a few critical functions],
343 [unet_cv_enable_inlines=$enable_inlines],
344 [AC_CACHE_VAL(unet_cv_enable_inlines,
345 [unet_cv_enable_inlines=yes])])
346 AC_MSG_RESULT([$unet_cv_enable_inlines])
347
348 if test x"$unet_cv_enable_inlines" = xyes; then
349     AC_DEFINE([FORCEINLINE], 1, [Force inlining for a few critical functions])
350 fi
351
352 dnl --disable-devpoll check...
353 AC_MSG_CHECKING([whether to enable the /dev/poll event engine])
354 AC_ARG_ENABLE([devpoll],
355 [  --disable-devpoll       Disable the /dev/poll-based engine],
356 [unet_cv_enable_devpoll=$enable_devpoll],
357 [AC_CACHE_VAL(unet_cv_enable_devpoll,
358 [unet_cv_enable_devpoll=yes])])
359
360 if test x"$ac_cv_header_sys_devpoll_h" = xno; then
361     unet_cv_enable_devpoll=no
362 fi
363
364 AC_MSG_RESULT([$unet_cv_enable_devpoll])
365
366 if test x"$unet_cv_enable_devpoll" != xno; then
367     AC_DEFINE([USE_DEVPOLL], 1, [Define to enable the /dev/poll engine])
368     ENGINE_C="engine_devpoll.c $ENGINE_C"
369 fi
370
371 dnl --disable-kqueue check...
372 AC_MSG_CHECKING([whether to enable the kqueue event engine])
373 AC_ARG_ENABLE([kqueue],
374 [  --disable-kqueue        Disable the kqueue-based engine],
375 [unet_cv_enable_kqueue=$enable_kqueue],
376 [AC_CACHE_VAL(unet_cv_enable_kqueue,
377 [unet_cv_enable_kqueue=yes])])
378
379 if test x"$ac_cv_header_sys_event_h" = xno -o x"$ac_cv_func_kqueue" = xno; then
380     unet_cv_enable_kqueue=no
381 fi
382
383 AC_MSG_RESULT([$unet_cv_enable_kqueue])
384
385 if test x"$unet_cv_enable_kqueue" != xno; then
386     AC_DEFINE([USE_KQUEUE], 1, [Define to enable the kqueue engine])
387     ENGINE_C="engine_kqueue.c $ENGINE_C"
388 fi
389
390 dnl --disable-epoll check
391 AC_MSG_CHECKING([whether to enable the epoll event engine])
392 AC_ARG_ENABLE([epoll],
393 [  --disable-epoll         Disable the epoll-based engine],
394 [unet_cv_enable_epoll=$enable_epoll],
395 [AC_CACHE_VAL(unet_cv_enable_epoll,
396 [unet_cv_enable_epoll=yes])])
397
398 if test x"$ac_cv_header_sys_epoll_h" = xno -o x"$ac_cv_func_epoll" = xno; then
399     unet_cv_enable_epoll=no
400 fi
401
402 AC_MSG_RESULT([$unet_cv_enable_epoll])
403
404 dnl If we have the header and user has not refused epoll, we still need
405 dnl to check whether the functions are properly defined.
406 if test x"$unet_cv_enable_epoll" != xno; then
407     AC_MSG_CHECKING([whether epoll functions are properly defined])
408     AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <sys/epoll.h>], [epoll_create(10);])],
409         [AC_MSG_RESULT([yes])],
410         [AC_MSG_RESULT([no])
411          AC_DEFINE([EPOLL_NEED_BODY], 1, [Define to implement epoll system calls])])
412     AC_DEFINE([USE_EPOLL], 1, [Define to enable the epoll engine])
413     ENGINE_C="engine_epoll.c $ENGINE_C"
414 fi
415
416 dnl How to copy one va_list to another?
417 AC_CACHE_CHECK([for va_copy], unet_cv_c_va_copy, [AC_LINK_IFELSE(
418   [AC_LANG_PROGRAM([#include <stdarg.h>], [va_list ap1, ap2; va_copy(ap1, ap2);])],
419   [unet_cv_c_va_copy="yes"],
420   [unet_cv_c_va_copy="no"]
421 )])
422 if test "$unet_cv_c_va_copy" = "yes" ; then
423   AC_DEFINE(HAVE_VA_COPY, 1, [Define if we have va_copy])
424 fi
425
426 AC_CACHE_CHECK([for __va_copy], unet_cv_c___va_copy, [AC_LINK_IFELSE(
427   [AC_LANG_PROGRAM([#include <stdarg.h>], [va_list ap1, ap2; __va_copy(ap1, ap2);])],
428   [unet_cv_c___va_copy="yes"],
429   [unet_cv_c___va_copy="no"]
430 )])
431 if test "$unet_cv_c___va_copy" = "yes" ; then
432   AC_DEFINE(HAVE___VA_COPY, 1, [Define if we have __va_copy])
433 fi
434
435 dnl --with-symlink lets us set the name of the symlink; defaults to "ircd"
436 AC_MSG_CHECKING([what name to give the symlink])
437 AC_ARG_WITH([symlink],
438 [  --with-symlink=name     Name to give the symlink; if name is "no," no
439                           symlink will be created.],
440 [unet_cv_with_symlink=$with_symlink],
441 [AC_CACHE_VAL(unet_cv_with_symlink,
442 [unet_cv_with_symlink="ircd"])])
443
444 if test x"$unet_cv_with_symlink" = xyes; then
445     unet_cv_with_symlink="ircd"
446 fi
447
448 AC_MSG_RESULT([$unet_cv_with_symlink])
449
450 if test x"$unet_cv_with_symlink" = xno; then
451     INSTALL_RULE=install-no-symlink
452     SYMLINK=
453 else
454     INSTALL_RULE=install-with-symlink
455     SYMLINK=$unet_cv_with_symlink
456 fi
457 AC_SUBST(INSTALL_RULE)
458 AC_SUBST(SYMLINK)
459
460 dnl --with-mode lets us set the permissions on the binary
461 AC_MSG_CHECKING([what permissions to set on the installed binary])
462 AC_ARG_WITH([mode],
463 [  --with-mode=mode        Permissions (in octal) to give the binary],
464 [unet_cv_with_mode=$with_mode],
465 [AC_CACHE_VAL(unet_cv_with_mode,
466 [unet_cv_with_mode=711])])
467
468 if test x"$unet_cv_with_mode" = xyes -o x"$unet_cv_with_mode" = xno; then
469     unet_cv_with_mode=711
470 fi
471
472 AC_MSG_RESULT([$unet_cv_with_mode])
473
474 IRCDMODE=$unet_cv_with_mode
475 AC_SUBST(IRCDMODE)
476
477 dnl --with-owner lets us set the owner of the binary
478 changequote(,)dnl
479 unet_uid=`id | sed -e 's/.*uid=[0-9]*(//' -e 's/).*//' 2> /dev/null`
480 changequote([,])dnl
481 AC_MSG_CHECKING([which user should own the installed binary])
482 AC_ARG_WITH([owner],
483 [  --with-owner=owner      Specify owner of the installed binary],
484 [unet_cv_with_owner=$with_owner],
485 [AC_CACHE_VAL(unet_cv_with_owner,
486 [unet_cv_with_owner=$unet_uid])])
487
488 if test x"$unet_cv_with_owner" = xyes -o x"$unet_cv_with_owner" = xno; then
489     unet_cv_with_owner=$unet_uid
490 fi
491
492 AC_MSG_RESULT([$unet_cv_with_owner])
493
494 IRCDOWN=$unet_cv_with_owner
495 AC_SUBST(IRCDOWN)
496
497 dnl --with-group lets us set the group owner of the binary
498 changequote(,)dnl
499 unet_gid=`id | sed -e 's/.*gid=[0-9]*(//' -e 's/).*//' 2> /dev/null`
500 changequote([,])dnl
501 AC_MSG_CHECKING([which group should own the installed binary])
502 AC_ARG_WITH([group],
503 [  --with-group=group      Specify group owner of the installed binary],
504 [unet_cv_with_group=$with_group],
505 [AC_CACHE_VAL(unet_cv_with_group,
506 [unet_cv_with_group=$unet_gid])])
507
508 if test x"$unet_cv_with_group" = xyes -o x"$unet_cv_with_group" = xno; then
509     unet_cv_with_group=$unet_gid
510 fi
511
512 AC_MSG_RESULT([$unet_cv_with_group])
513
514 IRCDGRP=$unet_cv_with_group
515 AC_SUBST(IRCDGRP)
516
517 dnl --with-domain lets us set the domain name for some statistics-gathering
518 unet_domain=
519 if test -f /etc/resolv.conf; then
520     unet_domain=`awk '/^domain/ { print $2; exit }' /etc/resolv.conf`
521     if test x"$unet_domain" = x; then
522         unet_domain=`awk '/^search/ { print $2; exit }' /etc/resolv.conf`
523     fi
524 fi
525 AC_MSG_CHECKING([for site domain name])
526 AC_ARG_WITH([domain],
527 [  --with-domain=domain    Domain name to use in local statistics gathering],
528 [unet_cv_with_domain=$with_domain],
529 [AC_CACHE_VAL(unet_cv_with_domain,
530 [unet_cv_with_domain=$unet_domain])])
531
532 if test x"$unet_cv_with_domain" = xyes -o x"$unet_cv_with_domain" = xno; then
533     unet_cv_with_domain=$unet_domain
534 fi
535 if test x"$unet_cv_with_domain" = xno; then
536     AC_MSG_ERROR([Unable to determine server DNS domain; use --with-domain to set it])
537 fi
538
539 AC_MSG_RESULT([$unet_cv_with_domain])
540
541 AC_DEFINE_UNQUOTED(DOMAINNAME, "*$unet_cv_with_domain",
542 [Domain name to be used for some statistics gathering])
543
544 dnl --with-chroot lets us define a directory that we are going to be using
545 dnl as the root of our filesystem
546 AC_MSG_CHECKING([if chroot operation is desired])
547 AC_ARG_WITH([chroot],
548 [  --with-chroot=dir       Specify that the server will be operated under
549                           a different root directory given by dir.  See
550                           doc/readme.chroot for more information.],
551 [unet_cv_with_chroot=$with_chroot],
552 [AC_CACHE_VAL(unet_cv_with_chroot,
553 [unet_cv_with_chroot=no])])
554
555 if test x"$unet_cv_with_chroot" = xyes; then
556     AC_MSG_ERROR([--with-chroot given with no directory.  See doc/readme.chroot.])
557 fi
558
559 # Ensure there are no trailing /'s to mess us up
560 unet_cv_with_chroot=`echo "$unet_cv_with_chroot" | sed 's%/*$%%'`
561
562 AC_MSG_RESULT([$unet_cv_with_chroot])
563
564 dnl Determine some default directory names
565 dnl
566 dnl HACK WARNING: We are referencing an autoconf internal variable.  This is
567 dnl the only way to figure out what value $prefix will have when we go to do
568 dnl the install--and the only way we can stick that value in our definitions
569 dnl of SPATH, etc.
570 # Deal with the annoying value "NONE" here
571 unet_save_prefix=$prefix
572 if test x"$prefix" = xNONE; then
573     prefix=$ac_default_prefix
574 else
575     prefix=$prefix
576 fi
577
578 unet_save_exec_prefix=$exec_prefix
579 if test x"$exec_prefix" = xNONE; then
580     exec_prefix=$prefix
581 else
582     exec_prefix=$exec_prefix
583 fi
584
585 # Obtain the actual interesting directories
586 unet_bindir=`eval echo "$bindir"`
587 unet_libdir=`eval echo "$libdir"`
588
589 # Restore the original settings of $prefix and $exec_prefix
590 prefix=$unet_save_prefix
591 exec_prefix=$unet_save_exec_prefix
592
593 dnl Now compute the name of the binary and verify that it will work under
594 dnl chroot operation
595 AC_MSG_CHECKING([where the binary will be for /restart])
596 if test x"$unet_cv_with_symlink" = xno; then
597     unet_spath="$unet_bindir/ircd"
598 else
599     unet_spath="$unet_bindir/$unet_cv_with_symlink"
600 fi
601 AC_MSG_RESULT([$unet_spath])
602
603 if test x"$unet_cv_with_chroot" != xno; then
604     if echo "$unet_spath" | grep "^$unet_cv_with_chroot" > /dev/null 2>&1; then
605         unet_spath=`echo "$unet_spath" | sed "s%^$unet_cv_with_chroot%%"`
606     else
607         AC_MSG_WARN([Binary $unet_spath not relative to root directory $unet_cv_with_chroot; restarts will probably fail])
608     fi
609 fi
610
611 AC_DEFINE_UNQUOTED(SPATH, "$unet_spath", [Path to executable for restarts])
612
613 dnl --with-dpath sets the all-important DPATH
614 AC_MSG_CHECKING([what the data directory should be])
615 AC_ARG_WITH([dpath],
616 [  --with-dpath=dir        Directory for all server data files],
617 [unet_cv_with_dpath=$with_dpath],
618 [AC_CACHE_VAL(unet_cv_with_dpath,
619 [unet_cv_with_dpath=$unet_libdir])])
620
621 if test x"$unet_cv_with_dpath" = xyes -o x"$unet_cv_with_dpath" = xno; then
622     unet_cv_with_dpath=$unet_libdir
623 fi
624
625 # Ensure there are no trailing /'s to mess us up
626 unet_cv_with_dpath=`echo "$unet_cv_with_dpath" | sed 's%/*$%%'`
627
628 AC_MSG_RESULT([$unet_cv_with_dpath])
629
630 if test x"$unet_cv_with_chroot" != xno; then
631     if echo "$unet_cv_with_dpath" | grep "^$unet_cv_with_chroot" > /dev/null 2>&1; then
632         unet_dpath=`echo "$unet_cv_with_dpath" | sed "s%^$unet_cv_with_chroot%%"`
633     else
634         AC_MSG_ERROR([Data directory $unet_cv_with_dpath not relative to root directory $unet_cv_with_chroot])
635     fi
636 else
637     unet_dpath=$unet_cv_with_dpath
638 fi
639
640 AC_DEFINE_UNQUOTED(DPATH, "$unet_dpath", [Path to data directory])
641
642 DPATH=$unet_cv_with_dpath
643 AC_SUBST(DPATH)
644
645 dnl --with-cpath allows us to specify the configuration file
646 AC_MSG_CHECKING([where the default configuration file resides])
647 AC_ARG_WITH([cpath],
648 [  --with-cpath=file       Set server configuration file],
649 [unet_cv_with_cpath=$with_cpath],
650 [AC_CACHE_VAL(unet_cv_with_cpath,
651 [unet_cv_with_cpath="ircd.conf"])])
652
653 if test x"$unet_cv_with_cpath" = xyes -o x"$unet_cv_with_cpath" = xno; then
654     unet_cv_with_cpath="ircd.conf"
655 fi
656
657 AC_MSG_RESULT([$unet_cv_with_cpath])
658
659 if echo "$unet_cv_with_cpath" | grep '^/' > /dev/null 2>&1; then
660     # Absolute path; check against chroot stuff
661     if test x"$unet_cv_with_chroot" != xno; then
662         if echo "$unet_cv_with_cpath" | grep "^$unet_cv_with_chroot" > /dev/null 2>&1; then
663             unet_cpath=`echo "$unet_cv_with_cpath" | sed "s%^$unet_cv_with_chroot%%"`
664         else
665             AC_MSG_ERROR([Configuration file $unet_cv_with_cpath not relative to root directory $unet_cv_with_chroot])
666         fi
667     else
668         unet_cpath=$unet_cv_with_cpath
669     fi
670 else
671     unet_cpath=$unet_cv_with_cpath
672 fi
673
674 AC_DEFINE_UNQUOTED(CPATH, "$unet_cpath", [Configuration file name])
675
676 dnl --with-lpath allows us to specify the default debugging log file
677 AC_MSG_CHECKING([where to put the debugging log if debugging enabled])
678 AC_ARG_WITH([lpath],
679 [  --with-lpath=file       Set the debugging log file],
680 [unet_cv_with_lpath=$with_lpath],
681 [AC_CACHE_VAL(unet_cv_with_lpath,
682 [unet_cv_with_lpath="ircd.log"])])
683
684 if test x"$unet_cv_with_lpath" = xyes -o x"$unet_cv_with_lpath" = xno; then
685     unet_cv_with_lpath="ircd.log"
686 fi
687
688 AC_MSG_RESULT([$unet_cv_with_lpath])
689
690 if echo "$unet_cv_with_lpath" | grep '^/' > /dev/null 2>&1; then
691     # Absolute path; check against chroot stuff
692     if test x"$unet_cv_with_chroot" != xno; then
693         if echo "$unet_cv_with_lpath" | grep "^$unet_cv_with_chroot" > /dev/null 2>&1; then
694             unet_lpath=`echo "$unet_cv_with_lpath" | sed "s%^$unet_cv_with_chroot%%"`
695         else
696             AC_MSG_WARN([Log file $unet_cv_with_lpath not relative to root directory $unet_cv_with_chroot; using default ircd.log instead])
697             unet_cv_with_lpath="ircd.log"
698             unet_lpath="ircd.log"
699         fi
700     else
701         unet_lpath=$unet_cv_with_lpath
702     fi
703 else
704     unet_lpath=$unet_cv_with_lpath
705 fi
706
707 AC_DEFINE_UNQUOTED(LPATH, "$unet_lpath", [Path to debugging log file])
708
709 dnl --with-maxcon allows us to set the maximum connections
710 unet_maxcon=`ulimit -Hn`
711 if test x"$unet_maxcon" = xunlimited; then
712     unet_maxcon=`ulimit -Sn`
713 fi
714 unet_maxcon=`expr $unet_maxcon - 4`
715 AC_MSG_CHECKING([max connections])
716 AC_ARG_WITH([maxcon],
717 [  --with-maxcon=maxcon    Maximum number of connections server will accept],
718 [unet_cv_with_maxcon=$with_maxcon],
719 [AC_CACHE_VAL(unet_cv_with_maxcon,
720 [unet_cv_with_maxcon=$unet_maxcon])])
721
722 if test x"$unet_cv_with_maxcon" = xyes -o x"$unet_cv_with_maxcon" = xno; then
723     if test "$unet_maxcon" -lt 32; then
724       AC_MSG_ERROR([Maximum connections (number of open files minus 4) must be at least 32.])
725     fi
726     unet_cv_with_maxcon=$unet_maxcon
727 elif test "$unet_cv_with_maxcon" -lt 32; then
728     AC_MSG_ERROR([Maximum connections (--with-maxcon) must be at least 32.])
729 fi
730
731 AC_MSG_RESULT([$unet_cv_with_maxcon])
732
733 AC_DEFINE_UNQUOTED(MAXCONNECTIONS, $unet_cv_with_maxcon,
734 [Maximum number of network connections])
735
736 dnl Finally really generate all output files:
737 AC_OUTPUT(Makefile ircd/Makefile ircd/test/Makefile, [echo timestamp > stamp-h])
738
739 dnl Report configuration
740 AC_OUTPUT_COMMANDS([echo "
741 ircu is now hopefully configured for your system.
742
743   Host system:         $host_os
744   Prefix:              $prefix
745   Asserts:             $unet_cv_enable_asserts
746   Warnings:            $unet_cv_enable_warnings
747   Debug:               $unet_cv_enable_debug
748   Profile:             $unet_cv_enable_profile
749   Owner/mode:          $unet_cv_with_owner.$unet_cv_with_group ($unet_cv_with_mode)
750   Chroot:              $unet_cv_with_chroot
751
752   Domain:              $unet_cv_with_domain
753   DPath:               $unet_cv_with_dpath
754   CPath:               $unet_cv_with_cpath
755   LPath:               $unet_cv_with_lpath
756   Maximum connections: $unet_cv_with_maxcon
757
758   poll() engine:       $unet_cv_enable_poll
759   kqueue() engine:     $unet_cv_enable_kqueue
760   /dev/poll engine:    $unet_cv_enable_devpoll
761   epoll() engine:      $unet_cv_enable_epoll
762 "])