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])
36 if test "x$with_db" != xno -a "x$with_db" != xyes -a "$with_db"; then
40 test -f /usr/local/lib/libdb.a -o -f /usr/local/lib/libdb.so \
41 -o -f /usr/local/lib/libdb4.a -o -f /usr/local/lib/libdb4.so \
44 test -d /usr/local/BerkeleyDB.4.1 && db_dir=/usr/local/BerkeleyDB.4.1
47 dnl By default, we only build the client (citadel and whobbs) unless we can
48 dnl figure out how to build with POSIX threads.
52 PTHREAD_DEFS=-D_REENTRANT
54 dnl BSDI 3.0 wants relocatable object modules instead of shared libs
55 dnl for dlopen(), and has a wrapper script to link with shared libs.
56 dnl Also has stupid non-reentrant gethostbyaddr() and friends.
58 test -z "$CC" -a -x /usr/bin/shlicc2 && CC=shlicc2
59 AC_DEFINE(HAVE_NONREENTRANT_NETDB)
62 AC_DEFINE(HAVE_NONREENTRANT_NETDB)
64 dnl Curses support on Mac OS X is kind of screwed at the moment.
66 AC_DEFINE(DISABLE_CURSES)
68 dnl Digital Unix has an odd way to build for pthreads, and we can't
69 dnl build pthreads programs with gcc due to header problems.
71 test -z "$CC" && CC=cc
72 LIBS="-lpthread -lexc $LIBS"
75 dnl FreeBSD is similar to Digital UNIX with DEC C, which has a -pthread flag:
77 if test "$with_kthread" = yes; then
83 PTHREAD_DEFS=-D_THREAD_SAFE
91 PTHREAD_DEFS="-D_REENTRANT -D_PTHREADS"
94 DEFS="$DEFS $PTHREAD_DEFS"
96 dnl Checks for programs.
99 dnl Set up system-dependent compiler flags.
100 if test "$GCC" = yes; then
102 *-*-solaris*|alpha*-dec-osf*)
103 CFLAGS="$CFLAGS -Wall -Wcast-qual -Wcast-align -Wno-char-subscripts"
106 CFLAGS="$CFLAGS -Wall -Wcast-qual -Wcast-align -Wstrict-prototypes"
113 missing_dir=`cd $ac_aux_dir && pwd`
114 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
115 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
117 dnl Checks for system services.
119 dnl Check the size of various builtin types; see typesize.h (error)
120 AC_CHECK_SIZEOF(char, 0)
121 AC_CHECK_SIZEOF(short, 0)
122 AC_CHECK_SIZEOF(int, 0)
123 AC_CHECK_SIZEOF(long, 0)
124 dnl AC_CHECK_SIZEOF(long long, 0)
126 dnl Checks for libraries.
128 dnl We want to test for the following in libc before checking for their
129 dnl respective libraries, because some systems (like Irix) have both, and the
130 dnl non-libc versions may be broken.
131 AC_CHECK_FUNCS(crypt gethostbyname connect)
133 if test "$ac_cv_func_gethostbyname" = no; then
134 AC_CHECK_LIB(nsl, gethostbyname)
137 if test "$ac_cv_func_connect" = no; then
138 AC_CHECK_LIB(socket, connect)
141 dnl Check for Solaris realtime support
142 AC_CHECK_LIB(rt, sched_yield)
144 dnl Determine the system's authentication capabilities, if autologin is
145 dnl requested. We currently support PAM, standard getpwnam(), and getspnam()
146 dnl (Linux shadow passwords)
147 if test "$enable_autologin" != no; then
148 if test "$with_pam" = yes; then
150 AC_CHECK_LIB(pam, pam_start, [chkpwd_LIBS="-lpam $chkpwd_LIBS"
152 AC_CHECK_FUNCS(pam_start)
153 test "$enable_chkpwd" != no && LIBS=$save_LIBS
155 if test "$ac_cv_func_pam_start" = no -o "$with_pam" != yes; then
157 AC_SEARCH_LIBS(getspnam, shadow, [
158 if test "$ac_cv_search_getspnam" = -lshadow; then
159 chkpwd_LIBS="-lshadow $chkpwd_LIBS"
161 test "$enable_chkpwd" != no && LIBS=$save_LIBS
162 if test "$ac_cv_func_crypt" = no; then
163 AC_CHECK_LIB(crypt, crypt, [
164 chkpwd_LIBS="-lcrypt $chkpwd_LIBS"
165 test "$enable_chkpwd" = no && \
166 LIBS="-lcrypt $LIBS"])
169 if test "$ac_cv_func_crypt" = yes -o "$ac_cv_lib_crypt_crypt" = yes -o "$ac_cv_func_pam_start" = yes; then
170 AC_DEFINE(ENABLE_AUTOLOGIN)
171 if test "$enable_chkpwd" != no; then
172 AC_DEFINE(ENABLE_CHKPWD)
180 test -f /usr/local/lib/libresolv.a && LDFLAGS="$LDFLAGS -L/usr/local/lib"
181 AC_CHECK_LIB(resolv, res_query, RESOLV="$RESOLV -lresolv")
183 if test "x$with_ncurses" != "xno"; then
184 AC_SEARCH_LIBS(tgetent, [ncurses curses termcap])
185 AC_SEARCH_LIBS(scrollok, [ncurses curses])
186 AC_SEARCH_LIBS(initscr, [ncurses curses])
188 AC_SEARCH_LIBS(tgetent, [curses termcap])
189 AC_SEARCH_LIBS(initscr, [curses])
191 AC_CHECK_FUNCS(vw_printw wcolor_set resizeterm wresize)
193 dnl Check for libpthread(s) if we're not using Digital UNIX or FreeBSD. (On
194 dnl which the -pthread flag takes care of this.)
195 if test "$check_pthread" != no; then
196 AC_CHECK_LIB(pthread, pthread_create)
197 AC_CHECK_LIB(pthreads, pthread_create)
200 # The big search for OpenSSL
201 if test "$with_ssl" != "no"; then
203 saved_LDFLAGS="$LDFLAGS"
204 saved_CFLAGS="$CFLAGS"
205 if test "x$prefix" != "xNONE"; then
206 tryssldir="$tryssldir $prefix"
208 AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
209 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
210 CFLAGS="$saved_CFLAGS"
211 LDFLAGS="$saved_LDFLAGS"
212 LIBS="$saved_LIBS -lssl -lcrypto"
214 # Skip directories if they don't exist
215 if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
218 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
219 # Try to use $ssldir/lib if it exists, otherwise
221 if test -d "$ssldir/lib" ; then
222 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
223 if test ! -z "$need_dash_r" ; then
224 LDFLAGS="-R$ssldir/lib $LDFLAGS"
227 LDFLAGS="-L$ssldir $saved_LDFLAGS"
228 if test ! -z "$need_dash_r" ; then
229 LDFLAGS="-R$ssldir $LDFLAGS"
232 # Try to use $ssldir/include if it exists, otherwise
234 if test -d "$ssldir/include" ; then
235 CFLAGS="-I$ssldir/include $saved_CFLAGS"
237 CFLAGS="-I$ssldir $saved_CFLAGS"
241 # Basic test to check for compatible version and correct linking
242 # *does not* test for RSA - that comes later.
246 #include <openssl/rand.h>
250 memset(a, 0, sizeof(a));
251 RAND_add(a, sizeof(a), sizeof(a));
252 return(RAND_status() <= 0);
261 if test ! -z "$found_crypto" ; then
266 if test -z "$ssldir" ; then
270 if test ! -z "$found_crypto" ; then
271 ac_cv_openssldir=$ssldir
273 ac_cv_openssldir="no"
277 LDFLAGS="$saved_LDFLAGS"
278 CFLAGS="$saved_CFLAGS"
280 if test "x$ac_cv_openssldir" != "xno" ; then
281 AC_DEFINE(HAVE_OPENSSL)
282 LIBS="-lssl -lcrypto $LIBS"
283 dnl Need to recover ssldir - test above runs in subshell
284 ssldir=$ac_cv_openssldir
285 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
286 # Try to use $ssldir/lib if it exists, otherwise
288 if test -d "$ssldir/lib" ; then
289 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
290 if test ! -z "$need_dash_r" ; then
291 LDFLAGS="-R$ssldir/lib $LDFLAGS"
294 LDFLAGS="-L$ssldir $saved_LDFLAGS"
295 if test ! -z "$need_dash_r" ; then
296 LDFLAGS="-R$ssldir $LDFLAGS"
299 # Try to use $ssldir/include if it exists, otherwise
301 if test -d "$ssldir/include" ; then
302 CFLAGS="-I$ssldir/include $saved_CFLAGS"
304 CFLAGS="-I$ssldir $saved_CFLAGS"
310 if test "x$with_db" != xno; then
311 test "$db_dir" && LDFLAGS="$LDFLAGS -L$db_dir/lib"
315 if test -d "$db_dir/include/db4"; then
316 CPPFLAGS="$CPPFLAGS -I$db_dir/include/db4"
318 elif test "$db_dir"; then
319 CPPFLAGS="$CPPFLAGS -I$db_dir/include"
320 elif test -d /usr/include/db4; then
321 CPPFLAGS="$CPPFLAGS -I/usr/include/db4"
326 AC_CHECK_DB([db db-4.1 db-4 db4],
328 DATABASE=database_sleepycat.c
330 AC_MSG_ERROR([[Can not locate a suitable Berkeley DB
331 library. Use --with-db=PATH to specify
337 dnl Checks for the zlib compression library.
338 if test "x$with_zlib" != xno ; then
339 AC_CHECK_HEADERS(zlib.h,
340 [AC_CHECK_LIB(z, zlibVersion,
345 if test "x$ok_zlib" = xyes ; then
352 dnl Checks for the libical calendaring library.
353 if test "x$with_libical" != xno ; then
354 AC_CHECK_HEADERS(ical.h,
355 [AC_CHECK_LIB(ical, icalcomponent_new,
360 if test "x$ok_libical" = xyes ; then
368 sscanf(ICAL_VERSION, "%f", &v);
369 printf("libical version: %0.2f\n", v);
373 printf("This version is ok.\n");
376 printf("libical 0.24 or newer required.\n");
377 printf("Citadel will be built without calendar support.\n");
383 AC_DEFINE(HAVE_LIBICAL)
390 dnl Checks for header files.
396 dnl TODO: for the DB header checks, we should check whether the headers
397 dnl define db_env_create, somehow
399 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)
402 dnl need to check if this is actually compilable, sometimes there are
403 dnl conflicts with the system's headers (eg solaris xpg4 style headers)
405 if test "x$with_ncurses" != xno; then
406 AC_CHECK_HEADERS(ncurses.h,,,[ ])
409 AC_CHECK_HEADER(resolv.h,AC_DEFINE(HAVE_RESOLV_H),,
410 [#ifdef HAVE_SYS_TYPES_H
411 #include <sys/types.h>
413 #ifdef HAVE_NETINET_IN_H
414 #include <netinet/in.h>
416 #ifdef HAVE_ARPA_NAMESER_H
417 #include <arpa/nameser.h>
421 dnl Checks for typedefs, structures, and compiler characteristics.
427 dnl defined in acinclude.m4:
430 AC_CACHE_CHECK([for ut_type in struct utmp], ac_cv_struct_ut_type,
431 [AC_TRY_COMPILE([#include <sys/types.h>
432 #include <utmp.h>], [struct utmp ut; ut.ut_type;],
433 ac_cv_struct_ut_type=yes, ac_cv_struct_ut_type=no)])
434 if test $ac_cv_struct_ut_type = yes; then
435 AC_DEFINE(HAVE_UT_TYPE)
438 AC_CACHE_CHECK([for ut_host in struct utmp], ac_cv_struct_ut_host,
439 [AC_TRY_COMPILE([#include <sys/types.h>
440 #include <utmp.h>], [struct utmp ut; ut.ut_host;],
441 ac_cv_struct_ut_host=yes, ac_cv_struct_ut_host=no)])
442 if test $ac_cv_struct_ut_host = yes; then
443 AC_DEFINE(HAVE_UT_HOST)
446 dnl Checks for library functions.
448 AC_PROG_GCC_TRADITIONAL
451 AC_CHECK_FUNCS(getspnam getutxline mkdir mkfifo mktime rmdir select socket strerror strcasecmp strncasecmp)
453 dnl Now check for pthreads
455 dnl On some platforms, AC_CHECK_FUNC[S] doesn't work for pthreads programs;
456 dnl we need to include pthread.h
458 AC_CACHE_CHECK([for pthread_cancel], ac_cv_func_pthread_cancel,
459 [AC_TRY_LINK([#include <pthread.h>],
462 /* The GNU C library defines this for functions which it implements
463 to always fail with ENOSYS. Some functions are actually named
464 something starting with __ and the normal name is an alias. */
465 #if defined (__stub_pthread_cancel) || defined (__stub___pthread_cancel)
468 pthread_cancel(thread);
470 ac_cv_func_pthread_cancel=yes, ac_cv_func_pthread_cancel=no)])
471 if test "$ac_cv_func_pthread_cancel" = yes; then
472 AC_DEFINE(HAVE_PTHREAD_CANCEL)
475 AC_CACHE_CHECK([for pthread_create], ac_cv_func_pthread_create,
476 [AC_TRY_LINK([#include <pthread.h>],
477 [ /* The GNU C library defines this for functions which it implements
478 to always fail with ENOSYS. Some functions are actually named
479 something starting with __ and the normal name is an alias. */
480 #if defined (__stub_pthread_cancel) || defined (__stub___pthread_cancel)
483 pthread_create(NULL, NULL, NULL, NULL);
485 ac_cv_func_pthread_create=yes, ac_cv_func_pthread_create=no)])
486 if test "$ac_cv_func_pthread_create" = yes; then
487 test "$DATABASE" && TARGETS="client server utils"
488 if test "x$enable_threaded_client" != xno; then
489 AC_DEFINE(THREADED_CLIENT)
493 AC_REPLACE_FUNCS(snprintf getutline)
495 # AC_CACHE_CHECK([the weather], ac_cv_weather, [
497 # echo $ECHO_N "opening your window... $ECHO_C" >&6
499 # month=`date | cut -f 2 -d ' '`
502 # ac_cv_weather="it's cold!"
505 # ac_cv_weather="it's wet!"
508 # ac_cv_weather="it's hot!"
511 # ac_cv_weather="it's cool"
513 # May | Jun | Sep | *)
514 # ac_cv_weather="it's fine"
519 AC_CACHE_CHECK([under the bed], ac_cv_under_the_bed, [
520 number=`date | cut -c 19`
523 ac_cv_under_the_bed="lunatics and monsters found"
526 ac_cv_under_the_bed="dust bunnies found"
531 dnl Done! Now write the Makefile and sysdep.h
535 AC_SUBST(chkpwd_LIBS)
538 AC_CONFIG_HEADER(sysdep.h)
539 AC_CONFIG_FILES([Makefile weekly])
542 if test -z "$DATABASE"; then
543 AC_MSG_WARN([No database driver was found. Please install Berkeley DB.])
548 echo "... On many operating systems, you must use GNU make (gmake) to compile"