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