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