Author: Kev <klmitch@mit.edu>
[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_CACHE_VAL(unet_cv_prefix, [unet_cv_prefix=$HOME])
31 if test x"$prefix" != xNONE; then
32     unet_cv_prefix=$prefix
33 fi
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
36 dnl file!
37 ac_default_prefix=$unet_cv_prefix
38
39 dnl Define the input and output configuration header file.
40 AC_CONFIG_HEADER([config.h])
41
42 dnl Demand at least version 2.13 of autoconf
43 AC_PREREQ(2.13)
44
45 dnl Find out what type of system we are
46 AC_CANONICAL_HOST
47
48 dnl This should be done early.
49 AC_PROG_CC
50
51 dnl ANSIfy the C compiler whenever possible.
52 AM_PROG_CC_STDC
53 dnl Use -O3 instead of -O2.
54 if test x"$CFLAGS" != x; then
55     CFLAGS=`echo "$CFLAGS" | sed -e 's/-O2/-O3/'`
56 fi
57 dnl Remove -pipe during configure
58 if test x"$CFLAGS" != x; then
59     CFLAGS=`echo "$CFLAGS" | sed -e 's/-pipe//g'`
60 fi
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'`
65 fi
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
69 fi
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'`
74 fi
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
78 fi
79
80 dnl Checks for libraries.
81
82 dnl Locate the library containing crypt
83 AC_SEARCH_LIBS(crypt, descrypt crypt, ,
84 [AC_MSG_ERROR([Unable to find library containing crypt()])])
85
86 dnl Do all the checks necessary to figure out -lnsl / -lsocket stuff
87 AC_LIBRARY_NET
88
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()])])
93
94 dnl Checks for header files.
95 AC_HEADER_STDC
96 AC_CHECK_HEADERS(poll.h)
97
98 dnl Checks for typedefs, structures, and compiler characteristics
99 dnl AC_C_CONST
100 AC_C_BIGENDIAN
101 AC_TYPE_SIZE_T
102 AC_HEADER_TIME
103 AC_STRUCT_TM
104 AC_TYPE_UID_T
105 unet_CHECK_TYPE_SIZES
106
107 dnl Checks for library functions.
108
109 dnl Do we have restarting syscalls ?
110 AC_SYS_RESTARTABLE_SYSCALLS
111
112 dnl Check for required features for admins?
113 AC_MSG_CHECKING([for donuts])
114 AC_MSG_RESULT([yes])
115
116 dnl Test for programs
117 AC_PROG_AWK
118 AC_PROG_MAKE_SET
119 AC_PROG_INSTALL
120 AC_PROG_LN_S
121 AC_PATH_PROGS(RMPROG, rm, /bin/rm)
122 AC_PATH_PROGS(SHPROG, sh, /bin/sh)
123
124 unet_NONBLOCKING
125 unet_SIGNALS
126
127 dnl Add -pipe when possible
128 unet_PIPE_CFLAGS
129
130 dnl Check OS for os_dep files.
131 AC_MSG_CHECKING(for OS-dependent information)
132 case "$host" in
133     *-linux*)
134         AC_MSG_RESULT([Linux ($host) found.])
135         unet_poll_syscall=yes
136         OSDEP_C=os_linux.c
137         ;;
138
139     *-solaris*)
140         AC_MSG_RESULT([Solaris ($host) found.])
141         if test x"$ac_cv_header_poll_h" = xyes; then
142             unet_poll_syscall=yes
143         else
144             unet_poll_syscall=no
145         fi
146         OSDEP_C=os_solaris.c
147         ;;
148
149     *-sunos*)
150         AC_MSG_RESULT([Solaris ($host) found.])
151         unet_poll_syscall=no
152         OSDEP_C=os_solaris.c
153         ;;
154
155     *-openbsd*)
156         AC_MSG_RESULT([OpenBSD ($host) found.])
157         if test x"$ac_cv_header_poll_h" = xyes; then
158             unet_poll_syscall=yes
159         else
160             unet_poll_syscall=no
161         fi
162         OSDEP_C=os_openbsd.c
163         ;;
164
165     *-*bsd*)
166         AC_MSG_RESULT([Generic BSD ($host) found.])
167         if test x"$ac_cv_header_poll_h" = xyes; then
168             unet_poll_syscall=yes
169         else
170             unet_poll_syscall=no
171         fi
172         OSDEP_C=os_bsd.c
173         ;;
174
175     *)
176         AC_MSG_RESULT([Unknown system type $host found.])
177         AC_MSG_WARN([Unknown OS type; using generic routines.])
178         unet_poll_syscall=no
179         OSDEP_C=os_generic.c
180         ;;
181 esac
182 AC_SUBST(OSDEP_C)
183
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])])
193
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
197 fi
198
199 AC_MSG_RESULT([$unet_cv_enable_poll])
200
201 if test x"$unet_cv_enable_poll" = xyes; then
202     AC_DEFINE([USE_POLL], , [Specify whether or not to use poll()])
203 fi
204
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])
213
214 if test x"$unet_cv_enable_debug" = xyes; then
215     AC_DEFINE([DEBUGMODE], , [Enable debugging code])
216 fi
217
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])
226
227 if test x"$unet_cv_enable_asserts" = xno; then
228     AC_DEFINE([NDEBUG], , [Disable assertions])
229 fi
230
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])
239
240 if test x"$unet_cv_enable_symbols" = xyes; then
241     CFLAGS="-g $CFLAGS"
242 fi
243
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])
252
253 if test x"$unet_cv_enable_profile" = xyes; then
254     CFLAGS="-pg $CFLAGS"
255 fi
256
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])
265
266 if test x"$unet_cv_enable_inlines" = xyes; then
267     AC_DEFINE([FORCEINLINE], , [Force inlining for a few critical functions])
268 fi
269
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"])])
278
279 if test x"$unet_cv_with_symlink" = xyes; then
280     unet_cv_with_symlink="ircd"
281 fi
282
283 AC_MSG_RESULT([$unet_cv_with_symlink])
284
285 if test x"$unet_cv_with_symlink" = xno; then
286     INSTALL_RULE=install-no-symlink
287     SYMLINK=
288 else
289     INSTALL_RULE=install-with-symlink
290     SYMLINK=$unet_cv_with_symlink
291 fi
292 AC_SUBST(INSTALL_RULE)
293 AC_SUBST(SYMLINK)
294
295 dnl --with-mode lets us set the permissions on the binary
296 AC_MSG_CHECKING([what permissions to set on the installed binary])
297 AC_ARG_WITH([mode],
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])])
302
303 if test x"$unet_cv_with_mode" = xyes -o x"$unet_cv_with_mode" = xno; then
304     unet_cv_with_mode=711
305 fi
306
307 AC_MSG_RESULT([$unet_cv_with_mode])
308
309 IRCDMODE=$unet_cv_with_mode
310 AC_SUBST(IRCDMODE)
311
312 dnl --with-owner lets us set the owner of the binary
313 changequote(,)dnl
314 unet_uid=`id | sed -e 's/.*uid=[0-9]*(//' -e 's/).*//' 2> /dev/null`
315 changequote([,])dnl
316 AC_MSG_CHECKING([which user should own the installed binary])
317 AC_ARG_WITH([owner],
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])])
322
323 if test x"$unet_cv_with_owner" = xyes -o x"$unet_cv_with_owner" = xno; then
324     unet_cv_with_owner=$unet_uid
325 fi
326
327 AC_MSG_RESULT([$unet_cv_with_owner])
328
329 IRCDOWN=$unet_cv_with_owner
330 AC_SUBST(IRCDOWN)
331
332 dnl --with-group lets us set the group owner of the binary
333 changequote(,)dnl
334 unet_gid=`id | sed -e 's/.*gid=[0-9]*(//' -e 's/).*//' 2> /dev/null`
335 changequote([,])dnl
336 AC_MSG_CHECKING([which group should own the installed binary])
337 AC_ARG_WITH([group],
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])])
342
343 if test x"$unet_cv_with_group" = xyes -o x"$unet_cv_with_group" = xno; then
344     unet_cv_with_group=$unet_gid
345 fi
346
347 AC_MSG_RESULT([$unet_cv_with_group])
348
349 IRCDGRP=$unet_cv_with_group
350 AC_SUBST(IRCDGRP)
351
352 dnl --with-domain lets us set the domain name for some statistics-gathering
353 unet_domain=
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`
358     fi
359 fi
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])])
366
367 if test x"$unet_cv_with_domain" = xyes -o x"$unet_cv_with_domain" = xno; then
368     unet_cv_with_domain=$unet_domain
369 fi
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])
372 fi
373
374 AC_MSG_RESULT([$unet_cv_with_domain])
375
376 AC_DEFINE_UNQUOTED(DOMAINNAME, "*$unet_cv_with_domain",
377 [Domain name to be used for some statistics gathering])
378
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])])
389
390 if test x"$unet_cv_with_chroot" = xyes; then
391     AC_MSG_ERROR([--with-chroot given with no directory.  See doc/readme.chroot.])
392 fi
393
394 # Ensure there are no trailing /'s to mess us up
395 unet_cv_with_chroot=`echo "$unet_cv_with_chroot" | sed 's%/*$%%'`
396
397 AC_MSG_RESULT([$unet_cv_with_chroot])
398
399 dnl Determine some default directory names
400 dnl
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
404 dnl of SPATH, etc.
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
409 else
410     prefix=$prefix
411 fi
412
413 unet_save_exec_prefix=$exec_prefix
414 if test x"$exec_prefix" = xNONE; then
415     exec_prefix=$prefix
416 else
417     exec_prefix=$exec_prefix
418 fi
419
420 # Obtain the actual interesting directories
421 unet_bindir=`eval echo "$bindir"`
422 unet_libdir=`eval echo "$libdir"`
423
424 # Restore the original settings of $prefix and $exec_prefix
425 prefix=$unet_save_prefix
426 exec_prefix=$unet_save_exec_prefix
427
428 dnl Now compute the name of the binary and verify that it will work under
429 dnl chroot operation
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"
433 else
434     unet_spath="$unet_bindir/$unet_cv_with_symlink"
435 fi
436 AC_MSG_RESULT([$unet_spath])
437
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%%"`
441     else
442         AC_MSG_WARN([Binary $unet_spath not relative to root directory $unet_cv_with_chroot; restarts will probably fail])
443     fi
444 fi
445
446 AC_DEFINE_UNQUOTED(SPATH, "$unet_spath", [Path to executable for restarts])
447
448 dnl --with-dpath sets the all-important DPATH
449 AC_MSG_CHECKING([what the data directory should be])
450 AC_ARG_WITH([dpath],
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])])
455
456 if test x"$unet_cv_with_dpath" = xyes -o x"$unet_cv_with_dpath" = xno; then
457     unet_cv_with_dpath=$unet_libdir
458 fi
459
460 # Ensure there are no trailing /'s to mess us up
461 unet_cv_with_dpath=`echo "$unet_cv_with_dpath" | sed 's%/*$%%'`
462
463 AC_MSG_RESULT([$unet_cv_with_dpath])
464
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%%"`
468     else
469         AC_MSG_ERROR([Data directory $unet_cv_with_dpath not relative to root directory $unet_cv_with_chroot])
470     fi
471 else
472     unet_dpath=$unet_cv_with_dpath
473 fi
474
475 AC_DEFINE_UNQUOTED(DPATH, "$unet_dpath", [Path to data directory])
476
477 DPATH=$unet_cv_with_dpath
478 AC_SUBST(DPATH)
479
480 dnl --with-cpath allows us to specify the configuration file
481 AC_MSG_CHECKING([where the default configuration file resides])
482 AC_ARG_WITH([cpath],
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"])])
487
488 if test x"$unet_cv_with_cpath" = xyes -o x"$unet_cv_with_cpath" = xno; then
489     unet_cv_with_cpath="ircd.conf"
490 fi
491
492 AC_MSG_RESULT([$unet_cv_with_cpath])
493
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%%"`
499         else
500             AC_MSG_ERROR([Configuration file $unet_cv_with_cpath not relative to root directory $unet_cv_with_chroot])
501         fi
502     else
503         unet_cpath=$unet_cv_with_cpath
504     fi
505 else
506     unet_cpath=$unet_cv_with_cpath
507 fi
508
509 AC_DEFINE_UNQUOTED(CPATH, "$unet_cpath", [Configuration file name])
510
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])
513 AC_ARG_WITH([lpath],
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"])])
518
519 if test x"$unet_cv_with_lpath" = xyes -o x"$unet_cv_with_lpath" = xno; then
520     unet_cv_with_lpath="ircd.log"
521 fi
522
523 AC_MSG_RESULT([$unet_cv_with_lpath])
524
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%%"`
530         else
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"
534         fi
535     else
536         unet_lpath=$unet_cv_with_lpath
537     fi
538 else
539     unet_lpath=$unet_cv_with_lpath
540 fi
541
542 AC_DEFINE_UNQUOTED(LPATH, "$unet_lpath", [Path to debugging log file])
543
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])])
553
554 if test x"$unet_cv_with_maxcon" = xyes -o x"$unet_cv_with_maxcon" = xno; then
555     unet_cv_with_maxcon=$unet_maxcon
556 fi
557
558 AC_MSG_RESULT([$unet_cv_with_maxcon])
559
560 AC_DEFINE_UNQUOTED(MAXCONNECTIONS, $unet_cv_with_maxcon,
561 [Maximum number of network connections])
562
563 dnl Finally really generate all output files:
564 AC_OUTPUT(Makefile ircd/Makefile doc/Makefile, [echo timestamp > stamp-h])