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