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