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