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