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_newt, [ --with-newt use newt window library])
118 if test "x$with_db" != xno -a "x$with_db" != xyes -a "$with_db"; then
122 test -f /usr/local/lib/libdb.a -o -f /usr/local/lib/libdb.so \
123 -o -f /usr/local/lib/libdb4.a -o -f /usr/local/lib/libdb4.so \
126 test -d /usr/local/BerkeleyDB.4.1 && db_dir=/usr/local/BerkeleyDB.4.1
127 test -d /usr/local/BerkeleyDB.4.2 && db_dir=/usr/local/BerkeleyDB.4.2
128 test -d /usr/local/BerkeleyDB.4.3 && db_dir=/usr/local/BerkeleyDB.4.3
131 dnl By default, we only build the client (citadel and whobbs) unless we can
132 dnl figure out how to build with POSIX threads.
136 PTHREAD_DEFS=-D_REENTRANT
137 AC_MSG_CHECKING([how to compile with POSIX threads])
139 dnl BSDI 3.0 wants relocatable object modules instead of shared libs
140 dnl for dlopen(), and has a wrapper script to link with shared libs.
141 dnl Also has stupid non-reentrant gethostbyaddr() and friends.
143 test -z "$CC" -a -x /usr/bin/shlicc2 && CC=shlicc2
144 AC_DEFINE(HAVE_NONREENTRANT_NETDB)
145 AC_MSG_RESULT([Old BSDI])
148 AC_DEFINE(HAVE_NONREENTRANT_NETDB)
149 AC_MSG_RESULT([BSD/OS])
151 dnl Curses support on Mac OS X is kind of screwed at the moment.
153 AC_DEFINE(DISABLE_CURSES)
154 AC_MSG_RESULT([Mac OS X])
156 dnl Digital Unix has an odd way to build for pthreads, and we can't
157 dnl build pthreads programs with gcc due to header problems.
159 test -z "$CC" && CC=cc
160 LIBS="-lpthread -lexc $LIBS"
162 AC_MSG_RESULT([Tru64 or Digital UNIX])
164 dnl FreeBSD is similar to Digital UNIX with DEC C, which has a -pthread flag:
166 if test "$with_kthread" = yes; then
167 LIBS="-kthread $LIBS"
169 LIBS="-pthread $LIBS"
172 PTHREAD_DEFS=-D_THREAD_SAFE
173 AC_MSG_RESULT([FreeBSD])
176 LIBS="-pthread $LIBS"
178 PTHREAD_DEFS=-pthread
179 AC_MSG_RESULT([OpenBSD])
182 PTHREAD_DEFS="-D_REENTRANT -pthread"
183 AC_MSG_RESULT([Linux])
186 PTHREAD_DEFS="-D_REENTRANT -D_PTHREADS"
187 AC_MSG_RESULT([Solaris])
190 SERVER_LDFLAGS="-Wl,-subsystem,windows"
191 AC_MSG_RESULT([Cygwin])
194 AC_MSG_RESULT([default])
197 dnl DEFS="$DEFS $PTHREAD_DEFS"
200 dnl Checks for programs.
203 dnl Set up system-dependent compiler flags.
204 if test "$GCC" = yes; then
205 if test "$CC" = icc; then
209 *-*-solaris*|alpha*-dec-osf*)
210 CFLAGS="$CFLAGS -Wall -Wcast-qual -Wcast-align -Wno-char-subscripts $PTHREAD_DEFS"
213 CFLAGS="$CFLAGS -Wall -Wcast-qual -Wcast-align -Wstrict-prototypes $PTHREAD_DEFS"
219 if test "x$enable_pie" = xyes; then
220 save_CFLAGS="$CFLAGS"
221 save_LDFLAGS="$LDFLAGS"
222 CFLAGS="$CFLAGS -fpie"
223 LDFLAGS="$LDFLAGS -pie -fpie"
224 AC_CACHE_CHECK([whether compiler accepts -pie -fpie], ac_cv_pie_fpie,
226 ac_cv_pie_fpie=yes, ac_cv_pie_fpie=no)])
227 if test $ac_cv_pie_fpie = no; then
228 CFLAGS="$save_CFLAGS"
229 LDFLAGS="$save_LDFLAGS"
235 missing_dir=`cd $ac_aux_dir && pwd`
236 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
237 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
239 dnl Checks for system services.
241 dnl Check the size of various builtin types; see typesize.h (error)
242 AC_CHECK_SIZEOF(char, 0)
243 AC_CHECK_SIZEOF(short, 0)
244 AC_CHECK_SIZEOF(int, 0)
245 AC_CHECK_SIZEOF(long, 0)
246 dnl AC_CHECK_SIZEOF(long long, 0)
248 dnl Checks for libraries.
250 dnl We want to test for the following in libc before checking for their
251 dnl respective libraries, because some systems (like Irix) have both, and the
252 dnl non-libc versions may be broken.
253 AC_CHECK_FUNCS(crypt gethostbyname connect)
255 if test "$ac_cv_func_gethostbyname" = no; then
256 AC_CHECK_LIB(nsl, gethostbyname)
259 if test "$ac_cv_func_connect" = no; then
260 AC_CHECK_LIB(socket, connect)
263 dnl Check for Solaris realtime support
264 AC_CHECK_LIB(rt, sched_yield)
266 dnl Determine the system's authentication capabilities, if autologin is
267 dnl requested. We currently support PAM, standard getpwnam(), and getspnam()
268 dnl (Linux shadow passwords)
269 if test "$enable_autologin" = yes; then
270 if test "$with_pam" = yes; then
272 AC_CHECK_LIB(pam, pam_start, [chkpwd_LIBS="-lpam $chkpwd_LIBS"
274 AC_CHECK_FUNCS(pam_start)
275 test "$enable_chkpwd" != no && LIBS=$save_LIBS
277 if test "$ac_cv_func_pam_start" = no -o "$with_pam" != yes; then
279 AC_SEARCH_LIBS(getspnam, shadow, [
280 if test "$ac_cv_search_getspnam" = -lshadow; then
281 chkpwd_LIBS="-lshadow $chkpwd_LIBS"
283 test "$enable_chkpwd" != no && LIBS=$save_LIBS
284 if test "$ac_cv_func_crypt" = no; then
285 AC_CHECK_LIB(crypt, crypt, [
286 chkpwd_LIBS="-lcrypt $chkpwd_LIBS"
287 test "$enable_chkpwd" = no && \
288 LIBS="-lcrypt $LIBS"])
291 if test "$ac_cv_func_crypt" = yes -o "$ac_cv_lib_crypt_crypt" = yes -o "$ac_cv_func_pam_start" = yes; then
292 AC_DEFINE(ENABLE_AUTOLOGIN)
293 if test "$enable_chkpwd" != no; then
294 AC_DEFINE(ENABLE_CHKPWD)
302 test -f /usr/local/lib/libresolv.a && LDFLAGS="$LDFLAGS -L/usr/local/lib"
303 AC_CHECK_LIB(resolv, res_query, RESOLV="$RESOLV -lresolv")
305 if test "x$with_ncurses" != "xno"; then
306 AC_SEARCH_LIBS(tgetent, [ncurses curses termcap])
307 AC_SEARCH_LIBS(scrollok, [ncurses curses])
308 AC_SEARCH_LIBS(initscr, [ncurses curses])
310 AC_SEARCH_LIBS(tgetent, [curses termcap])
311 AC_SEARCH_LIBS(initscr, [curses])
313 AC_CHECK_FUNCS(vw_printw wcolor_set resizeterm wresize)
315 dnl Check for libpthread(s) if we're not using Digital UNIX or FreeBSD. (On
316 dnl which the -pthread flag takes care of this.)
317 if test "$check_pthread" != no; then
318 AC_CHECK_LIB(pthread, pthread_create)
319 AC_CHECK_LIB(pthreads, pthread_create)
322 test -d /usr/kerberos/include && CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
324 # The big search for OpenSSL
325 if test "$with_ssl" != "no"; then
327 saved_LDFLAGS="$LDFLAGS"
328 saved_CFLAGS="$CFLAGS"
329 if test "x$prefix" != "xNONE"; then
330 tryssldir="$tryssldir $prefix"
332 AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
333 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
334 CFLAGS="$saved_CFLAGS"
335 LDFLAGS="$saved_LDFLAGS"
336 LIBS="$saved_LIBS -lssl -lcrypto"
338 # Skip directories if they don't exist
339 if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
342 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
343 # Try to use $ssldir/lib if it exists, otherwise
345 if test -d "$ssldir/lib" ; then
346 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
347 if test ! -z "$need_dash_r" ; then
348 LDFLAGS="-R$ssldir/lib $LDFLAGS"
351 LDFLAGS="-L$ssldir $saved_LDFLAGS"
352 if test ! -z "$need_dash_r" ; then
353 LDFLAGS="-R$ssldir $LDFLAGS"
356 # Try to use $ssldir/include if it exists, otherwise
358 if test -d "$ssldir/include" ; then
359 CFLAGS="-I$ssldir/include $saved_CFLAGS"
361 CFLAGS="-I$ssldir $saved_CFLAGS"
365 # Basic test to check for compatible version and correct linking
366 # *does not* test for RSA - that comes later.
370 #include <openssl/rand.h>
374 memset(a, 0, sizeof(a));
375 RAND_add(a, sizeof(a), sizeof(a));
376 return(RAND_status() <= 0);
385 if test ! -z "$found_crypto" ; then
390 if test -z "$ssldir" ; then
394 if test ! -z "$found_crypto" ; then
395 ac_cv_openssldir=$ssldir
397 ac_cv_openssldir="no"
401 LDFLAGS="$saved_LDFLAGS"
402 CFLAGS="$saved_CFLAGS"
404 if test "x$ac_cv_openssldir" != "xno" ; then
405 AC_DEFINE(HAVE_OPENSSL)
406 LIBS="-lssl -lcrypto $LIBS"
407 dnl Need to recover ssldir - test above runs in subshell
408 ssldir=$ac_cv_openssldir
409 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
410 # Try to use $ssldir/lib if it exists, otherwise
412 if test -d "$ssldir/lib" ; then
413 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
414 if test ! -z "$need_dash_r" ; then
415 LDFLAGS="-R$ssldir/lib $LDFLAGS"
418 LDFLAGS="-L$ssldir $saved_LDFLAGS"
419 if test ! -z "$need_dash_r" ; then
420 LDFLAGS="-R$ssldir $LDFLAGS"
423 # Try to use $ssldir/include if it exists, otherwise
425 if test -d "$ssldir/include" ; then
426 CFLAGS="-I$ssldir/include $saved_CFLAGS"
428 CFLAGS="-I$ssldir $saved_CFLAGS"
434 if test "x$with_db" != xno; then
435 test "$db_dir" && LDFLAGS="$LDFLAGS -L$db_dir/lib"
439 if test -d "$db_dir/include/db4"; then
440 CPPFLAGS="$CPPFLAGS -I$db_dir/include/db4"
442 elif test "$db_dir"; then
443 CPPFLAGS="$CPPFLAGS -I$db_dir/include"
444 elif test -d /usr/include/db4; then
445 CPPFLAGS="$CPPFLAGS -I/usr/include/db4"
450 AC_CHECK_DB([db db-4.1 db-4 db4],
452 DATABASE=database_sleepycat.c
454 AC_MSG_ERROR([[Can not locate a suitable Berkeley DB
455 library. Use --with-db=PATH to specify
460 dnl Checks for the zlib compression library.
461 if test "x$with_zlib" != xno ; then
462 AC_CHECK_HEADERS(zlib.h,
463 [AC_CHECK_LIB(z, zlibVersion,
468 if test "x$ok_zlib" = xyes ; then
469 SERVER_LIBS="-lz $SERVER_LIBS"
476 dnl Checks for the OpenLDAP client library.
477 if test "x$with_ldap" != xno ; then
478 AC_CHECK_HEADERS(ldap.h,
479 [AC_CHECK_LIB(ldap, ldap_init,
484 if test "x$ok_ldap" = xyes ; then
485 SERVER_LIBS="-lldap $SERVER_LIBS"
492 dnl Checks for the newt window library.
493 if test "x$with_newt" != xno ; then
494 AC_CHECK_HEADERS(newt.h,
495 [AC_CHECK_LIB(newt, newtInit,
500 if test "x$ok_newt" = xyes ; then
501 SETUP_LIBS="-lnewt $SETUP_LIBS"
510 dnl Checks for the libical calendaring library.
511 if test "x$with_libical" != xno ; then
512 AC_CHECK_HEADERS(ical.h,
513 [AC_CHECK_LIB(ical, icalcomponent_new,
518 if test "x$ok_libical" = xyes ; then
525 sscanf(ICAL_VERSION, "%d.%d", &major, &minor);
526 v = 100*major + minor;
527 printf("libical version: %i\n", v);
529 printf("This version is ok.\n");
532 printf("libical 0.24 or newer required.\n");
533 printf("Citadel will be built without calendar support.\n");
538 SERVER_LIBS="-lical $SERVER_LIBS"
539 AC_DEFINE(HAVE_LIBICAL)
547 dnl Checks for header files.
553 dnl TODO: for the DB header checks, we should check whether the headers
554 dnl define db_env_create, somehow
556 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)
559 dnl need to check if this is actually compilable, sometimes there are
560 dnl conflicts with the system's headers (eg solaris xpg4 style headers)
562 if test "x$with_ncurses" != xno; then
563 AC_CHECK_HEADERS(ncurses.h,,,[ ])
566 AC_CHECK_HEADER(resolv.h,AC_DEFINE(HAVE_RESOLV_H),,
567 [#ifdef HAVE_SYS_TYPES_H
568 #include <sys/types.h>
570 #ifdef HAVE_NETINET_IN_H
571 #include <netinet/in.h>
573 #ifdef HAVE_ARPA_NAMESER_H
574 #include <arpa/nameser.h>
578 dnl Checks for typedefs, structures, and compiler characteristics.
584 dnl defined in acinclude.m4:
587 AC_CACHE_CHECK([for ut_type in struct utmp], ac_cv_struct_ut_type,
588 [AC_TRY_COMPILE([#include <sys/types.h>
589 #include <utmp.h>], [struct utmp ut; ut.ut_type;],
590 ac_cv_struct_ut_type=yes, ac_cv_struct_ut_type=no)])
591 if test $ac_cv_struct_ut_type = yes; then
592 AC_DEFINE(HAVE_UT_TYPE)
595 AC_CACHE_CHECK([for ut_host in struct utmp], ac_cv_struct_ut_host,
596 [AC_TRY_COMPILE([#include <sys/types.h>
597 #include <utmp.h>], [struct utmp ut; ut.ut_host;],
598 ac_cv_struct_ut_host=yes, ac_cv_struct_ut_host=no)])
599 if test $ac_cv_struct_ut_host = yes; then
600 AC_DEFINE(HAVE_UT_HOST)
603 dnl Checks for library functions.
605 AC_PROG_GCC_TRADITIONAL
608 AC_CHECK_FUNCS(getspnam getutxline mkdir mkfifo mktime rmdir select socket strerror strcasecmp strncasecmp)
610 dnl Now check for pthreads
612 dnl On some platforms, AC_CHECK_FUNC[S] doesn't work for pthreads programs;
613 dnl we need to include pthread.h
615 AC_CACHE_CHECK([for pthread_cancel], ac_cv_func_pthread_cancel,
616 [AC_TRY_LINK([#include <pthread.h>],
619 /* The GNU C library defines this for functions which it implements
620 to always fail with ENOSYS. Some functions are actually named
621 something starting with __ and the normal name is an alias. */
622 #if defined (__stub_pthread_cancel) || defined (__stub___pthread_cancel)
625 pthread_cancel(thread);
627 ac_cv_func_pthread_cancel=yes, ac_cv_func_pthread_cancel=no)])
628 if test "$ac_cv_func_pthread_cancel" = yes; then
629 AC_DEFINE(HAVE_PTHREAD_CANCEL)
632 AC_CACHE_CHECK([for pthread_create], ac_cv_func_pthread_create,
633 [AC_TRY_LINK([#include <pthread.h>],
634 [ /* The GNU C library defines this for functions which it implements
635 to always fail with ENOSYS. Some functions are actually named
636 something starting with __ and the normal name is an alias. */
637 #if defined (__stub_pthread_cancel) || defined (__stub___pthread_cancel)
640 pthread_create(NULL, NULL, NULL, NULL);
642 ac_cv_func_pthread_create=yes, ac_cv_func_pthread_create=no)])
643 if test "$ac_cv_func_pthread_create" = yes; then
644 test "$DATABASE" && TARGETS="client server utils"
645 if test "x$enable_threaded_client" != xno; then
646 AC_DEFINE(THREADED_CLIENT)
650 AC_REPLACE_FUNCS(snprintf getutline)
652 # AC_CACHE_CHECK([the weather], ac_cv_weather, [
654 # echo $ECHO_N "opening your window... $ECHO_C" >&6
656 # month=`date | cut -f 2 -d ' '`
659 # ac_cv_weather="it's cold!"
662 # ac_cv_weather="it's wet!"
665 # ac_cv_weather="it's hot!"
668 # ac_cv_weather="it's cool"
670 # May | Jun | Sep | *)
671 # ac_cv_weather="it's fine"
678 AC_CACHE_CHECK([under the bed], ac_cv_under_the_bed, [
679 number=`date | cut -c 19`
682 ac_cv_under_the_bed="lunatics and monsters found"
685 ac_cv_under_the_bed="dust bunnies found"
690 dnl Done! Now write the Makefile and sysdep.h
694 AC_SUBST(chkpwd_LIBS)
697 AC_SUBST(SERVER_LDFLAGS)
698 AC_SUBST(SERVER_LIBS)
700 AC_CONFIG_HEADER(sysdep.h)
701 AC_CONFIG_FILES([Makefile])
702 AC_OUTPUT(database_cleanup.sh)
704 if test -z "$DATABASE"; then
705 AC_MSG_WARN([No database driver was found. Please install Berkeley DB.])
708 echo ------------------------------------------------------------------------
709 echo 'zlib compression: ' $ok_zlib
710 echo 'Calendar support: ' $ok_libical
711 echo 'LDAP support: ' $ok_ldap
713 echo 'Note: if you are not using Linux, make sure you are using GNU make'
714 echo '(gmake) to compile Citadel.'