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