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")
14 dnl Checks for the 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")
24 dnl Checks for the 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")
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")
47 dnl Checks for the run-dir for the sockets
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")
58 dnl Checks for the Pseudo Random Generator sockets TODO: this keeps being default.
59 AC_DEFINE_UNQUOTED(EGD_POOL, "/var/run/egd-pool")
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")
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'])
74 AC_ARG_ENABLE(threaded-client, [ --disable-threaded-client
75 disable multithreaded client])
77 AC_ARG_ENABLE(pie, [ --enable-pie build position-independent executables])
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@:>@@:>@])
83 [ --with-ssl=PATH Specify path to OpenSSL installation ],
85 if test "x$withval" != "xno" ; then
90 AC_ARG_WITH(ncurses, [ --without-ncurses don't use ncurses])
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])
97 if test "x$with_db" != xno -a "x$with_db" != xyes -a "$with_db"; then
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 \
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
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.
115 PTHREAD_DEFS=-D_REENTRANT
116 AC_MSG_CHECKING([how to compile with POSIX threads])
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.
122 test -z "$CC" -a -x /usr/bin/shlicc2 && CC=shlicc2
123 AC_DEFINE(HAVE_NONREENTRANT_NETDB)
124 AC_MSG_RESULT([Old BSDI])
127 AC_DEFINE(HAVE_NONREENTRANT_NETDB)
128 AC_MSG_RESULT([BSD/OS])
130 dnl Curses support on Mac OS X is kind of screwed at the moment.
132 AC_DEFINE(DISABLE_CURSES)
133 AC_MSG_RESULT([Mac OS X])
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.
138 test -z "$CC" && CC=cc
139 LIBS="-lpthread -lexc $LIBS"
141 AC_MSG_RESULT([Tru64 or Digital UNIX])
143 dnl FreeBSD is similar to Digital UNIX with DEC C, which has a -pthread flag:
145 if test "$with_kthread" = yes; then
146 LIBS="-kthread $LIBS"
148 LIBS="-pthread $LIBS"
151 PTHREAD_DEFS=-D_THREAD_SAFE
152 AC_MSG_RESULT([FreeBSD])
155 LIBS="-pthread $LIBS"
157 PTHREAD_DEFS=-pthread
158 AC_MSG_RESULT([OpenBSD])
161 PTHREAD_DEFS="-D_REENTRANT -pthread"
162 AC_MSG_RESULT([Linux])
165 PTHREAD_DEFS="-D_REENTRANT -D_PTHREADS"
166 AC_MSG_RESULT([Solaris])
169 SERVER_LDFLAGS="-Wl,-subsystem,windows"
170 AC_MSG_RESULT([Cygwin])
173 AC_MSG_RESULT([default])
176 dnl DEFS="$DEFS $PTHREAD_DEFS"
179 dnl Checks for programs.
182 dnl Set up system-dependent compiler flags.
183 if test "$GCC" = yes; then
184 if test "$CC" = icc; then
188 *-*-solaris*|alpha*-dec-osf*)
189 CFLAGS="$CFLAGS -Wall -Wcast-qual -Wcast-align -Wno-char-subscripts $PTHREAD_DEFS"
192 CFLAGS="$CFLAGS -Wall -Wcast-qual -Wcast-align -Wstrict-prototypes $PTHREAD_DEFS"
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,
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"
214 missing_dir=`cd $ac_aux_dir && pwd`
215 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
216 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
218 dnl Checks for system services.
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)
227 dnl Checks for libraries.
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)
234 if test "$ac_cv_func_gethostbyname" = no; then
235 AC_CHECK_LIB(nsl, gethostbyname)
238 if test "$ac_cv_func_connect" = no; then
239 AC_CHECK_LIB(socket, connect)
242 dnl Check for Solaris realtime support
243 AC_CHECK_LIB(rt, sched_yield)
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
251 AC_CHECK_LIB(pam, pam_start, [chkpwd_LIBS="-lpam $chkpwd_LIBS"
253 AC_CHECK_FUNCS(pam_start)
254 test "$enable_chkpwd" != no && LIBS=$save_LIBS
256 if test "$ac_cv_func_pam_start" = no -o "$with_pam" != yes; then
258 AC_SEARCH_LIBS(getspnam, shadow, [
259 if test "$ac_cv_search_getspnam" = -lshadow; then
260 chkpwd_LIBS="-lshadow $chkpwd_LIBS"
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"])
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)
281 test -f /usr/local/lib/libresolv.a && LDFLAGS="$LDFLAGS -L/usr/local/lib"
282 AC_CHECK_LIB(resolv, res_query, RESOLV="$RESOLV -lresolv")
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])
289 AC_SEARCH_LIBS(tgetent, [curses termcap])
290 AC_SEARCH_LIBS(initscr, [curses])
292 AC_CHECK_FUNCS(vw_printw wcolor_set resizeterm wresize)
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)
301 test -d /usr/kerberos/include && CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
303 # The big search for OpenSSL
304 if test "$with_ssl" != "no"; then
306 saved_LDFLAGS="$LDFLAGS"
307 saved_CFLAGS="$CFLAGS"
308 if test "x$prefix" != "xNONE"; then
309 tryssldir="$tryssldir $prefix"
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"
317 # Skip directories if they don't exist
318 if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
321 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
322 # Try to use $ssldir/lib if it exists, otherwise
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"
330 LDFLAGS="-L$ssldir $saved_LDFLAGS"
331 if test ! -z "$need_dash_r" ; then
332 LDFLAGS="-R$ssldir $LDFLAGS"
335 # Try to use $ssldir/include if it exists, otherwise
337 if test -d "$ssldir/include" ; then
338 CFLAGS="-I$ssldir/include $saved_CFLAGS"
340 CFLAGS="-I$ssldir $saved_CFLAGS"
344 # Basic test to check for compatible version and correct linking
345 # *does not* test for RSA - that comes later.
349 #include <openssl/rand.h>
353 memset(a, 0, sizeof(a));
354 RAND_add(a, sizeof(a), sizeof(a));
355 return(RAND_status() <= 0);
364 if test ! -z "$found_crypto" ; then
369 if test -z "$ssldir" ; then
373 if test ! -z "$found_crypto" ; then
374 ac_cv_openssldir=$ssldir
376 ac_cv_openssldir="no"
380 LDFLAGS="$saved_LDFLAGS"
381 CFLAGS="$saved_CFLAGS"
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
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"
397 LDFLAGS="-L$ssldir $saved_LDFLAGS"
398 if test ! -z "$need_dash_r" ; then
399 LDFLAGS="-R$ssldir $LDFLAGS"
402 # Try to use $ssldir/include if it exists, otherwise
404 if test -d "$ssldir/include" ; then
405 CFLAGS="-I$ssldir/include $saved_CFLAGS"
407 CFLAGS="-I$ssldir $saved_CFLAGS"
413 if test "x$with_db" != xno; then
414 test "$db_dir" && LDFLAGS="$LDFLAGS -L$db_dir/lib"
418 if test -d "$db_dir/include/db4"; then
419 CPPFLAGS="$CPPFLAGS -I$db_dir/include/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"
429 AC_CHECK_DB([db db-4.1 db-4 db4],
431 DATABASE=database_sleepycat.c
433 AC_MSG_ERROR([[Can not locate a suitable Berkeley DB
434 library. Use --with-db=PATH to specify
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,
447 if test "x$ok_zlib" = xyes ; then
448 SERVER_LIBS="-lz $SERVER_LIBS"
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,
463 if test "x$ok_ldap" = xyes ; then
464 SERVER_LIBS="-lldap $SERVER_LIBS"
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,
479 if test "x$ok_newt" = xyes ; then
480 SETUP_LIBS="-lnewt $SETUP_LIBS"
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,
497 if test "x$ok_libical" = xyes ; then
504 sscanf(ICAL_VERSION, "%d.%d", &major, &minor);
505 v = 100*major + minor;
506 printf("libical version: %i\n", v);
508 printf("This version is ok.\n");
511 printf("libical 0.24 or newer required.\n");
512 printf("Citadel will be built without calendar support.\n");
517 SERVER_LIBS="-lical $SERVER_LIBS"
518 AC_DEFINE(HAVE_LIBICAL)
526 dnl Checks for header files.
532 dnl TODO: for the DB header checks, we should check whether the headers
533 dnl define db_env_create, somehow
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)
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)
541 if test "x$with_ncurses" != xno; then
542 AC_CHECK_HEADERS(ncurses.h,,,[ ])
545 AC_CHECK_HEADER(resolv.h,AC_DEFINE(HAVE_RESOLV_H),,
546 [#ifdef HAVE_SYS_TYPES_H
547 #include <sys/types.h>
549 #ifdef HAVE_NETINET_IN_H
550 #include <netinet/in.h>
552 #ifdef HAVE_ARPA_NAMESER_H
553 #include <arpa/nameser.h>
557 dnl Checks for typedefs, structures, and compiler characteristics.
563 dnl defined in acinclude.m4:
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)
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)
582 dnl Checks for library functions.
584 AC_PROG_GCC_TRADITIONAL
587 AC_CHECK_FUNCS(getspnam getutxline mkdir mkfifo mktime rmdir select socket strerror strcasecmp strncasecmp)
589 dnl Now check for pthreads
591 dnl On some platforms, AC_CHECK_FUNC[S] doesn't work for pthreads programs;
592 dnl we need to include pthread.h
594 AC_CACHE_CHECK([for pthread_cancel], ac_cv_func_pthread_cancel,
595 [AC_TRY_LINK([#include <pthread.h>],
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)
604 pthread_cancel(thread);
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)
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)
619 pthread_create(NULL, NULL, NULL, NULL);
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)
629 AC_REPLACE_FUNCS(snprintf getutline)
631 # AC_CACHE_CHECK([the weather], ac_cv_weather, [
633 # echo $ECHO_N "opening your window... $ECHO_C" >&6
635 # month=`date | cut -f 2 -d ' '`
638 # ac_cv_weather="it's cold!"
641 # ac_cv_weather="it's wet!"
644 # ac_cv_weather="it's hot!"
647 # ac_cv_weather="it's cool"
649 # May | Jun | Sep | *)
650 # ac_cv_weather="it's fine"
655 AC_CACHE_CHECK([under the bed], ac_cv_under_the_bed, [
656 number=`date | cut -c 19`
659 ac_cv_under_the_bed="lunatics and monsters found"
662 ac_cv_under_the_bed="dust bunnies found"
667 dnl Done! Now write the Makefile and sysdep.h
671 AC_SUBST(chkpwd_LIBS)
674 AC_SUBST(SERVER_LDFLAGS)
675 AC_SUBST(SERVER_LIBS)
677 AC_CONFIG_HEADER(sysdep.h)
678 AC_CONFIG_FILES([Makefile])
681 if test -z "$DATABASE"; then
682 AC_MSG_WARN([No database driver was found. Please install Berkeley DB.])
687 echo "... On many operating systems, you must use GNU make (gmake) to compile"