* Updated setup dialog for host auth mode.
[citadel.git] / citadel / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2 dnl $Id$
3 AC_PREREQ(2.52)
4 AC_INIT([Citadel], [7.01], [http://www.citadel.org/])
5 AC_REVISION([$Revision$])
6 AC_CONFIG_SRCDIR([citserver.c])
7 AC_PREFIX_DEFAULT(/usr/local/citadel)
8 if test "$prefix" = NONE; then
9         AC_DEFINE_UNQUOTED(CTDLDIR, "$ac_default_prefix")
10 else
11         AC_DEFINE_UNQUOTED(CTDLDIR, "$prefix")
12 fi
13
14
15 dnl Make sure we see all GNU and Solaris extensions.
16 AC_GNU_SOURCE
17
18
19 dnl Checks for the Datadir
20 AC_ARG_WITH(datadir, 
21                     [  --with-datadir          directory to store the databases under],
22                         [ if test "x$withval" != "xno" ; then
23                                               AC_DEFINE(HAVE_DATA_DIR)
24                                                   AC_DEFINE_UNQUOTED(DATA_DIR, "$withval")
25                                                   MAKE_DATA_DIR=$withval
26                                                   AC_SUBST(MAKE_DATA_DIR)
27                           fi
28                         ]
29 )
30
31 dnl Checks for the spooldir
32 AC_ARG_WITH(spooldir, 
33                         [  --with-spooldir         directory to keep queues under],
34                         [ if test "x$withval" != "xno" ; then
35                                             AC_DEFINE(HAVE_SPOOL_DIR)
36                                                 AC_DEFINE_UNQUOTED(SPOOL_DIR,"$withval")
37                                                 MAKE_SPOOL_DIR=$withval
38                                                 AC_SUBST(MAKE_SPOOL_DIR)
39                            fi
40                         ]
41 )
42
43
44 dnl Checks for the Configdir
45 AC_ARG_WITH(sysconfdir, 
46                         [  --with-sysconfdir       directory to store the configs under],
47                         [ if test "x$withval" != "xno" ; then
48                                             AC_DEFINE(HAVE_ETC_DIR)
49                                                 AC_DEFINE_UNQUOTED(ETC_DIR, "$withval")
50                                                 MAKE_ETC_DIR=$withval
51                                                 AC_SUBST(MAKE_ETC_DIR)
52                           fi
53                         ]
54 )
55
56
57 dnl Checks for the run-dir for the sockets
58 AC_ARG_WITH(rundir, 
59                         [  --with-rundir           directory to store the configs under],
60                         [ if test "x$withval" != "xno" ; then
61                                             AC_DEFINE(HAVE_RUN_DIR)
62                                                 AC_DEFINE_UNQUOTED(RUN_DIR, "$withval")
63                                                 MAKE_RUN_DIR=$withval
64                                                 AC_SUBST(MAKE_RUN_DIR)
65                           fi
66                         ]
67 )
68
69
70 dnl Checks for the Pseudo Random Generator sockets TODO: this keeps being default.
71 AC_DEFINE_UNQUOTED(EGD_POOL, "/var/run/egd-pool")
72 AC_ARG_WITH(egdpool, 
73                         [  --with-egdpool          the socket from Pseudo Random Generator, defaults to /var/run/egd-pool],
74                         [ if test "x$withval" != "xno" ; then
75                                                 AC_DEFINE_UNQUOTED(EGD_POOL, "$withval")
76                           fi
77                         ]
78 )
79
80
81 AC_ARG_WITH(docdir,
82                         [  --with-docdir           where to install the documentation. default: /usr/local/citadel/],
83                         [ if test "x$withval" != "xno" ; then
84                                         MAKE_DOC_DIR=$withval
85                                         AC_SUBST(MAKE_DOC_DIR)
86                           fi
87                         ]
88 )
89
90
91
92 AC_ARG_ENABLE(chkpwd, [  --disable-chkpwd        don't build 'chkpwd'])
93
94 AC_ARG_ENABLE(threaded-client, [  --disable-threaded-client
95                           disable multithreaded client])
96
97 AC_ARG_ENABLE(pie, [  --enable-pie            build position-independent executables])
98
99 AC_ARG_WITH(pam, [  --with-pam              use PAM if present (see PAM.txt before you try this)])
100 AC_ARG_WITH(kthread, [  --with-kthread          use kernel threads (on FreeBSD) (not recommended yet)])
101 AC_ARG_WITH(db, [  --with-db@<:@=DIR@:>@         use Sleepycat DB 3.x @<:@DIR=/usr/local/BerkeleyDB.3.@<:@123@:>@@:>@])
102 AC_ARG_WITH(ssl,
103         [  --with-ssl=PATH         Specify path to OpenSSL installation ],
104         [
105                 if test "x$withval" != "xno" ; then
106                         tryssldir=$withval
107                 fi
108         ]
109 )
110 AC_ARG_WITH(ncurses, [  --without-ncurses       don't use ncurses])
111
112 AC_ARG_WITH(with_zlib, [  --with-zlib             use zlib compression if present])
113 AC_ARG_WITH(with_ldap, [  --with-ldap             use OpenLDAP client library])
114 AC_ARG_WITH(with_libical, [  --with-libical          use libical calendaring library])
115 AC_ARG_WITH(with_libsieve, [  --with-libsieve         use libsieve mail sorting library])
116
117 if test "x$with_db" != xno -a "x$with_db" != xyes -a "$with_db"; then
118         db_dir="$with_db"
119         with_db=yes
120 else
121         test -f /usr/local/lib/libdb.a -o -f /usr/local/lib/libdb.so \
122           -o -f /usr/local/lib/libdb4.a -o -f /usr/local/lib/libdb4.so \
123           && db_dir=/usr/local
124
125         test -d /usr/local/BerkeleyDB.4.1 && db_dir=/usr/local/BerkeleyDB.4.1
126         test -d /usr/local/BerkeleyDB.4.2 && db_dir=/usr/local/BerkeleyDB.4.2
127         test -d /usr/local/BerkeleyDB.4.3 && db_dir=/usr/local/BerkeleyDB.4.3
128 fi
129
130 dnl By default, we only build the client (citadel and whobbs) unless we can
131 dnl figure out how to build with POSIX threads.
132 TARGETS=client
133
134 AC_CANONICAL_HOST
135 PTHREAD_DEFS=-D_REENTRANT
136 AC_MSG_CHECKING([how to compile with POSIX threads])
137 case "$host" in
138         dnl BSDI 3.0 wants relocatable object modules instead of shared libs
139         dnl for dlopen(), and has a wrapper script to link with shared libs.
140         dnl Also has stupid non-reentrant gethostbyaddr() and friends.
141         *-*-bsdi[123]*)
142                 test -z "$CC" -a -x /usr/bin/shlicc2 && CC=shlicc2
143                 AC_DEFINE(HAVE_NONREENTRANT_NETDB)
144                 AC_MSG_RESULT([Old BSDI])
145         ;;
146         *-*-bsdi*)
147                 AC_DEFINE(HAVE_NONREENTRANT_NETDB)
148                 AC_MSG_RESULT([BSD/OS])
149         ;;
150         dnl Curses support on Mac OS X is kind of screwed at the moment.
151         *-*-darwin*)
152                 AC_DEFINE(DISABLE_CURSES)
153                 AC_MSG_RESULT([Mac OS X])
154         ;;
155         dnl Digital Unix has an odd way to build for pthreads, and we can't
156         dnl build pthreads programs with gcc due to header problems.
157         alpha*-dec-osf*)
158                 test -z "$CC" && CC=cc
159                 LIBS="-lpthread -lexc $LIBS"
160                 check_pthread=no
161                 AC_MSG_RESULT([Tru64 or Digital UNIX])
162         ;;
163         dnl FreeBSD is similar to Digital UNIX with DEC C, which has a -pthread flag:
164         *-*-freebsd*)
165                 if test "$with_kthread" = yes; then
166                         LIBS="-kthread $LIBS"
167                 else
168                         LIBS="-pthread $LIBS"
169                 fi
170                 check_pthread=no
171                 PTHREAD_DEFS=-D_THREAD_SAFE
172                 AC_MSG_RESULT([FreeBSD])
173         ;;
174         *-*-openbsd*)
175                 LIBS="-pthread $LIBS"
176                 check_pthread=no
177                 PTHREAD_DEFS=-pthread
178                 AC_MSG_RESULT([OpenBSD])
179         ;;
180         *-*-linux*)
181                 PTHREAD_DEFS="-D_REENTRANT -pthread"
182                 AC_MSG_RESULT([Linux])
183         ;;
184         *-*-solaris*)
185                 PTHREAD_DEFS="-D_REENTRANT -D_PTHREADS"
186                 AC_MSG_RESULT([Solaris])
187         ;;
188         *-*-cygwin*)
189                 SERVER_LDFLAGS="-Wl,-subsystem,windows"
190                 AC_MSG_RESULT([Cygwin])
191         ;;
192         *)
193                 AC_MSG_RESULT([default])
194         ;;
195 esac
196 dnl DEFS="$DEFS $PTHREAD_DEFS"
197
198
199 dnl Checks for programs.
200 AC_PROG_CC
201
202 dnl Set up system-dependent compiler flags.
203 if test "$GCC" = yes; then
204         if test "$CC" = icc; then
205                 CFLAGS="$CFLAGS -w1"
206         else
207                 case "$host" in
208                         *-*-solaris*|alpha*-dec-osf*)
209                                 CFLAGS="$CFLAGS -Wall -Wcast-qual -Wcast-align -Wno-char-subscripts $PTHREAD_DEFS"
210                         ;;
211                         *)
212                         CFLAGS="$CFLAGS -Wall -Wcast-qual -Wcast-align -Wstrict-prototypes $PTHREAD_DEFS"
213                         ;;
214                 esac
215         fi
216 fi
217
218 if test "x$enable_pie" = xyes; then
219         save_CFLAGS="$CFLAGS"
220         save_LDFLAGS="$LDFLAGS"
221         CFLAGS="$CFLAGS -fpie"
222         LDFLAGS="$LDFLAGS -pie -fpie"
223         AC_CACHE_CHECK([whether compiler accepts -pie -fpie], ac_cv_pie_fpie,
224         [AC_TRY_LINK([], [],
225         ac_cv_pie_fpie=yes, ac_cv_pie_fpie=no)])
226         if test $ac_cv_pie_fpie = no; then
227                 CFLAGS="$save_CFLAGS"
228                 LDFLAGS="$save_LDFLAGS"
229         fi
230 fi
231
232 AC_PROG_INSTALL
233 AC_PROG_YACC
234 missing_dir=`cd $ac_aux_dir && pwd`
235 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
236 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
237
238 dnl Checks for system services.
239
240 dnl Check the size of various builtin types; see typesize.h (error)
241 AC_CHECK_SIZEOF(char, 0)
242 AC_CHECK_SIZEOF(short, 0)
243 AC_CHECK_SIZEOF(int, 0)
244 AC_CHECK_SIZEOF(long, 0)
245 dnl AC_CHECK_SIZEOF(long long, 0)
246
247 dnl Checks for libraries.
248
249 dnl We want to test for the following in libc before checking for their
250 dnl respective libraries, because some systems (like Irix) have both, and the
251 dnl non-libc versions may be broken.
252 AC_CHECK_FUNCS(crypt gethostbyname connect)
253
254 if test "$ac_cv_func_gethostbyname" = no; then
255         AC_CHECK_LIB(nsl, gethostbyname)
256 fi
257
258 if test "$ac_cv_func_connect" = no; then
259         AC_CHECK_LIB(socket, connect)
260 fi
261
262 dnl Check for Solaris realtime support
263 AC_CHECK_LIB(rt, sched_yield)
264
265 dnl Determine the system's authentication capabilities.
266 dnl We currently support PAM, standard getpwnam(), and getspnam()
267 dnl (Linux shadow passwords)
268
269         if test "$with_pam" = yes; then
270                 save_LIBS=$LIBS
271                 AC_CHECK_LIB(pam, pam_start, [chkpwd_LIBS="-lpam $chkpwd_LIBS"
272                         LIBS="-lpam $LIBS"])
273                 AC_CHECK_FUNCS(pam_start)
274                 test "$enable_chkpwd" != no && LIBS=$save_LIBS
275         fi
276         if test "$ac_cv_func_pam_start" = no -o "$with_pam" != yes; then
277                 save_LIBS=$LIBS
278                 AC_SEARCH_LIBS(getspnam, shadow, [
279                         if test "$ac_cv_search_getspnam" = -lshadow; then
280                                 chkpwd_LIBS="-lshadow $chkpwd_LIBS"
281                         fi])
282                 test "$enable_chkpwd" != no && LIBS=$save_LIBS
283                 if test "$ac_cv_func_crypt" = no; then
284                         AC_CHECK_LIB(crypt, crypt, [
285                                 chkpwd_LIBS="-lcrypt $chkpwd_LIBS"
286                                 test "$enable_chkpwd" = no && \
287                                         LIBS="-lcrypt $LIBS"])
288                 fi
289         fi
290         if test "$ac_cv_func_crypt" = yes -o "$ac_cv_lib_crypt_crypt" = yes -o "$ac_cv_func_pam_start" = yes; then
291                 if test "$enable_chkpwd" != no; then
292                         AC_DEFINE(ENABLE_CHKPWD)
293                         CHKPWD=chkpwd
294                 else
295                         AUTH=auth.lo
296                 fi
297         fi
298
299 test -f /usr/local/lib/libresolv.a && LDFLAGS="$LDFLAGS -L/usr/local/lib"
300 AC_CHECK_LIB(resolv, res_query, RESOLV="$RESOLV -lresolv")
301
302 if test "x$with_ncurses" != "xno"; then
303         AC_SEARCH_LIBS(tgetent, [ncurses curses termcap])
304         AC_SEARCH_LIBS(scrollok, [ncurses curses])
305         AC_SEARCH_LIBS(initscr, [ncurses curses])
306 else
307         AC_SEARCH_LIBS(tgetent, [curses termcap])
308         AC_SEARCH_LIBS(initscr, [curses])
309 fi
310 AC_CHECK_FUNCS(vw_printw wcolor_set resizeterm wresize)
311
312 dnl Check for libpthread(s) if we're not using Digital UNIX or FreeBSD. (On
313 dnl which the -pthread flag takes care of this.)
314 if test "$check_pthread" != no; then
315         AC_CHECK_LIB(pthread, pthread_create)
316         AC_CHECK_LIB(pthreads, pthread_create)
317 fi
318
319 test -d /usr/kerberos/include && CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
320
321 # The big search for OpenSSL
322 if test "$with_ssl" != "no"; then
323         saved_LIBS="$LIBS"
324         saved_LDFLAGS="$LDFLAGS"
325         saved_CFLAGS="$CFLAGS"
326         if test "x$prefix" != "xNONE"; then
327                 tryssldir="$tryssldir $prefix"
328         fi
329         AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
330                 for ssldir in $tryssldir "" /usr /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/pkg /opt /opt/openssl ; do
331                         CFLAGS="$saved_CFLAGS"
332                         LDFLAGS="$saved_LDFLAGS"
333                         LIBS="$saved_LIBS -lssl -lcrypto"
334         
335                         # Skip directories if they don't exist
336                         if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
337                                 continue;
338                         fi
339                         if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
340                                 # Try to use $ssldir/lib if it exists, otherwise
341                                 # $ssldir
342                                 if test -d "$ssldir/lib" ; then
343                                         LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
344                                         if test ! -z "$need_dash_r" ; then
345                                                 LDFLAGS="-R$ssldir/lib $LDFLAGS"
346                                         fi
347                                 else
348                                         LDFLAGS="-L$ssldir $saved_LDFLAGS"
349                                         if test ! -z "$need_dash_r" ; then
350                                                 LDFLAGS="-R$ssldir $LDFLAGS"
351                                         fi
352                                 fi
353                                 # Try to use $ssldir/include if it exists, otherwise
354                                 # $ssldir
355                                 if test -d "$ssldir/include" ; then
356                                         CFLAGS="-I$ssldir/include $saved_CFLAGS"
357                                 else
358                                         CFLAGS="-I$ssldir $saved_CFLAGS"
359                                 fi
360                         fi
361         
362                         # Basic test to check for compatible version and correct linking
363                         # *does not* test for RSA - that comes later.
364                         AC_TRY_RUN(
365                                 [
366         #include <string.h>
367         #include <openssl/rand.h>
368         int main(void)
369         {
370                 char a[2048];
371                 memset(a, 0, sizeof(a));
372                 RAND_add(a, sizeof(a), sizeof(a));
373                 return(RAND_status() <= 0);
374         }
375                                 ],
376                                 [
377                                         found_crypto=1
378                                         break;
379                                 ], []
380                         )
381         
382                         if test ! -z "$found_crypto" ; then
383                                 break;
384                         fi
385                 done
386         
387                 if test -z "$ssldir" ; then
388                         ssldir="(system)"
389                 fi
390         
391                 if test ! -z "$found_crypto" ; then
392                         ac_cv_openssldir=$ssldir
393                 else
394                         ac_cv_openssldir="no"
395                 fi
396         ])
397         LIBS="$saved_LIBS"
398         LDFLAGS="$saved_LDFLAGS"
399         CFLAGS="$saved_CFLAGS"
400         
401         if test "x$ac_cv_openssldir" != "xno" ; then
402                 AC_DEFINE(HAVE_OPENSSL)
403                 LIBS="-lssl -lcrypto $LIBS"
404                 dnl Need to recover ssldir - test above runs in subshell
405                 ssldir=$ac_cv_openssldir
406                 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
407                         # Try to use $ssldir/lib if it exists, otherwise
408                         # $ssldir
409                         if test -d "$ssldir/lib" ; then
410                                 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
411                                 if test ! -z "$need_dash_r" ; then
412                                         LDFLAGS="-R$ssldir/lib $LDFLAGS"
413                                 fi
414                         else
415                                 LDFLAGS="-L$ssldir $saved_LDFLAGS"
416                                 if test ! -z "$need_dash_r" ; then
417                                         LDFLAGS="-R$ssldir $LDFLAGS"
418                                 fi
419                         fi
420                         # Try to use $ssldir/include if it exists, otherwise
421                         # $ssldir
422                         if test -d "$ssldir/include" ; then
423                                 CFLAGS="-I$ssldir/include $saved_CFLAGS"
424                         else
425                                 CFLAGS="-I$ssldir $saved_CFLAGS"
426                         fi
427                 fi
428         fi
429 fi
430
431 if test "x$with_db" != xno; then
432         test "$db_dir" && LDFLAGS="$LDFLAGS -L$db_dir/lib"
433
434         dblib=""
435
436         if test -d "$db_dir/include/db4"; then
437                 CPPFLAGS="$CPPFLAGS -I$db_dir/include/db4"
438                 dblib="db4"
439         elif test "$db_dir"; then
440                 CPPFLAGS="$CPPFLAGS -I$db_dir/include"
441         elif test -d /usr/include/db4; then
442                 CPPFLAGS="$CPPFLAGS -I/usr/include/db4"
443                 dblib="db4"
444         fi
445
446
447         AC_CHECK_DB([db db-4.1 db-4 db4],
448                     [
449                      DATABASE=database_sleepycat.c
450                     ],
451                     AC_MSG_ERROR([[Can not locate a suitable Berkeley DB
452                                   library.  Use --with-db=PATH to specify
453                                   the path]]))
454
455 fi
456
457 dnl Checks for the zlib compression library.
458 if test "x$with_zlib" != xno ; then
459         AC_CHECK_HEADERS(zlib.h,
460                 [AC_CHECK_LIB(z, zlibVersion,
461                         [ok_zlib=yes],,
462         )])
463 fi
464
465 if test "x$ok_zlib" = xyes ; then
466         SERVER_LIBS="-lz $SERVER_LIBS"
467         AC_DEFINE(HAVE_ZLIB)
468 fi
469
470
471
472
473 dnl Checks for the OpenLDAP client library.
474 if test "x$with_ldap" != xno ; then
475         AC_CHECK_HEADERS(ldap.h,
476                 [AC_CHECK_LIB(ldap, ldap_init,
477                         [ok_ldap=yes],,
478         )])
479 fi
480
481 if test "x$ok_ldap" = xyes ; then
482         SERVER_LIBS="-lldap $SERVER_LIBS"
483         AC_DEFINE(HAVE_LDAP)
484 fi
485
486
487
488
489
490 dnl Checks for the libsieve mailbox sorting library.
491 if test "x$with_libsieve" != xno ; then
492         AC_CHECK_HEADERS(sieve2.h,
493                 [AC_CHECK_LIB(sieve, sieve2_license,
494                         [ok_libsieve=yes],,
495         )])
496 fi
497
498 if test "x$ok_libsieve" = xyes ; then
499         SERVER_LIBS="-lsieve $SERVER_LIBS"
500         AC_DEFINE(HAVE_LIBSIEVE)
501 fi
502
503
504
505
506 dnl Checks for the libical calendaring library.
507 if test "x$with_libical" != xno ; then
508         AC_CHECK_HEADERS(ical.h,
509                 [AC_CHECK_LIB(ical, icalcomponent_new,
510                         [ok_libical=yes],,
511         )])
512 fi
513
514 if test "x$ok_libical" = xyes ; then
515
516         AC_TRY_RUN(
517                 [
518 #include <ical.h>
519 main() {
520         int major, minor, v;
521         sscanf(ICAL_VERSION, "%d.%d", &major, &minor);
522         v = 100*major + minor;
523         printf("libical version: %i\n", v);
524         if (v >= 24) {
525                 printf("This version is ok.\n");
526                 return(0);
527         }
528         printf("libical 0.24 or newer required.\n");
529         printf("Citadel will be built without calendar support.\n");
530         return(1);
531 }
532                 ], 
533                 [
534                         SERVER_LIBS="-lical $SERVER_LIBS"
535                         AC_DEFINE(HAVE_LIBICAL)
536                 ]
537         )
538 fi
539
540
541
542
543 dnl Checks for header files.
544 AC_HEADER_DIRENT
545 AC_HEADER_STDC
546 AC_HEADER_SYS_WAIT
547
548 dnl
549 dnl TODO: for the DB header checks, we should check whether the headers
550 dnl define db_env_create, somehow
551 dnl
552 AC_CHECK_HEADERS(curses.h dl.h fcntl.h limits.h malloc.h termios.h sys/ioctl.h sys/select.h sys/time.h sys/prctl.h syslog.h unistd.h utmp.h utmpx.h paths.h db.h db4/db.h pthread.h netinet/in.h arpa/nameser.h arpa/nameser_compat.h)
553
554 dnl
555 dnl need to check if this is actually compilable, sometimes there are
556 dnl conflicts with the system's headers (eg solaris xpg4 style headers)
557 dnl
558 if test "x$with_ncurses" != xno; then
559         AC_CHECK_HEADERS(ncurses.h,,,[ ])
560 fi
561
562 AC_CHECK_HEADER(resolv.h,AC_DEFINE(HAVE_RESOLV_H),,
563 [#ifdef HAVE_SYS_TYPES_H
564 #include <sys/types.h>
565 #endif
566 #ifdef HAVE_NETINET_IN_H
567 #include <netinet/in.h>
568 #endif
569 #ifdef HAVE_ARPA_NAMESER_H
570 #include <arpa/nameser.h>
571 #endif])
572
573
574 dnl Checks for typedefs, structures, and compiler characteristics.
575 AC_C_CONST
576 AC_TYPE_PID_T
577 AC_TYPE_SIZE_T
578 AC_HEADER_TIME
579
580 dnl defined in acinclude.m4:
581 CIT_STRUCT_TM
582
583 AC_CACHE_CHECK([for ut_type in struct utmp], ac_cv_struct_ut_type,
584 [AC_TRY_COMPILE([#include <sys/types.h>
585 #include <utmp.h>], [struct utmp ut; ut.ut_type;],
586 ac_cv_struct_ut_type=yes, ac_cv_struct_ut_type=no)])
587 if test $ac_cv_struct_ut_type = yes; then
588         AC_DEFINE(HAVE_UT_TYPE)
589 fi
590
591 AC_CACHE_CHECK([for ut_host in struct utmp], ac_cv_struct_ut_host,
592 [AC_TRY_COMPILE([#include <sys/types.h>
593 #include <utmp.h>], [struct utmp ut; ut.ut_host;],
594 ac_cv_struct_ut_host=yes, ac_cv_struct_ut_host=no)])
595 if test $ac_cv_struct_ut_host = yes; then
596         AC_DEFINE(HAVE_UT_HOST)
597 fi
598
599 dnl Checks for library functions.
600 AC_FUNC_GETPGRP
601 AC_PROG_GCC_TRADITIONAL
602 AC_TYPE_SIGNAL
603 AC_FUNC_VPRINTF
604 AC_CHECK_FUNCS(getspnam getutxline mkdir mkfifo mktime rmdir select socket strerror strcasecmp strncasecmp)
605
606 dnl Now check for pthreads
607
608 dnl On some platforms, AC_CHECK_FUNC[S] doesn't work for pthreads programs;
609 dnl we need to include pthread.h
610
611 AC_CACHE_CHECK([for pthread_cancel], ac_cv_func_pthread_cancel,
612 [AC_TRY_LINK([#include <pthread.h>],
613 [       pthread_t thread;
614
615         /* The GNU C library defines this for functions which it implements
616            to always fail with ENOSYS.  Some functions are actually named
617            something starting with __ and the normal name is an alias.  */
618 #if defined (__stub_pthread_cancel) || defined (__stub___pthread_cancel)
619         choke me
620 #else
621         pthread_cancel(thread);
622 #endif],
623 ac_cv_func_pthread_cancel=yes, ac_cv_func_pthread_cancel=no)])
624 if test "$ac_cv_func_pthread_cancel" = yes; then
625         AC_DEFINE(HAVE_PTHREAD_CANCEL)
626 fi
627
628 AC_CACHE_CHECK([for pthread_create], ac_cv_func_pthread_create,
629 [AC_TRY_LINK([#include <pthread.h>],
630 [       /* The GNU C library defines this for functions which it implements
631            to always fail with ENOSYS.  Some functions are actually named
632            something starting with __ and the normal name is an alias.  */
633 #if defined (__stub_pthread_cancel) || defined (__stub___pthread_cancel)
634         choke me
635 #else
636         pthread_create(NULL, NULL, NULL, NULL);
637 #endif],
638 ac_cv_func_pthread_create=yes, ac_cv_func_pthread_create=no)])
639 if test "$ac_cv_func_pthread_create" = yes; then
640         test "$DATABASE" && TARGETS="client server utils"
641         if test "x$enable_threaded_client" != xno; then
642                 AC_DEFINE(THREADED_CLIENT)
643         fi
644 fi
645
646 AC_REPLACE_FUNCS(snprintf getutline)
647
648 # AC_CACHE_CHECK([the weather], ac_cv_weather, [
649 #       sleep 1
650 #       echo $ECHO_N "opening your window... $ECHO_C" >&6
651 #       sleep 2
652 #       month=`date | cut -f 2 -d ' '`
653 #       case $month in
654 #       Dec | Jan | Feb)
655 #               ac_cv_weather="it's cold!"
656 #               ;;
657 #       Mar | Apr)
658 #               ac_cv_weather="it's wet!"
659 #               ;;
660 #       Jul | Aug)
661 #               ac_cv_weather="it's hot!"
662 #               ;;
663 #       Oct | Nov)
664 #               ac_cv_weather="it's cool"
665 #               ;;
666 #       May | Jun | Sep | *)
667 #               ac_cv_weather="it's fine"
668 #               ;;
669 #       esac
670 #       ])
671
672
673
674 AC_CACHE_CHECK([under the bed], ac_cv_under_the_bed, [
675         number=`date | cut -c 19`
676         case $number in
677         7)
678                 ac_cv_under_the_bed="lunatics and monsters found"
679                 ;;
680         *)
681                 ac_cv_under_the_bed="dust bunnies found"
682                 ;;
683         esac
684         ])
685
686 dnl Done! Now write the Makefile and sysdep.h
687 AC_SUBST(AUTH)
688 AC_SUBST(CHKPWD)
689 AC_SUBST(RESOLV)
690 AC_SUBST(chkpwd_LIBS)
691 AC_SUBST(TARGETS)
692 AC_SUBST(DATABASE)
693 AC_SUBST(SERVER_LDFLAGS)
694 AC_SUBST(SERVER_LIBS)
695 AC_SUBST(SETUP_LIBS)
696 AC_CONFIG_HEADER(sysdep.h)
697 AC_CONFIG_FILES([Makefile])
698 AC_OUTPUT(database_cleanup.sh)
699
700 if test -z "$DATABASE"; then
701         AC_MSG_WARN([No database driver was found. Please install Berkeley DB.])
702 fi
703
704 echo ------------------------------------------------------------------------
705 echo 'zlib compression:                ' $ok_zlib
706 echo 'Calendar support:                ' $ok_libical
707 echo 'LDAP support:                    ' $ok_ldap
708 echo 'Sieve mailbox filtering support: ' $ok_libsieve
709 echo 
710 echo 'Note: if you are not using Linux, make sure you are using GNU make'
711 echo '(gmake) to compile Citadel.'
712 echo