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