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