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