1 dnl Process this file with autoconf to produce a configure script.
4 AC_INIT([Citadel/UX], [6.02], [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(BBSDIR, "$ac_default_prefix")
11 AC_DEFINE_UNQUOTED(BBSDIR, "$prefix")
14 AC_ARG_ENABLE(autologin, [ --disable-autologin disable autologin (default is enabled if possible)])
15 AC_ARG_ENABLE(chkpwd, [ --disable-chkpwd don't build 'chkpwd'])
17 AC_ARG_ENABLE(threaded-client, [ --disable-threaded-client
18 disable multithreaded client])
20 AC_ARG_WITH(pam, [ --with-pam use PAM if present (see PAM.txt before you try this)])
21 AC_ARG_WITH(kthread, [ --with-kthread use kernel threads (on FreeBSD) (not recommended yet)])
22 AC_ARG_WITH(db, [ --with-db@<:@=DIR@:>@ use Sleepycat DB 3.x @<:@DIR=/usr/local/BerkeleyDB.3.@<:@123@:>@@:>@])
24 [ --with-ssl=PATH Specify path to OpenSSL installation ],
26 if test "x$withval" != "xno" ; then
31 AC_ARG_WITH(ncurses, [ --without-ncurses don't use ncurses])
33 AC_ARG_WITH(with_zlib, [ --with-zlib use zlib compression if present])
34 AC_ARG_WITH(with_libical, [ --with-libical use libical calendaring library])
35 AC_ARG_WITH(with_newt, [ --with-newt use newt window library])
37 if test "x$with_db" != xno -a "x$with_db" != xyes -a "$with_db"; then
41 test -f /usr/local/lib/libdb.a -o -f /usr/local/lib/libdb.so \
42 -o -f /usr/local/lib/libdb4.a -o -f /usr/local/lib/libdb4.so \
45 test -d /usr/local/BerkeleyDB.4.1 && db_dir=/usr/local/BerkeleyDB.4.1
48 dnl By default, we only build the client (citadel and whobbs) unless we can
49 dnl figure out how to build with POSIX threads.
53 PTHREAD_DEFS=-D_REENTRANT
55 dnl BSDI 3.0 wants relocatable object modules instead of shared libs
56 dnl for dlopen(), and has a wrapper script to link with shared libs.
57 dnl Also has stupid non-reentrant gethostbyaddr() and friends.
59 test -z "$CC" -a -x /usr/bin/shlicc2 && CC=shlicc2
60 AC_DEFINE(HAVE_NONREENTRANT_NETDB)
63 AC_DEFINE(HAVE_NONREENTRANT_NETDB)
65 dnl Curses support on Mac OS X is kind of screwed at the moment.
67 AC_DEFINE(DISABLE_CURSES)
69 dnl Digital Unix has an odd way to build for pthreads, and we can't
70 dnl build pthreads programs with gcc due to header problems.
72 test -z "$CC" && CC=cc
73 LIBS="-lpthread -lexc $LIBS"
76 dnl FreeBSD is similar to Digital UNIX with DEC C, which has a -pthread flag:
78 if test "$with_kthread" = yes; then
84 PTHREAD_DEFS=-D_THREAD_SAFE
92 PTHREAD_DEFS="-D_REENTRANT -D_PTHREADS"
95 SERVER_LDFLAGS="-Wl,-subsystem,windows"
98 DEFS="$DEFS $PTHREAD_DEFS"
100 dnl Checks for programs.
103 dnl Set up system-dependent compiler flags.
104 if test "$GCC" = yes; then
106 *-*-solaris*|alpha*-dec-osf*)
107 CFLAGS="$CFLAGS -Wall -Wcast-qual -Wcast-align -Wno-char-subscripts"
110 CFLAGS="$CFLAGS -Wall -Wcast-qual -Wcast-align -Wstrict-prototypes"
117 missing_dir=`cd $ac_aux_dir && pwd`
118 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
119 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
121 dnl Checks for system services.
123 dnl Check the size of various builtin types; see typesize.h (error)
124 AC_CHECK_SIZEOF(char, 0)
125 AC_CHECK_SIZEOF(short, 0)
126 AC_CHECK_SIZEOF(int, 0)
127 AC_CHECK_SIZEOF(long, 0)
128 dnl AC_CHECK_SIZEOF(long long, 0)
130 dnl Checks for libraries.
132 dnl We want to test for the following in libc before checking for their
133 dnl respective libraries, because some systems (like Irix) have both, and the
134 dnl non-libc versions may be broken.
135 AC_CHECK_FUNCS(crypt gethostbyname connect)
137 if test "$ac_cv_func_gethostbyname" = no; then
138 AC_CHECK_LIB(nsl, gethostbyname)
141 if test "$ac_cv_func_connect" = no; then
142 AC_CHECK_LIB(socket, connect)
145 dnl Check for Solaris realtime support
146 AC_CHECK_LIB(rt, sched_yield)
148 dnl Determine the system's authentication capabilities, if autologin is
149 dnl requested. We currently support PAM, standard getpwnam(), and getspnam()
150 dnl (Linux shadow passwords)
151 if test "$enable_autologin" != no; then
152 if test "$with_pam" = yes; then
154 AC_CHECK_LIB(pam, pam_start, [chkpwd_LIBS="-lpam $chkpwd_LIBS"
156 AC_CHECK_FUNCS(pam_start)
157 test "$enable_chkpwd" != no && LIBS=$save_LIBS
159 if test "$ac_cv_func_pam_start" = no -o "$with_pam" != yes; then
161 AC_SEARCH_LIBS(getspnam, shadow, [
162 if test "$ac_cv_search_getspnam" = -lshadow; then
163 chkpwd_LIBS="-lshadow $chkpwd_LIBS"
165 test "$enable_chkpwd" != no && LIBS=$save_LIBS
166 if test "$ac_cv_func_crypt" = no; then
167 AC_CHECK_LIB(crypt, crypt, [
168 chkpwd_LIBS="-lcrypt $chkpwd_LIBS"
169 test "$enable_chkpwd" = no && \
170 LIBS="-lcrypt $LIBS"])
173 if test "$ac_cv_func_crypt" = yes -o "$ac_cv_lib_crypt_crypt" = yes -o "$ac_cv_func_pam_start" = yes; then
174 AC_DEFINE(ENABLE_AUTOLOGIN)
175 if test "$enable_chkpwd" != no; then
176 AC_DEFINE(ENABLE_CHKPWD)
184 test -f /usr/local/lib/libresolv.a && LDFLAGS="$LDFLAGS -L/usr/local/lib"
185 AC_CHECK_LIB(resolv, res_query, RESOLV="$RESOLV -lresolv")
187 if test "x$with_ncurses" != "xno"; then
188 AC_SEARCH_LIBS(tgetent, [ncurses curses termcap])
189 AC_SEARCH_LIBS(scrollok, [ncurses curses])
190 AC_SEARCH_LIBS(initscr, [ncurses curses])
192 AC_SEARCH_LIBS(tgetent, [curses termcap])
193 AC_SEARCH_LIBS(initscr, [curses])
195 AC_CHECK_FUNCS(vw_printw wcolor_set resizeterm wresize)
197 dnl Check for libpthread(s) if we're not using Digital UNIX or FreeBSD. (On
198 dnl which the -pthread flag takes care of this.)
199 if test "$check_pthread" != no; then
200 AC_CHECK_LIB(pthread, pthread_create)
201 AC_CHECK_LIB(pthreads, pthread_create)
204 test -d /usr/kerberos/include && CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
206 # The big search for OpenSSL
207 if test "$with_ssl" != "no"; then
209 saved_LDFLAGS="$LDFLAGS"
210 saved_CFLAGS="$CFLAGS"
211 if test "x$prefix" != "xNONE"; then
212 tryssldir="$tryssldir $prefix"
214 AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
215 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
216 CFLAGS="$saved_CFLAGS"
217 LDFLAGS="$saved_LDFLAGS"
218 LIBS="$saved_LIBS -lssl -lcrypto"
220 # Skip directories if they don't exist
221 if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
224 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
225 # Try to use $ssldir/lib if it exists, otherwise
227 if test -d "$ssldir/lib" ; then
228 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
229 if test ! -z "$need_dash_r" ; then
230 LDFLAGS="-R$ssldir/lib $LDFLAGS"
233 LDFLAGS="-L$ssldir $saved_LDFLAGS"
234 if test ! -z "$need_dash_r" ; then
235 LDFLAGS="-R$ssldir $LDFLAGS"
238 # Try to use $ssldir/include if it exists, otherwise
240 if test -d "$ssldir/include" ; then
241 CFLAGS="-I$ssldir/include $saved_CFLAGS"
243 CFLAGS="-I$ssldir $saved_CFLAGS"
247 # Basic test to check for compatible version and correct linking
248 # *does not* test for RSA - that comes later.
252 #include <openssl/rand.h>
256 memset(a, 0, sizeof(a));
257 RAND_add(a, sizeof(a), sizeof(a));
258 return(RAND_status() <= 0);
267 if test ! -z "$found_crypto" ; then
272 if test -z "$ssldir" ; then
276 if test ! -z "$found_crypto" ; then
277 ac_cv_openssldir=$ssldir
279 ac_cv_openssldir="no"
283 LDFLAGS="$saved_LDFLAGS"
284 CFLAGS="$saved_CFLAGS"
286 if test "x$ac_cv_openssldir" != "xno" ; then
287 AC_DEFINE(HAVE_OPENSSL)
288 LIBS="-lssl -lcrypto $LIBS"
289 dnl Need to recover ssldir - test above runs in subshell
290 ssldir=$ac_cv_openssldir
291 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
292 # Try to use $ssldir/lib if it exists, otherwise
294 if test -d "$ssldir/lib" ; then
295 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
296 if test ! -z "$need_dash_r" ; then
297 LDFLAGS="-R$ssldir/lib $LDFLAGS"
300 LDFLAGS="-L$ssldir $saved_LDFLAGS"
301 if test ! -z "$need_dash_r" ; then
302 LDFLAGS="-R$ssldir $LDFLAGS"
305 # Try to use $ssldir/include if it exists, otherwise
307 if test -d "$ssldir/include" ; then
308 CFLAGS="-I$ssldir/include $saved_CFLAGS"
310 CFLAGS="-I$ssldir $saved_CFLAGS"
316 if test "x$with_db" != xno; then
317 test "$db_dir" && LDFLAGS="$LDFLAGS -L$db_dir/lib"
321 if test -d "$db_dir/include/db4"; then
322 CPPFLAGS="$CPPFLAGS -I$db_dir/include/db4"
324 elif test "$db_dir"; then
325 CPPFLAGS="$CPPFLAGS -I$db_dir/include"
326 elif test -d /usr/include/db4; then
327 CPPFLAGS="$CPPFLAGS -I/usr/include/db4"
332 AC_CHECK_DB([db db-4.1 db-4 db4],
334 DATABASE=database_sleepycat.c
336 AC_MSG_ERROR([[Can not locate a suitable Berkeley DB
337 library. Use --with-db=PATH to specify
343 dnl Checks for the zlib compression library.
344 if test "x$with_zlib" != xno ; then
345 AC_CHECK_HEADERS(zlib.h,
346 [AC_CHECK_LIB(z, zlibVersion,
351 if test "x$ok_zlib" = xyes ; then
359 dnl Checks for the newt window library.
360 if test "x$with_newt" != xno ; then
361 AC_CHECK_HEADERS(newt.h,
362 [AC_CHECK_LIB(newt, newtInit,
367 if test "x$ok_newt" = xyes ; then
368 SETUP_LIBS="-lnewt $SETUP_LIBS"
377 dnl Checks for the libical calendaring library.
378 if test "x$with_libical" != xno ; then
379 AC_CHECK_HEADERS(ical.h,
380 [AC_CHECK_LIB(ical, icalcomponent_new,
385 if test "x$ok_libical" = xyes ; then
393 sscanf(ICAL_VERSION, "%f", &v);
394 printf("libical version: %0.2f\n", v);
398 printf("This version is ok.\n");
401 printf("libical 0.24 or newer required.\n");
402 printf("Citadel will be built without calendar support.\n");
408 AC_DEFINE(HAVE_LIBICAL)
416 dnl Checks for header files.
422 dnl TODO: for the DB header checks, we should check whether the headers
423 dnl define db_env_create, somehow
425 AC_CHECK_HEADERS(curses.h dl.h fcntl.h limits.h malloc.h termios.h sys/ioctl.h sys/select.h sys/time.h syslog.h unistd.h utmp.h utmpx.h paths.h db.h db4/db.h pthread.h netinet/in.h arpa/nameser.h)
428 dnl need to check if this is actually compilable, sometimes there are
429 dnl conflicts with the system's headers (eg solaris xpg4 style headers)
431 if test "x$with_ncurses" != xno; then
432 AC_CHECK_HEADERS(ncurses.h,,,[ ])
435 AC_CHECK_HEADER(resolv.h,AC_DEFINE(HAVE_RESOLV_H),,
436 [#ifdef HAVE_SYS_TYPES_H
437 #include <sys/types.h>
439 #ifdef HAVE_NETINET_IN_H
440 #include <netinet/in.h>
442 #ifdef HAVE_ARPA_NAMESER_H
443 #include <arpa/nameser.h>
447 dnl Checks for typedefs, structures, and compiler characteristics.
453 dnl defined in acinclude.m4:
456 AC_CACHE_CHECK([for ut_type in struct utmp], ac_cv_struct_ut_type,
457 [AC_TRY_COMPILE([#include <sys/types.h>
458 #include <utmp.h>], [struct utmp ut; ut.ut_type;],
459 ac_cv_struct_ut_type=yes, ac_cv_struct_ut_type=no)])
460 if test $ac_cv_struct_ut_type = yes; then
461 AC_DEFINE(HAVE_UT_TYPE)
464 AC_CACHE_CHECK([for ut_host in struct utmp], ac_cv_struct_ut_host,
465 [AC_TRY_COMPILE([#include <sys/types.h>
466 #include <utmp.h>], [struct utmp ut; ut.ut_host;],
467 ac_cv_struct_ut_host=yes, ac_cv_struct_ut_host=no)])
468 if test $ac_cv_struct_ut_host = yes; then
469 AC_DEFINE(HAVE_UT_HOST)
472 dnl Checks for library functions.
474 AC_PROG_GCC_TRADITIONAL
477 AC_CHECK_FUNCS(getspnam getutxline mkdir mkfifo mktime rmdir select socket strerror strcasecmp strncasecmp)
479 dnl Now check for pthreads
481 dnl On some platforms, AC_CHECK_FUNC[S] doesn't work for pthreads programs;
482 dnl we need to include pthread.h
484 AC_CACHE_CHECK([for pthread_cancel], ac_cv_func_pthread_cancel,
485 [AC_TRY_LINK([#include <pthread.h>],
488 /* The GNU C library defines this for functions which it implements
489 to always fail with ENOSYS. Some functions are actually named
490 something starting with __ and the normal name is an alias. */
491 #if defined (__stub_pthread_cancel) || defined (__stub___pthread_cancel)
494 pthread_cancel(thread);
496 ac_cv_func_pthread_cancel=yes, ac_cv_func_pthread_cancel=no)])
497 if test "$ac_cv_func_pthread_cancel" = yes; then
498 AC_DEFINE(HAVE_PTHREAD_CANCEL)
501 AC_CACHE_CHECK([for pthread_create], ac_cv_func_pthread_create,
502 [AC_TRY_LINK([#include <pthread.h>],
503 [ /* The GNU C library defines this for functions which it implements
504 to always fail with ENOSYS. Some functions are actually named
505 something starting with __ and the normal name is an alias. */
506 #if defined (__stub_pthread_cancel) || defined (__stub___pthread_cancel)
509 pthread_create(NULL, NULL, NULL, NULL);
511 ac_cv_func_pthread_create=yes, ac_cv_func_pthread_create=no)])
512 if test "$ac_cv_func_pthread_create" = yes; then
513 test "$DATABASE" && TARGETS="client server utils"
514 if test "x$enable_threaded_client" != xno; then
515 AC_DEFINE(THREADED_CLIENT)
519 AC_REPLACE_FUNCS(snprintf getutline)
521 # AC_CACHE_CHECK([the weather], ac_cv_weather, [
523 # echo $ECHO_N "opening your window... $ECHO_C" >&6
525 # month=`date | cut -f 2 -d ' '`
528 # ac_cv_weather="it's cold!"
531 # ac_cv_weather="it's wet!"
534 # ac_cv_weather="it's hot!"
537 # ac_cv_weather="it's cool"
539 # May | Jun | Sep | *)
540 # ac_cv_weather="it's fine"
545 AC_CACHE_CHECK([under the bed], ac_cv_under_the_bed, [
546 number=`date | cut -c 19`
549 ac_cv_under_the_bed="lunatics and monsters found"
552 ac_cv_under_the_bed="dust bunnies found"
557 dnl Done! Now write the Makefile and sysdep.h
561 AC_SUBST(chkpwd_LIBS)
564 AC_SUBST(SERVER_LDFLAGS)
566 AC_CONFIG_HEADER(sysdep.h)
567 AC_CONFIG_FILES([Makefile weekly])
570 if test -z "$DATABASE"; then
571 AC_MSG_WARN([No database driver was found. Please install Berkeley DB.])
576 echo "... On many operating systems, you must use GNU make (gmake) to compile"