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