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