1 dnl Process this file with autoconf to produce a configure script.
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"
12 AC_DEFINE_UNQUOTED(CTDLDIR, "$prefix")
13 ssl_dir="$prefix/keys"
17 dnl Make sure we see all GNU and Solaris extensions.
21 dnl Checks for the 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)
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.
38 [ --with-ssldir directory to store the ssl certificates under],
39 [ if test "x$withval" != "xno" ; then
43 AC_SUBST(MAKE_SSL_DIR)
46 AC_DEFINE_UNQUOTED(SSL_DIR, "$ssl_dir", [were should we put our keys?])
49 dnl Checks for the 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)
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")
69 AC_SUBST(MAKE_ETC_DIR)
75 dnl Checks for the run-dir for the sockets
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")
82 AC_SUBST(MAKE_RUN_DIR)
88 dnl Checks for the Pseudo Random Generator sockets TODO: this keeps being default.
89 AC_DEFINE_UNQUOTED(EGD_POOL, "/var/run/egd-pool")
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")
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)
110 AC_ARG_ENABLE(chkpwd, [ --disable-chkpwd don't build 'chkpwd'])
112 AC_ARG_ENABLE(threaded-client, [ --disable-threaded-client
113 disable multithreaded client])
115 AC_ARG_ENABLE(pie, [ --enable-pie build position-independent executables])
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@:>@@:>@])
121 [ --with-ssl=PATH Specify path to OpenSSL installation ],
123 if test "x$withval" != "xno" ; then
128 AC_ARG_WITH(ncurses, [ --without-ncurses don't use ncurses])
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])
135 if test "x$with_db" != xno -a "x$with_db" != xyes -a "$with_db"; then
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 \
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
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.
153 PTHREAD_DEFS=-D_REENTRANT
154 AC_MSG_CHECKING([how to compile with POSIX threads])
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.
160 test -z "$CC" -a -x /usr/bin/shlicc2 && CC=shlicc2
161 AC_DEFINE(HAVE_NONREENTRANT_NETDB)
162 AC_MSG_RESULT([Old BSDI])
165 AC_DEFINE(HAVE_NONREENTRANT_NETDB)
166 AC_MSG_RESULT([BSD/OS])
168 dnl Curses support on Mac OS X is kind of screwed at the moment.
170 AC_DEFINE(DISABLE_CURSES)
171 AC_MSG_RESULT([Mac OS X])
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.
176 test -z "$CC" && CC=cc
177 LIBS="-lpthread -lexc $LIBS"
179 AC_MSG_RESULT([Tru64 or Digital UNIX])
181 dnl FreeBSD is similar to Digital UNIX with DEC C, which has a -pthread flag:
183 if test "$with_kthread" = yes; then
184 LIBS="-kthread $LIBS"
186 LIBS="-pthread $LIBS"
189 PTHREAD_DEFS=-D_THREAD_SAFE
190 AC_MSG_RESULT([FreeBSD])
193 LIBS="-pthread $LIBS"
195 PTHREAD_DEFS=-pthread
196 AC_MSG_RESULT([OpenBSD])
199 PTHREAD_DEFS="-D_REENTRANT -pthread"
200 AC_MSG_RESULT([Linux])
203 PTHREAD_DEFS="-D_REENTRANT -D_PTHREADS"
204 AC_MSG_RESULT([Solaris])
207 SERVER_LDFLAGS="-Wl,-subsystem,windows"
208 AC_MSG_RESULT([Cygwin])
211 AC_MSG_RESULT([default])
214 dnl DEFS="$DEFS $PTHREAD_DEFS"
217 dnl Checks for programs.
220 dnl Set up system-dependent compiler flags.
221 if test "$GCC" = yes; then
222 if test "$CC" = icc; then
226 *-*-solaris*|alpha*-dec-osf*)
227 CFLAGS="$CFLAGS -Wall -Wcast-qual -Wcast-align -Wno-char-subscripts $PTHREAD_DEFS"
230 CFLAGS="$CFLAGS -Wall -Wcast-qual -Wcast-align -Wstrict-prototypes $PTHREAD_DEFS"
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,
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"
252 missing_dir=`cd $ac_aux_dir && pwd`
253 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
254 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
256 dnl Checks for system services.
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)
265 dnl Checks for libraries.
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)
272 if test "$ac_cv_func_gethostbyname" = no; then
273 AC_CHECK_LIB(nsl, gethostbyname)
276 if test "$ac_cv_func_connect" = no; then
277 AC_CHECK_LIB(socket, connect)
280 dnl Check for Solaris realtime support
281 AC_CHECK_LIB(rt, sched_yield)
283 dnl Determine the system's authentication capabilities.
284 dnl We currently support PAM, standard getpwnam(), and getspnam()
285 dnl (Linux shadow passwords)
287 if test "$with_pam" = yes; then
289 AC_CHECK_LIB(pam, pam_start, [chkpwd_LIBS="-lpam $chkpwd_LIBS"
291 AC_CHECK_FUNCS(pam_start)
292 test "$enable_chkpwd" != no && LIBS=$save_LIBS
294 if test "$ac_cv_func_pam_start" = no -o "$with_pam" != yes; then
296 AC_SEARCH_LIBS(getspnam, shadow, [
297 if test "$ac_cv_search_getspnam" = -lshadow; then
298 chkpwd_LIBS="-lshadow $chkpwd_LIBS"
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"])
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)
317 test -f /usr/local/lib/libresolv.a && LDFLAGS="$LDFLAGS -L/usr/local/lib"
318 AC_CHECK_LIB(resolv, res_query, RESOLV="$RESOLV -lresolv")
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])
325 AC_SEARCH_LIBS(tgetent, [curses termcap])
326 AC_SEARCH_LIBS(initscr, [curses])
328 AC_CHECK_FUNCS(vw_printw wcolor_set resizeterm wresize)
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)
337 test -d /usr/kerberos/include && CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
339 # The big search for OpenSSL
340 if test "$with_ssl" != "no"; then
342 saved_LDFLAGS="$LDFLAGS"
343 saved_CFLAGS="$CFLAGS"
344 if test "x$prefix" != "xNONE"; then
345 tryssldir="$tryssldir $prefix"
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"
353 # Skip directories if they don't exist
354 if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
357 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
358 # Try to use $ssldir/lib if it exists, otherwise
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"
366 LDFLAGS="-L$ssldir $saved_LDFLAGS"
367 if test ! -z "$need_dash_r" ; then
368 LDFLAGS="-R$ssldir $LDFLAGS"
371 # Try to use $ssldir/include if it exists, otherwise
373 if test -d "$ssldir/include" ; then
374 CFLAGS="-I$ssldir/include $saved_CFLAGS"
376 CFLAGS="-I$ssldir $saved_CFLAGS"
380 # Basic test to check for compatible version and correct linking
381 # *does not* test for RSA - that comes later.
385 #include <openssl/rand.h>
389 memset(a, 0, sizeof(a));
390 RAND_add(a, sizeof(a), sizeof(a));
391 return(RAND_status() <= 0);
400 if test ! -z "$found_crypto" ; then
405 if test -z "$ssldir" ; then
409 if test ! -z "$found_crypto" ; then
410 ac_cv_openssldir=$ssldir
412 ac_cv_openssldir="no"
416 LDFLAGS="$saved_LDFLAGS"
417 CFLAGS="$saved_CFLAGS"
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
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"
433 LDFLAGS="-L$ssldir $saved_LDFLAGS"
434 if test ! -z "$need_dash_r" ; then
435 LDFLAGS="-R$ssldir $LDFLAGS"
438 # Try to use $ssldir/include if it exists, otherwise
440 if test -d "$ssldir/include" ; then
441 CFLAGS="-I$ssldir/include $saved_CFLAGS"
443 CFLAGS="-I$ssldir $saved_CFLAGS"
449 if test "x$with_db" != xno; then
450 test "$db_dir" && LDFLAGS="$LDFLAGS -L$db_dir/lib"
454 if test -d "$db_dir/include/db4"; then
455 CPPFLAGS="$CPPFLAGS -I$db_dir/include/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"
465 AC_CHECK_DB([db db-4.1 db-4 db4],
467 DATABASE=database_sleepycat.c
469 AC_MSG_ERROR([[Can not locate a suitable Berkeley DB
470 library. Use --with-db=PATH to specify
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,
483 if test "x$ok_zlib" = xyes ; then
484 SERVER_LIBS="-lz $SERVER_LIBS"
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,
499 if test "x$ok_ldap" = xyes ; then
500 SERVER_LIBS="-lldap $SERVER_LIBS"
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,
516 if test "x$ok_libsieve" = xyes ; then
517 SERVER_LIBS="-lsieve $SERVER_LIBS"
518 AC_DEFINE(HAVE_LIBSIEVE)
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,
532 if test "x$ok_libical" = xyes ; then
539 sscanf(ICAL_VERSION, "%d.%d", &major, &minor);
540 v = 100*major + minor;
541 printf("libical version: %i\n", v);
543 printf("This version is ok.\n");
546 printf("libical 0.24 or newer required.\n");
547 printf("Citadel will be built without calendar support.\n");
552 SERVER_LIBS="-lical $SERVER_LIBS"
553 AC_DEFINE(HAVE_LIBICAL)
561 dnl Checks for header files.
567 dnl TODO: for the DB header checks, we should check whether the headers
568 dnl define db_env_create, somehow
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)
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)
576 if test "x$with_ncurses" != xno; then
577 AC_CHECK_HEADERS(ncurses.h,,,[ ])
580 AC_CHECK_HEADER(resolv.h,AC_DEFINE(HAVE_RESOLV_H),,
581 [#ifdef HAVE_SYS_TYPES_H
582 #include <sys/types.h>
584 #ifdef HAVE_NETINET_IN_H
585 #include <netinet/in.h>
587 #ifdef HAVE_ARPA_NAMESER_H
588 #include <arpa/nameser.h>
592 dnl Checks for typedefs, structures, and compiler characteristics.
598 dnl defined in acinclude.m4:
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)
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)
617 dnl Checks for library functions.
619 AC_PROG_GCC_TRADITIONAL
622 AC_CHECK_FUNCS(getspnam getutxline mkdir mkfifo mktime rmdir select socket strerror strcasecmp strncasecmp)
624 dnl Now check for pthreads
626 dnl On some platforms, AC_CHECK_FUNC[S] doesn't work for pthreads programs;
627 dnl we need to include pthread.h
629 AC_CACHE_CHECK([for pthread_cancel], ac_cv_func_pthread_cancel,
630 [AC_TRY_LINK([#include <pthread.h>],
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)
639 pthread_cancel(thread);
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)
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)
654 pthread_create(NULL, NULL, NULL, NULL);
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)
664 AC_REPLACE_FUNCS(snprintf getutline)
666 # AC_CACHE_CHECK([the weather], ac_cv_weather, [
668 # echo $ECHO_N "opening your window... $ECHO_C" >&6
670 # month=`date | cut -f 2 -d ' '`
673 # ac_cv_weather="it's cold!"
676 # ac_cv_weather="it's wet!"
679 # ac_cv_weather="it's hot!"
682 # ac_cv_weather="it's cool"
684 # May | Jun | Sep | *)
685 # ac_cv_weather="it's fine"
692 AC_CACHE_CHECK([under the bed], ac_cv_under_the_bed, [
693 number=`date | cut -c 19`
696 ac_cv_under_the_bed="lunatics and monsters found"
699 ac_cv_under_the_bed="dust bunnies found"
704 AC_MSG_CHECKING([for reality distorion field])
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.
709 AC_DEFINE(HAVE_DARWIN)
710 AC_MSG_RESULT([present])
713 AC_MSG_RESULT([missing])
716 dnl Done! Now write the Makefile and sysdep.h
720 AC_SUBST(chkpwd_LIBS)
723 AC_SUBST(SERVER_LDFLAGS)
724 AC_SUBST(SERVER_LIBS)
726 AC_CONFIG_HEADER(sysdep.h)
727 AC_CONFIG_FILES([Makefile])
728 AC_OUTPUT(database_cleanup.sh)
730 if test -z "$DATABASE"; then
731 AC_MSG_WARN([No database driver was found. Please install Berkeley DB.])
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
740 echo 'Note: if you are not using Linux, make sure you are using GNU make'
741 echo '(gmake) to compile Citadel.'