1 dnl Prefered emacs editing mode: -*- shell-script -*-
3 dnl Process this file with autoconf to produce a configure script.
5 dnl Copyright (c) 1997, by Carlo Wood <carlo@runaway.xs4all.nl>
6 dnl Copyright (C) 2001 Kevin L. Mitchell <klmitch@mit.edu>
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.
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.
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.
24 dnl Make sure we are in the correct directory (someone could have run
25 dnl 'configure' with a wrong '--srcdir').
28 dnl Set the default prefix
29 AC_PREFIX_DEFAULT([$HOME])
30 AC_CACHE_VAL(unet_cv_prefix, [unet_cv_prefix=$HOME])
31 if test x"$prefix" != xNONE; then
32 unet_cv_prefix=$prefix
34 dnl HACK WARNING: We are referencing an autoconf internal variable. This is
35 dnl the only way to force the prefix to be retrieved from the config.cache
37 ac_default_prefix=$unet_cv_prefix
39 dnl Define the input and output configuration header file.
40 AC_CONFIG_HEADER([config.h])
42 dnl Demand at least version 2.13 of autoconf
45 dnl Find out what type of system we are
48 dnl This should be done early.
51 dnl ANSIfy the C compiler whenever possible.
53 dnl Use -O3 instead of -O2.
54 if test x"$CFLAGS" != x; then
55 CFLAGS=`echo "$CFLAGS" | sed -e 's/-O2/-O3/'`
57 dnl Remove -pipe during configure
58 if test x"$CFLAGS" != x; then
59 CFLAGS=`echo "$CFLAGS" | sed -e 's/-pipe//g'`
61 dnl Notice the -g flag and deal accordingly
62 if test x"$CFLAGS" != x; then
63 unet_old_cflags=$CFLAGS
64 CFLAGS=`echo "$CFLAGS" | sed -e 's/-g//g'`
66 if test x"$CFLAGS" != x"$unet_old_cflags"; then
67 # If -g was already there, force symbols to be enabled
68 unet_cv_enable_symbols=yes
70 dnl Notice the -pg flag and deal accordingly
71 if test x"$CFLAGS" != x; then
72 unet_old_cflags=$CFLAGS
73 CFLAGS=`echo "$CFLAGS" | sed -e 's/-pg//g'`
75 if test x"$CFLAGS" != x"$unet_old_cflags"; then
76 # If -pg was already there, force profiling to be enabled
77 unet_cv_enable_profile=yes
80 dnl Checks for libraries.
82 dnl Locate the library containing crypt
83 AC_SEARCH_LIBS(crypt, descrypt crypt, ,
84 [AC_MSG_ERROR([Unable to find library containing crypt()])])
86 dnl Do all the checks necessary to figure out -lnsl / -lsocket stuff
89 dnl Look for res_mkquery. Done after AC_LIBRARY_NET in case res_mkquery
90 dnl is in one of those libraries somewhere.
91 AC_SEARCH_LIBS(res_mkquery, resolv, ,
92 [AC_MSG_ERROR([Unable to find library containing res_mkquery()])])
94 dnl Checks for header files.
96 AC_CHECK_HEADERS(poll.h)
98 dnl Checks for typedefs, structures, and compiler characteristics
105 unet_CHECK_TYPE_SIZES
107 dnl Checks for library functions.
109 dnl Do we have restarting syscalls ?
110 AC_SYS_RESTARTABLE_SYSCALLS
112 dnl Check for required features for admins?
113 AC_MSG_CHECKING([for donuts])
116 dnl Test for programs
121 AC_PATH_PROGS(RMPROG, rm, /bin/rm)
122 AC_PATH_PROGS(SHPROG, sh, /bin/sh)
127 dnl Add -pipe when possible
130 dnl Check OS for os_dep files.
131 AC_MSG_CHECKING(for OS-dependent information)
134 AC_MSG_RESULT([Linux ($host) found.])
135 unet_poll_syscall=yes
140 AC_MSG_RESULT([Solaris ($host) found.])
141 if test x"$ac_cv_header_poll_h" = xyes; then
142 unet_poll_syscall=yes
150 AC_MSG_RESULT([Solaris ($host) found.])
156 AC_MSG_RESULT([OpenBSD ($host) found.])
157 if test x"$ac_cv_header_poll_h" = xyes; then
158 unet_poll_syscall=yes
166 AC_MSG_RESULT([Generic BSD ($host) found.])
167 if test x"$ac_cv_header_poll_h" = xyes; then
168 unet_poll_syscall=yes
176 AC_MSG_RESULT([Unknown system type $host found.])
177 AC_MSG_WARN([Unknown OS type; using generic routines.])
184 dnl Check user configuration options
185 dnl Start with --enable-poll
186 AC_MSG_CHECKING([whether to enable use of poll()])
187 AC_ARG_ENABLE([poll],
188 [ --enable-poll Force poll to be used regardless of whether or not
189 it is a system call],
190 [unet_cv_enable_poll=$enable_poll],
191 [AC_CACHE_VAL(unet_cv_enable_poll,
192 [unet_cv_enable_poll=$unet_poll_syscall])])
194 # Force poll to be disabled if there is no poll.h
195 if test x"$ac_cv_header_poll_h" != xyes; then
196 unet_cv_enable_poll=no
199 AC_MSG_RESULT([$unet_cv_enable_poll])
201 if test x"$unet_cv_enable_poll" = xyes; then
202 AC_DEFINE([USE_POLL], , [Specify whether or not to use poll()])
205 dnl Now look for --enable-debug
206 AC_MSG_CHECKING([whether to enable debug mode])
207 AC_ARG_ENABLE([debug],
208 [ --enable-debug Turn on debugging mode],
209 [unet_cv_enable_debug=$enable_debug],
210 [AC_CACHE_VAL(unet_cv_enable_debug,
211 [unet_cv_enable_debug=no])])
212 AC_MSG_RESULT([$unet_cv_enable_debug])
214 if test x"$unet_cv_enable_debug" = xyes; then
215 AC_DEFINE([DEBUGMODE], , [Enable debugging code])
218 dnl And now for --enable-asserts
219 AC_MSG_CHECKING([whether to enable asserts])
220 AC_ARG_ENABLE([asserts],
221 [ --enable-asserts Enable asserts],
222 [unet_cv_enable_asserts=$enable_asserts],
223 [AC_CACHE_VAL(unet_cv_enable_asserts,
224 [unet_cv_enable_asserts=no])])
225 AC_MSG_RESULT([$unet_cv_enable_asserts])
227 if test x"$unet_cv_enable_asserts" = xno; then
228 AC_DEFINE([NDEBUG], , [Disable assertions])
231 dnl Check for --enable-symbols
232 AC_MSG_CHECKING([whether to enable debugging symbols])
233 AC_ARG_ENABLE([symbols],
234 [ --disable-symbols Disable debugging symbols (remove -g from CFLAGS)],
235 [unet_cv_enable_symbols=$enable_symbols],
236 [AC_CACHE_VAL(unet_cv_enable_symbols,
237 [unet_cv_enable_symbols=yes])])
238 AC_MSG_RESULT([$unet_cv_enable_symbols])
240 if test x"$unet_cv_enable_symbols" = xyes; then
244 dnl Now check for --enable-profile
245 AC_MSG_CHECKING([whether to enable profiling support (gprof)])
246 AC_ARG_ENABLE([profile],
247 [ --enable-profile Enable profiling support (add -pg to CFLAGS)],
248 [unet_cv_enable_profile=$enable_profile],
249 [AC_CACHE_VAL(unet_cv_enable_profile,
250 [unet_cv_enable_profile=no])])
251 AC_MSG_RESULT([$unet_cv_enable_profile])
253 if test x"$unet_cv_enable_profile" = xyes; then
257 dnl --disable-inlines check...
258 AC_MSG_CHECKING([whether to enable inlining for a few critical functions])
259 AC_ARG_ENABLE([inlines],
260 [ --disable-inlines Disable inlining for a few critical functions],
261 [unet_cv_enable_inlines=$enable_inlines],
262 [AC_CACHE_VAL(unet_cv_enable_inlines,
263 [unet_cv_enable_inlines=yes])])
264 AC_MSG_RESULT([$unet_cv_enable_inlines])
266 if test x"$unet_cv_enable_inlines" = xyes; then
267 AC_DEFINE([FORCEINLINE], , [Force inlining for a few critical functions])
270 dnl --with-symlink lets us set the name of the symlink; defaults to "ircd"
271 AC_MSG_CHECKING([what name to give the symlink])
272 AC_ARG_WITH([symlink],
273 [ --with-symlink=name Name to give the symlink; if name is "no," no
274 symlink will be created.],
275 [unet_cv_with_symlink=$with_symlink],
276 [AC_CACHE_VAL(unet_cv_with_symlink,
277 [unet_cv_with_symlink="ircd"])])
279 if test x"$unet_cv_with_symlink" = xyes; then
280 unet_cv_with_symlink="ircd"
283 AC_MSG_RESULT([$unet_cv_with_symlink])
285 if test x"$unet_cv_with_symlink" = xno; then
286 INSTALL_RULE=install-no-symlink
289 INSTALL_RULE=install-with-symlink
290 SYMLINK=$unet_cv_with_symlink
292 AC_SUBST(INSTALL_RULE)
295 dnl --with-mode lets us set the permissions on the binary
296 AC_MSG_CHECKING([what permissions to set on the installed binary])
298 [ --with-mode=mode Permissions (in octal) to give the binary],
299 [unet_cv_with_mode=$with_mode],
300 [AC_CACHE_VAL(unet_cv_with_mode,
301 [unet_cv_with_mode=711])])
303 if test x"$unet_cv_with_mode" = xyes -o x"$unet_cv_with_mode" = xno; then
304 unet_cv_with_mode=711
307 AC_MSG_RESULT([$unet_cv_with_mode])
309 IRCDMODE=$unet_cv_with_mode
312 dnl --with-owner lets us set the owner of the binary
314 unet_uid=`id | sed -e 's/.*uid=[0-9]*(//' -e 's/).*//' 2> /dev/null`
316 AC_MSG_CHECKING([which user should own the installed binary])
318 [ --with-owner=owner Specify owner of the installed binary],
319 [unet_cv_with_owner=$with_owner],
320 [AC_CACHE_VAL(unet_cv_with_owner,
321 [unet_cv_with_owner=$unet_uid])])
323 if test x"$unet_cv_with_owner" = xyes -o x"$unet_cv_with_owner" = xno; then
324 unet_cv_with_owner=$unet_uid
327 AC_MSG_RESULT([$unet_cv_with_owner])
329 IRCDOWN=$unet_cv_with_owner
332 dnl --with-group lets us set the group owner of the binary
334 unet_gid=`id | sed -e 's/.*gid=[0-9]*(//' -e 's/).*//' 2> /dev/null`
336 AC_MSG_CHECKING([which group should own the installed binary])
338 [ --with-group=group Specify group owner of the installed binary],
339 [unet_cv_with_group=$with_group],
340 [AC_CACHE_VAL(unet_cv_with_group,
341 [unet_cv_with_group=$unet_gid])])
343 if test x"$unet_cv_with_group" = xyes -o x"$unet_cv_with_group" = xno; then
344 unet_cv_with_group=$unet_gid
347 AC_MSG_RESULT([$unet_cv_with_group])
349 IRCDGRP=$unet_cv_with_group
352 dnl --with-domain lets us set the domain name for some statistics-gathering
354 if test -f /etc/resolv.conf; then
355 unet_domain=`awk '/^domain/ { print $2; exit }' /etc/resolv.conf`
356 if test x"$unet_domain" = x; then
357 unet_domain=`awk '/^search/ { print $2; exit }' /etc/resolv.conf`
360 AC_MSG_CHECKING([for site domain name])
361 AC_ARG_WITH([domain],
362 [ --with-domain=domain Domain name to use in local statistics gathering],
363 [unet_cv_with_domain=$with_domain],
364 [AC_CACHE_VAL(unet_cv_with_domain,
365 [unet_cv_with_domain=$unet_domain])])
367 if test x"$unet_cv_with_domain" = xyes -o x"$unet_cv_with_domain" = xno; then
368 unet_cv_with_domain=$unet_domain
370 if test x"$unet_cv_with_domain" = xno; then
371 AC_MSG_ERROR([Unable to determine server DNS domain; use --with-domain to set it])
374 AC_MSG_RESULT([$unet_cv_with_domain])
376 AC_DEFINE_UNQUOTED(DOMAINNAME, "*$unet_cv_with_domain",
377 [Domain name to be used for some statistics gathering])
379 dnl --with-chroot lets us define a directory that we are going to be using
380 dnl as the root of our filesystem
381 AC_MSG_CHECKING([if chroot operation is desired])
382 AC_ARG_WITH([chroot],
383 [ --with-chroot=dir Specify that the server will be operated under
384 a different root directory given by dir. See
385 doc/readme.chroot for more information.],
386 [unet_cv_with_chroot=$with_chroot],
387 [AC_CACHE_VAL(unet_cv_with_chroot,
388 [unet_cv_with_chroot=no])])
390 if test x"$unet_cv_with_chroot" = xyes; then
391 AC_MSG_ERROR([--with-chroot given with no directory. See doc/readme.chroot.])
394 # Ensure there are no trailing /'s to mess us up
395 unet_cv_with_chroot=`echo "$unet_cv_with_chroot" | sed 's%/*$%%'`
397 AC_MSG_RESULT([$unet_cv_with_chroot])
399 dnl Determine some default directory names
401 dnl HACK WARNING: We are referencing an autoconf internal variable. This is
402 dnl the only way to figure out what value $prefix will have when we go to do
403 dnl the install--and the only way we can stick that value in our definitions
405 # Deal with the annoying value "NONE" here
406 unet_save_prefix=$prefix
407 if test x"$prefix" = xNONE; then
408 prefix=$ac_default_prefix
413 unet_save_exec_prefix=$exec_prefix
414 if test x"$exec_prefix" = xNONE; then
417 exec_prefix=$exec_prefix
420 # Obtain the actual interesting directories
421 unet_bindir=`eval echo "$bindir"`
422 unet_libdir=`eval echo "$libdir"`
424 # Restore the original settings of $prefix and $exec_prefix
425 prefix=$unet_save_prefix
426 exec_prefix=$unet_save_exec_prefix
428 dnl Now compute the name of the binary and verify that it will work under
430 AC_MSG_CHECKING([where the binary will be for /restart])
431 if test x"$unet_cv_with_symlink" = xno; then
432 unet_spath="$unet_bindir/ircd"
434 unet_spath="$unet_bindir/$unet_cv_with_symlink"
436 AC_MSG_RESULT([$unet_spath])
438 if test x"$unet_cv_with_chroot" != xno; then
439 if echo "$unet_spath" | grep "^$unet_cv_with_chroot" > /dev/null 2>&1; then
440 unet_spath=`echo "$unet_spath" | sed "s%^$unet_cv_with_chroot%%"`
442 AC_MSG_WARN([Binary $unet_spath not relative to root directory $unet_cv_with_chroot; restarts will probably fail])
446 AC_DEFINE_UNQUOTED(SPATH, "$unet_spath", [Path to executable for restarts])
448 dnl --with-dpath sets the all-important DPATH
449 AC_MSG_CHECKING([what the data directory should be])
451 [ --with-dpath=dir Directory for all server data files],
452 [unet_cv_with_dpath=$with_dpath],
453 [AC_CACHE_VAL(unet_cv_with_dpath,
454 [unet_cv_with_dpath=$unet_libdir])])
456 if test x"$unet_cv_with_dpath" = xyes -o x"$unet_cv_with_dpath" = xno; then
457 unet_cv_with_dpath=$unet_libdir
460 # Ensure there are no trailing /'s to mess us up
461 unet_cv_with_dpath=`echo "$unet_cv_with_dpath" | sed 's%/*$%%'`
463 AC_MSG_RESULT([$unet_cv_with_dpath])
465 if test x"$unet_cv_with_chroot" != xno; then
466 if echo "$unet_cv_with_dpath" | grep "^$unet_cv_with_chroot" > /dev/null 2>&1; then
467 unet_dpath=`echo "$unet_cv_with_dpath" | sed "s%^$unet_cv_with_chroot%%"`
469 AC_MSG_ERROR([Data directory $unet_cv_with_dpath not relative to root directory $unet_cv_with_chroot])
472 unet_dpath=$unet_cv_with_dpath
475 AC_DEFINE_UNQUOTED(DPATH, "$unet_dpath", [Path to data directory])
477 DPATH=$unet_cv_with_dpath
480 dnl --with-cpath allows us to specify the configuration file
481 AC_MSG_CHECKING([where the default configuration file resides])
483 [ --with-cpath=file Set server configuration file],
484 [unet_cv_with_cpath=$with_cpath],
485 [AC_CACHE_VAL(unet_cv_with_cpath,
486 [unet_cv_with_cpath="ircd.conf"])])
488 if test x"$unet_cv_with_cpath" = xyes -o x"$unet_cv_with_cpath" = xno; then
489 unet_cv_with_cpath="ircd.conf"
492 AC_MSG_RESULT([$unet_cv_with_cpath])
494 if echo "$unet_cv_with_cpath" | grep '^/' > /dev/null 2>&1; then
495 # Absolute path; check against chroot stuff
496 if test x"$unet_cv_with_chroot" != xno; then
497 if echo "$unet_cv_with_cpath" | grep "^$unet_cv_with_chroot" > /dev/null 2>&1; then
498 unet_cpath=`echo "$unet_cv_with_cpath" | sed "s%^$unet_cv_with_chroot%%"`
500 AC_MSG_ERROR([Configuration file $unet_cv_with_cpath not relative to root directory $unet_cv_with_chroot])
503 unet_cpath=$unet_cv_with_cpath
506 unet_cpath=$unet_cv_with_cpath
509 AC_DEFINE_UNQUOTED(CPATH, "$unet_cpath", [Configuration file name])
511 dnl --with-lpath allows us to specify the default debugging log file
512 AC_MSG_CHECKING([where to put the debugging log if debugging enabled])
514 [ --with-lpath=file Set the debugging log file],
515 [unet_cv_with_lpath=$with_lpath],
516 [AC_CACHE_VAL(unet_cv_with_lpath,
517 [unet_cv_with_lpath="ircd.log"])])
519 if test x"$unet_cv_with_lpath" = xyes -o x"$unet_cv_with_lpath" = xno; then
520 unet_cv_with_lpath="ircd.log"
523 AC_MSG_RESULT([$unet_cv_with_lpath])
525 if echo "$unet_cv_with_lpath" | grep '^/' > /dev/null 2>&1; then
526 # Absolute path; check against chroot stuff
527 if test x"$unet_cv_with_chroot" != xno; then
528 if echo "$unet_cv_with_lpath" | grep "^$unet_cv_with_chroot" > /dev/null 2>&1; then
529 unet_lpath=`echo "$unet_cv_with_lpath" | sed "s%^$unet_cv_with_chroot%%"`
531 AC_MSG_WARN([Log file $unet_cv_with_lpath not relative to root directory $unet_cv_with_chroot; using default ircd.log instead])
532 unet_cv_with_lpath="ircd.log"
533 unet_lpath="ircd.log"
536 unet_lpath=$unet_cv_with_lpath
539 unet_lpath=$unet_cv_with_lpath
542 AC_DEFINE_UNQUOTED(LPATH, "$unet_lpath", [Path to debugging log file])
544 dnl --with-maxcon allows us to set the maximum connections
545 unet_maxcon=`ulimit -Hn`
546 unet_maxcon=`expr $unet_maxcon - 4`
547 AC_MSG_CHECKING([max connections])
548 AC_ARG_WITH([maxcon],
549 [ --with-maxcon=maxcon Maximum number of connections server will accept],
550 [unet_cv_with_maxcon=$with_maxcon],
551 [AC_CACHE_VAL(unet_cv_with_maxcon,
552 [unet_cv_with_maxcon=$unet_maxcon])])
554 if test x"$unet_cv_with_maxcon" = xyes -o x"$unet_cv_with_maxcon" = xno; then
555 unet_cv_with_maxcon=$unet_maxcon
558 AC_MSG_RESULT([$unet_cv_with_maxcon])
560 AC_DEFINE_UNQUOTED(MAXCONNECTIONS, $unet_cv_with_maxcon,
561 [Maximum number of network connections])
563 dnl Finally really generate all output files:
564 AC_OUTPUT(Makefile ircd/Makefile doc/Makefile, [echo timestamp > stamp-h])