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