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