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