1 dnl Process this file with autoconf to produce a configure script.
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")
11 AC_DEFINE_UNQUOTED(CTDLDIR, "$prefix")
15 dnl Make sure we see all GNU and Solaris extensions.
19 dnl Checks for the Datadir
21 [ --with-datadir directory to store the databases under],
22 [ if test "x$withval" != "xno" ; then
23 AC_DEFINE(HAVE_DATA_DIR)
24 AC_DEFINE_UNQUOTED(DATA_DIR, "$withval")
25 MAKE_DATA_DIR=$withval
26 AC_SUBST(MAKE_DATA_DIR)
31 dnl Checks for the spooldir
33 [ --with-spooldir directory to keep queues under],
34 [ if test "x$withval" != "xno" ; then
35 AC_DEFINE(HAVE_SPOOL_DIR)
36 AC_DEFINE_UNQUOTED(SPOOL_DIR,"$withval")
37 MAKE_SPOOL_DIR=$withval
38 AC_SUBST(MAKE_SPOOL_DIR)
44 dnl Checks for the Configdir
45 AC_ARG_WITH(sysconfdir,
46 [ --with-sysconfdir directory to store the configs under],
47 [ if test "x$withval" != "xno" ; then
48 AC_DEFINE(HAVE_ETC_DIR)
49 AC_DEFINE_UNQUOTED(ETC_DIR, "$withval")
51 AC_SUBST(MAKE_ETC_DIR)
57 dnl Checks for the run-dir for the sockets
59 [ --with-rundir directory to store the configs under],
60 [ if test "x$withval" != "xno" ; then
61 AC_DEFINE(HAVE_RUN_DIR)
62 AC_DEFINE_UNQUOTED(RUN_DIR, "$withval")
64 AC_SUBST(MAKE_RUN_DIR)
70 dnl Checks for the Pseudo Random Generator sockets TODO: this keeps being default.
71 AC_DEFINE_UNQUOTED(EGD_POOL, "/var/run/egd-pool")
73 [ --with-egdpool the socket from Pseudo Random Generator, defaults to /var/run/egd-pool],
74 [ if test "x$withval" != "xno" ; then
75 AC_DEFINE_UNQUOTED(EGD_POOL, "$withval")
82 [ --with-docdir where to install the documentation. default: /usr/local/citadel/],
83 [ if test "x$withval" != "xno" ; then
85 AC_SUBST(MAKE_DOC_DIR)
92 AC_ARG_ENABLE(autologin, [ --enable-autologin enable autologin (default is disabled)])
93 AC_ARG_ENABLE(chkpwd, [ --disable-chkpwd don't build 'chkpwd'])
95 AC_ARG_ENABLE(threaded-client, [ --disable-threaded-client
96 disable multithreaded client])
98 AC_ARG_ENABLE(pie, [ --enable-pie build position-independent executables])
100 AC_ARG_WITH(pam, [ --with-pam use PAM if present (see PAM.txt before you try this)])
101 AC_ARG_WITH(kthread, [ --with-kthread use kernel threads (on FreeBSD) (not recommended yet)])
102 AC_ARG_WITH(db, [ --with-db@<:@=DIR@:>@ use Sleepycat DB 3.x @<:@DIR=/usr/local/BerkeleyDB.3.@<:@123@:>@@:>@])
104 [ --with-ssl=PATH Specify path to OpenSSL installation ],
106 if test "x$withval" != "xno" ; then
111 AC_ARG_WITH(ncurses, [ --without-ncurses don't use ncurses])
113 AC_ARG_WITH(with_zlib, [ --with-zlib use zlib compression if present])
114 AC_ARG_WITH(with_ldap, [ --with-ldap use OpenLDAP client library])
115 AC_ARG_WITH(with_libical, [ --with-libical use libical calendaring library])
116 AC_ARG_WITH(with_libsieve, [ --with-libsieve use libsieve mail sorting library])
117 AC_ARG_WITH(with_newt, [ --with-newt use newt window library])
119 if test "x$with_db" != xno -a "x$with_db" != xyes -a "$with_db"; then
123 test -f /usr/local/lib/libdb.a -o -f /usr/local/lib/libdb.so \
124 -o -f /usr/local/lib/libdb4.a -o -f /usr/local/lib/libdb4.so \
127 test -d /usr/local/BerkeleyDB.4.1 && db_dir=/usr/local/BerkeleyDB.4.1
128 test -d /usr/local/BerkeleyDB.4.2 && db_dir=/usr/local/BerkeleyDB.4.2
129 test -d /usr/local/BerkeleyDB.4.3 && db_dir=/usr/local/BerkeleyDB.4.3
132 dnl By default, we only build the client (citadel and whobbs) unless we can
133 dnl figure out how to build with POSIX threads.
137 PTHREAD_DEFS=-D_REENTRANT
138 AC_MSG_CHECKING([how to compile with POSIX threads])
140 dnl BSDI 3.0 wants relocatable object modules instead of shared libs
141 dnl for dlopen(), and has a wrapper script to link with shared libs.
142 dnl Also has stupid non-reentrant gethostbyaddr() and friends.
144 test -z "$CC" -a -x /usr/bin/shlicc2 && CC=shlicc2
145 AC_DEFINE(HAVE_NONREENTRANT_NETDB)
146 AC_MSG_RESULT([Old BSDI])
149 AC_DEFINE(HAVE_NONREENTRANT_NETDB)
150 AC_MSG_RESULT([BSD/OS])
152 dnl Curses support on Mac OS X is kind of screwed at the moment.
154 AC_DEFINE(DISABLE_CURSES)
155 AC_MSG_RESULT([Mac OS X])
157 dnl Digital Unix has an odd way to build for pthreads, and we can't
158 dnl build pthreads programs with gcc due to header problems.
160 test -z "$CC" && CC=cc
161 LIBS="-lpthread -lexc $LIBS"
163 AC_MSG_RESULT([Tru64 or Digital UNIX])
165 dnl FreeBSD is similar to Digital UNIX with DEC C, which has a -pthread flag:
167 if test "$with_kthread" = yes; then
168 LIBS="-kthread $LIBS"
170 LIBS="-pthread $LIBS"
173 PTHREAD_DEFS=-D_THREAD_SAFE
174 AC_MSG_RESULT([FreeBSD])
177 LIBS="-pthread $LIBS"
179 PTHREAD_DEFS=-pthread
180 AC_MSG_RESULT([OpenBSD])
183 PTHREAD_DEFS="-D_REENTRANT -pthread"
184 AC_MSG_RESULT([Linux])
187 PTHREAD_DEFS="-D_REENTRANT -D_PTHREADS"
188 AC_MSG_RESULT([Solaris])
191 SERVER_LDFLAGS="-Wl,-subsystem,windows"
192 AC_MSG_RESULT([Cygwin])
195 AC_MSG_RESULT([default])
198 dnl DEFS="$DEFS $PTHREAD_DEFS"
201 dnl Checks for programs.
204 dnl Set up system-dependent compiler flags.
205 if test "$GCC" = yes; then
206 if test "$CC" = icc; then
210 *-*-solaris*|alpha*-dec-osf*)
211 CFLAGS="$CFLAGS -Wall -Wcast-qual -Wcast-align -Wno-char-subscripts $PTHREAD_DEFS"
214 CFLAGS="$CFLAGS -Wall -Wcast-qual -Wcast-align -Wstrict-prototypes $PTHREAD_DEFS"
220 if test "x$enable_pie" = xyes; then
221 save_CFLAGS="$CFLAGS"
222 save_LDFLAGS="$LDFLAGS"
223 CFLAGS="$CFLAGS -fpie"
224 LDFLAGS="$LDFLAGS -pie -fpie"
225 AC_CACHE_CHECK([whether compiler accepts -pie -fpie], ac_cv_pie_fpie,
227 ac_cv_pie_fpie=yes, ac_cv_pie_fpie=no)])
228 if test $ac_cv_pie_fpie = no; then
229 CFLAGS="$save_CFLAGS"
230 LDFLAGS="$save_LDFLAGS"
236 missing_dir=`cd $ac_aux_dir && pwd`
237 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
238 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
240 dnl Checks for system services.
242 dnl Check the size of various builtin types; see typesize.h (error)
243 AC_CHECK_SIZEOF(char, 0)
244 AC_CHECK_SIZEOF(short, 0)
245 AC_CHECK_SIZEOF(int, 0)
246 AC_CHECK_SIZEOF(long, 0)
247 dnl AC_CHECK_SIZEOF(long long, 0)
249 dnl Checks for libraries.
251 dnl We want to test for the following in libc before checking for their
252 dnl respective libraries, because some systems (like Irix) have both, and the
253 dnl non-libc versions may be broken.
254 AC_CHECK_FUNCS(crypt gethostbyname connect)
256 if test "$ac_cv_func_gethostbyname" = no; then
257 AC_CHECK_LIB(nsl, gethostbyname)
260 if test "$ac_cv_func_connect" = no; then
261 AC_CHECK_LIB(socket, connect)
264 dnl Check for Solaris realtime support
265 AC_CHECK_LIB(rt, sched_yield)
267 dnl Determine the system's authentication capabilities, if autologin is
268 dnl requested. We currently support PAM, standard getpwnam(), and getspnam()
269 dnl (Linux shadow passwords)
270 if test "$enable_autologin" = yes; then
271 if test "$with_pam" = yes; then
273 AC_CHECK_LIB(pam, pam_start, [chkpwd_LIBS="-lpam $chkpwd_LIBS"
275 AC_CHECK_FUNCS(pam_start)
276 test "$enable_chkpwd" != no && LIBS=$save_LIBS
278 if test "$ac_cv_func_pam_start" = no -o "$with_pam" != yes; then
280 AC_SEARCH_LIBS(getspnam, shadow, [
281 if test "$ac_cv_search_getspnam" = -lshadow; then
282 chkpwd_LIBS="-lshadow $chkpwd_LIBS"
284 test "$enable_chkpwd" != no && LIBS=$save_LIBS
285 if test "$ac_cv_func_crypt" = no; then
286 AC_CHECK_LIB(crypt, crypt, [
287 chkpwd_LIBS="-lcrypt $chkpwd_LIBS"
288 test "$enable_chkpwd" = no && \
289 LIBS="-lcrypt $LIBS"])
292 if test "$ac_cv_func_crypt" = yes -o "$ac_cv_lib_crypt_crypt" = yes -o "$ac_cv_func_pam_start" = yes; then
293 AC_DEFINE(ENABLE_AUTOLOGIN)
294 if test "$enable_chkpwd" != no; then
295 AC_DEFINE(ENABLE_CHKPWD)
303 test -f /usr/local/lib/libresolv.a && LDFLAGS="$LDFLAGS -L/usr/local/lib"
304 AC_CHECK_LIB(resolv, res_query, RESOLV="$RESOLV -lresolv")
306 if test "x$with_ncurses" != "xno"; then
307 AC_SEARCH_LIBS(tgetent, [ncurses curses termcap])
308 AC_SEARCH_LIBS(scrollok, [ncurses curses])
309 AC_SEARCH_LIBS(initscr, [ncurses curses])
311 AC_SEARCH_LIBS(tgetent, [curses termcap])
312 AC_SEARCH_LIBS(initscr, [curses])
314 AC_CHECK_FUNCS(vw_printw wcolor_set resizeterm wresize)
316 dnl Check for libpthread(s) if we're not using Digital UNIX or FreeBSD. (On
317 dnl which the -pthread flag takes care of this.)
318 if test "$check_pthread" != no; then
319 AC_CHECK_LIB(pthread, pthread_create)
320 AC_CHECK_LIB(pthreads, pthread_create)
323 test -d /usr/kerberos/include && CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
325 # The big search for OpenSSL
326 if test "$with_ssl" != "no"; then
328 saved_LDFLAGS="$LDFLAGS"
329 saved_CFLAGS="$CFLAGS"
330 if test "x$prefix" != "xNONE"; then
331 tryssldir="$tryssldir $prefix"
333 AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
334 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
335 CFLAGS="$saved_CFLAGS"
336 LDFLAGS="$saved_LDFLAGS"
337 LIBS="$saved_LIBS -lssl -lcrypto"
339 # Skip directories if they don't exist
340 if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
343 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
344 # Try to use $ssldir/lib if it exists, otherwise
346 if test -d "$ssldir/lib" ; then
347 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
348 if test ! -z "$need_dash_r" ; then
349 LDFLAGS="-R$ssldir/lib $LDFLAGS"
352 LDFLAGS="-L$ssldir $saved_LDFLAGS"
353 if test ! -z "$need_dash_r" ; then
354 LDFLAGS="-R$ssldir $LDFLAGS"
357 # Try to use $ssldir/include if it exists, otherwise
359 if test -d "$ssldir/include" ; then
360 CFLAGS="-I$ssldir/include $saved_CFLAGS"
362 CFLAGS="-I$ssldir $saved_CFLAGS"
366 # Basic test to check for compatible version and correct linking
367 # *does not* test for RSA - that comes later.
371 #include <openssl/rand.h>
375 memset(a, 0, sizeof(a));
376 RAND_add(a, sizeof(a), sizeof(a));
377 return(RAND_status() <= 0);
386 if test ! -z "$found_crypto" ; then
391 if test -z "$ssldir" ; then
395 if test ! -z "$found_crypto" ; then
396 ac_cv_openssldir=$ssldir
398 ac_cv_openssldir="no"
402 LDFLAGS="$saved_LDFLAGS"
403 CFLAGS="$saved_CFLAGS"
405 if test "x$ac_cv_openssldir" != "xno" ; then
406 AC_DEFINE(HAVE_OPENSSL)
407 LIBS="-lssl -lcrypto $LIBS"
408 dnl Need to recover ssldir - test above runs in subshell
409 ssldir=$ac_cv_openssldir
410 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
411 # Try to use $ssldir/lib if it exists, otherwise
413 if test -d "$ssldir/lib" ; then
414 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
415 if test ! -z "$need_dash_r" ; then
416 LDFLAGS="-R$ssldir/lib $LDFLAGS"
419 LDFLAGS="-L$ssldir $saved_LDFLAGS"
420 if test ! -z "$need_dash_r" ; then
421 LDFLAGS="-R$ssldir $LDFLAGS"
424 # Try to use $ssldir/include if it exists, otherwise
426 if test -d "$ssldir/include" ; then
427 CFLAGS="-I$ssldir/include $saved_CFLAGS"
429 CFLAGS="-I$ssldir $saved_CFLAGS"
435 if test "x$with_db" != xno; then
436 test "$db_dir" && LDFLAGS="$LDFLAGS -L$db_dir/lib"
440 if test -d "$db_dir/include/db4"; then
441 CPPFLAGS="$CPPFLAGS -I$db_dir/include/db4"
443 elif test "$db_dir"; then
444 CPPFLAGS="$CPPFLAGS -I$db_dir/include"
445 elif test -d /usr/include/db4; then
446 CPPFLAGS="$CPPFLAGS -I/usr/include/db4"
451 AC_CHECK_DB([db db-4.1 db-4 db4],
453 DATABASE=database_sleepycat.c
455 AC_MSG_ERROR([[Can not locate a suitable Berkeley DB
456 library. Use --with-db=PATH to specify
461 dnl Checks for the zlib compression library.
462 if test "x$with_zlib" != xno ; then
463 AC_CHECK_HEADERS(zlib.h,
464 [AC_CHECK_LIB(z, zlibVersion,
469 if test "x$ok_zlib" = xyes ; then
470 SERVER_LIBS="-lz $SERVER_LIBS"
477 dnl Checks for the OpenLDAP client library.
478 if test "x$with_ldap" != xno ; then
479 AC_CHECK_HEADERS(ldap.h,
480 [AC_CHECK_LIB(ldap, ldap_init,
485 if test "x$ok_ldap" = xyes ; then
486 SERVER_LIBS="-lldap $SERVER_LIBS"
493 dnl Checks for the newt window library.
494 if test "x$with_newt" != xno ; then
495 AC_CHECK_HEADERS(newt.h,
496 [AC_CHECK_LIB(newt, newtInit,
501 if test "x$ok_newt" = xyes ; then
502 SETUP_LIBS="-lnewt $SETUP_LIBS"
510 dnl Checks for the libsieve mailbox sorting library.
511 if test "x$with_libsieve" != xno ; then
512 AC_CHECK_HEADERS(sieve2.h,
513 [AC_CHECK_LIB(sieve, sieve2_license,
518 if test "x$ok_libsieve" = xyes ; then
519 SERVER_LIBS="-lsieve $SERVER_LIBS"
520 AC_DEFINE(HAVE_LIBSIEVE)
526 dnl Checks for the libical calendaring library.
527 if test "x$with_libical" != xno ; then
528 AC_CHECK_HEADERS(ical.h,
529 [AC_CHECK_LIB(ical, icalcomponent_new,
534 if test "x$ok_libical" = xyes ; then
541 sscanf(ICAL_VERSION, "%d.%d", &major, &minor);
542 v = 100*major + minor;
543 printf("libical version: %i\n", v);
545 printf("This version is ok.\n");
548 printf("libical 0.24 or newer required.\n");
549 printf("Citadel will be built without calendar support.\n");
554 SERVER_LIBS="-lical $SERVER_LIBS"
555 AC_DEFINE(HAVE_LIBICAL)
563 dnl Checks for header files.
569 dnl TODO: for the DB header checks, we should check whether the headers
570 dnl define db_env_create, somehow
572 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)
575 dnl need to check if this is actually compilable, sometimes there are
576 dnl conflicts with the system's headers (eg solaris xpg4 style headers)
578 if test "x$with_ncurses" != xno; then
579 AC_CHECK_HEADERS(ncurses.h,,,[ ])
582 AC_CHECK_HEADER(resolv.h,AC_DEFINE(HAVE_RESOLV_H),,
583 [#ifdef HAVE_SYS_TYPES_H
584 #include <sys/types.h>
586 #ifdef HAVE_NETINET_IN_H
587 #include <netinet/in.h>
589 #ifdef HAVE_ARPA_NAMESER_H
590 #include <arpa/nameser.h>
594 dnl Checks for typedefs, structures, and compiler characteristics.
600 dnl defined in acinclude.m4:
603 AC_CACHE_CHECK([for ut_type in struct utmp], ac_cv_struct_ut_type,
604 [AC_TRY_COMPILE([#include <sys/types.h>
605 #include <utmp.h>], [struct utmp ut; ut.ut_type;],
606 ac_cv_struct_ut_type=yes, ac_cv_struct_ut_type=no)])
607 if test $ac_cv_struct_ut_type = yes; then
608 AC_DEFINE(HAVE_UT_TYPE)
611 AC_CACHE_CHECK([for ut_host in struct utmp], ac_cv_struct_ut_host,
612 [AC_TRY_COMPILE([#include <sys/types.h>
613 #include <utmp.h>], [struct utmp ut; ut.ut_host;],
614 ac_cv_struct_ut_host=yes, ac_cv_struct_ut_host=no)])
615 if test $ac_cv_struct_ut_host = yes; then
616 AC_DEFINE(HAVE_UT_HOST)
619 dnl Checks for library functions.
621 AC_PROG_GCC_TRADITIONAL
624 AC_CHECK_FUNCS(getspnam getutxline mkdir mkfifo mktime rmdir select socket strerror strcasecmp strncasecmp)
626 dnl Now check for pthreads
628 dnl On some platforms, AC_CHECK_FUNC[S] doesn't work for pthreads programs;
629 dnl we need to include pthread.h
631 AC_CACHE_CHECK([for pthread_cancel], ac_cv_func_pthread_cancel,
632 [AC_TRY_LINK([#include <pthread.h>],
635 /* The GNU C library defines this for functions which it implements
636 to always fail with ENOSYS. Some functions are actually named
637 something starting with __ and the normal name is an alias. */
638 #if defined (__stub_pthread_cancel) || defined (__stub___pthread_cancel)
641 pthread_cancel(thread);
643 ac_cv_func_pthread_cancel=yes, ac_cv_func_pthread_cancel=no)])
644 if test "$ac_cv_func_pthread_cancel" = yes; then
645 AC_DEFINE(HAVE_PTHREAD_CANCEL)
648 AC_CACHE_CHECK([for pthread_create], ac_cv_func_pthread_create,
649 [AC_TRY_LINK([#include <pthread.h>],
650 [ /* The GNU C library defines this for functions which it implements
651 to always fail with ENOSYS. Some functions are actually named
652 something starting with __ and the normal name is an alias. */
653 #if defined (__stub_pthread_cancel) || defined (__stub___pthread_cancel)
656 pthread_create(NULL, NULL, NULL, NULL);
658 ac_cv_func_pthread_create=yes, ac_cv_func_pthread_create=no)])
659 if test "$ac_cv_func_pthread_create" = yes; then
660 test "$DATABASE" && TARGETS="client server utils"
661 if test "x$enable_threaded_client" != xno; then
662 AC_DEFINE(THREADED_CLIENT)
666 AC_REPLACE_FUNCS(snprintf getutline)
668 # AC_CACHE_CHECK([the weather], ac_cv_weather, [
670 # echo $ECHO_N "opening your window... $ECHO_C" >&6
672 # month=`date | cut -f 2 -d ' '`
675 # ac_cv_weather="it's cold!"
678 # ac_cv_weather="it's wet!"
681 # ac_cv_weather="it's hot!"
684 # ac_cv_weather="it's cool"
686 # May | Jun | Sep | *)
687 # ac_cv_weather="it's fine"
694 AC_CACHE_CHECK([under the bed], ac_cv_under_the_bed, [
695 number=`date | cut -c 19`
698 ac_cv_under_the_bed="lunatics and monsters found"
701 ac_cv_under_the_bed="dust bunnies found"
706 dnl Done! Now write the Makefile and sysdep.h
710 AC_SUBST(chkpwd_LIBS)
713 AC_SUBST(SERVER_LDFLAGS)
714 AC_SUBST(SERVER_LIBS)
716 AC_CONFIG_HEADER(sysdep.h)
717 AC_CONFIG_FILES([Makefile])
718 AC_OUTPUT(database_cleanup.sh)
720 if test -z "$DATABASE"; then
721 AC_MSG_WARN([No database driver was found. Please install Berkeley DB.])
724 echo ------------------------------------------------------------------------
725 echo 'zlib compression: ' $ok_zlib
726 echo 'Calendar support: ' $ok_libical
727 echo 'LDAP support: ' $ok_ldap
728 echo 'Sieve mailbox filtering support: ' $ok_libsieve
730 echo 'Note: if you are not using Linux, make sure you are using GNU make'
731 echo '(gmake) to compile Citadel.'