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