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