1 dnl Process this file with autoconf to produce a configure script.
4 AC_INIT([Citadel/UX], [5.91], [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(gdbm, [ --with-gdbm@<:@=DIR@:>@ use GDBM @<:@DIR=/usr/local@:>@])
23 AC_ARG_WITH(db, [ --with-db@<:@=DIR@:>@ use Sleepycat DB 3.x @<:@DIR=/usr/local/BerkeleyDB.3.@<:@123@:>@@:>@])
25 [ --with-ssl=PATH Specify path to OpenSSL installation ],
27 if test "x$withval" != "xno" ; then
33 if test "x$with_gdbm" != xno -a "x$with_gdbm" != xyes -a "$with_gdbm"; then
38 if test "x$with_db" != xno -a "x$with_db" != xyes -a "$with_db"; then
42 test -d /usr/local/BerkeleyDB.3.1 && db_dir=/usr/local/BerkeleyDB.3.1
43 test -d /usr/local/BerkeleyDB.3.2 && db_dir=/usr/local/BerkeleyDB.3.2
44 test -d /usr/local/BerkeleyDB.3.3 && db_dir=/usr/local/BerkeleyDB.3.3
45 test -d /usr/local/BerkeleyDB.4.0 && db_dir=/usr/local/BerkeleyDB.4.0
48 if test "x$with_gdbm" = xyes -a "x$with_db" = xyes; then
49 AC_MSG_ERROR(can't enable both gdbm and db)
52 dnl By default, we only build the client (citadel and whobbs) unless we can
53 dnl figure out how to build with POSIX threads.
57 PTHREAD_DEFS=-D_REENTRANT
59 dnl BSDI 3.0 wants relocatable object modules instead of shared libs
60 dnl for dlopen(), and has a wrapper script to link with shared libs.
61 dnl Also has stupid non-reentrant gethostbyaddr() and friends.
63 test -z "$CC" -a -x /usr/bin/shlicc2 && CC=shlicc2
64 AC_DEFINE(HAVE_NONREENTRANT_NETDB)
67 AC_DEFINE(HAVE_NONREENTRANT_NETDB)
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 PTHREAD_LIBS="-lpthread -lexc"
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"
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"
114 AC_SUBST(LIBTOOL_DEPS)
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 Checks for libraries.
125 dnl libdl, libgdbm, and libcrypt are only used in the server, so the
126 dnl Makefile only passes $(LIBS) to that target. If other programs start
127 dnl requiring additional libraries, we'll have to use other variables, as is
128 dnl done with curses.
130 dnl We want to test for the following in libc before checking for their
131 dnl respective libraries, because some systems (like Irix) have both, and the
132 dnl non-libc versions may be broken.
133 AC_CHECK_FUNCS(crypt dlopen gethostbyname connect)
135 if test "$ac_cv_func_gethostbyname" = no; then
136 AC_CHECK_LIB(nsl, gethostbyname, NETLIBS="-lnsl $NETLIBS")
139 if test "$ac_cv_func_connect" = no; then
140 AC_CHECK_LIB(socket, connect, NETLIBS="-lsocket $NETLIBS",, $NETLIBS)
143 if test "$ac_cv_func_dlopen" = no; then
144 AC_CHECK_LIB(dl, dlopen, [LIBS="-ldl $LIBS"
145 test "$with_pam" = yes && chkpwd_LIBS="-ldl $chkpwd_LIBS"])
148 dnl Check for HP/UX dyanmic loader. This should only be in -ldld.
149 AC_CHECK_LIB(dld, shl_load, LIBS="-ldld $LIBS")
151 dnl Check for Solaris realtime support
152 AC_CHECK_LIB(rt, sched_yield)
154 dnl Determine the system's authentication capabilities, if autologin is
155 dnl requested. We currently support PAM, standard getpwnam(), and getspnam()
156 dnl (Linux shadow passwords)
157 if test "$enable_autologin" != no; then
158 if test "$with_pam" = yes; then
160 AC_CHECK_LIB(pam, pam_start, [chkpwd_LIBS="-lpam $chkpwd_LIBS"
162 AC_CHECK_FUNCS(pam_start)
163 test "$enable_chkpwd" != no && LIBS=$save_LIBS
165 if test "$ac_cv_func_pam_start" = no -o "$with_pam" != yes; then
167 AC_SEARCH_LIBS(getspnam, shadow, [
168 if test "$ac_cv_search_getspnam" = -lshadow; then
169 chkpwd_LIBS="-lshadow $chkpwd_LIBS"
171 test "$enable_chkpwd" != no && LIBS=$save_LIBS
172 if test "$ac_cv_func_crypt" = no; then
173 AC_CHECK_LIB(crypt, crypt, [
174 chkpwd_LIBS="-lcrypt $chkpwd_LIBS"
175 test "$enable_chkpwd" = no && \
176 LIBS="-lcrypt $LIBS"])
179 if test "$ac_cv_func_crypt" = yes -o "$ac_cv_lib_crypt_crypt" = yes -o "$ac_cv_func_pam_start" = yes; then
180 AC_DEFINE(ENABLE_AUTOLOGIN)
181 if test "$enable_chkpwd" != no; then
182 AC_DEFINE(ENABLE_CHKPWD)
190 if test "x$with_db" != xno -a "x$with_gdbm" != xyes; then
191 test "$db_dir" && LDFLAGS="$LDFLAGS -L$db_dir/lib"
193 test "$db_dir" && CPPFLAGS="$CPPFLAGS -I$db_dir/include" || \
194 ( test -d /usr/include/db3 && CPPFLAGS="$CPPFLAGS -I/usr/include/db3" ) || \
195 ( test -d /usr/local/include/db3 && CPPFLAGS="$CPPFLAGS -I/usr/local/include/db3" )
197 AC_CHECK_LIB(db3, db_env_create,
199 DATABASE=database_sleepycat.c
200 with_gdbm=no], [AC_CHECK_LIB(db, db_env_create,
202 DATABASE=database_sleepycat.c
203 with_gdbm=no], [], [$NETLIBS])], [$NETLIBS])
206 if test "x$with_gdbm" != xno -a "x$with_db" != xyes; then
207 test -f /usr/local/lib/libgdbm.a -o -f /usr/local/lib/libgdbm.so && db_dir=/usr/local
208 test "$db_dir" && LDFLAGS="$LDFLAGS -L$db_dir/lib"
210 test "$db_dir" && CPPFLAGS="$CPPFLAGS -I$db_dir/include"
212 AC_CHECK_LIB(gdbm, gdbm_open,
218 test -f /usr/local/lib/libresolv.a && LDFLAGS="$LDFLAGS -L/usr/local/lib"
219 AC_CHECK_LIB(resolv, res_query, RESOLV="$RESOLV -lresolv")
223 AC_SEARCH_LIBS(tgetent, [ncurses curses termcap])
224 AC_SEARCH_LIBS(initscr, [ncurses curses])
225 AC_CHECK_FUNCS(vw_printw wcolor_set)
229 dnl Check for libpthread(s) if we're not using Digital UNIX or FreeBSD. (On
230 dnl which the -pthread flag takes care of this.)
231 if test "$check_pthread" != no; then
232 AC_CHECK_LIB(pthread, pthread_create,
233 PTHREAD_LIBS="-lpthread $PTHREAD_LIBS")
234 AC_CHECK_LIB(pthreads, pthread_create,
235 PTHREAD_LIBS="-lpthreads $PTHREAD_LIBS")
238 # The big search for OpenSSL
239 if test "$with_ssl" != "no"; then
241 saved_LDFLAGS="$LDFLAGS"
242 saved_CFLAGS="$CFLAGS"
243 if test "x$prefix" != "xNONE"; then
244 tryssldir="$tryssldir $prefix"
246 AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
247 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
248 CFLAGS="$saved_CFLAGS"
249 LDFLAGS="$saved_LDFLAGS"
250 LIBS="$saved_LIBS -lssl -lcrypto"
252 # Skip directories if they don't exist
253 if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
256 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
257 # Try to use $ssldir/lib if it exists, otherwise
259 if test -d "$ssldir/lib" ; then
260 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
261 if test ! -z "$need_dash_r" ; then
262 LDFLAGS="-R$ssldir/lib $LDFLAGS"
265 LDFLAGS="-L$ssldir $saved_LDFLAGS"
266 if test ! -z "$need_dash_r" ; then
267 LDFLAGS="-R$ssldir $LDFLAGS"
270 # Try to use $ssldir/include if it exists, otherwise
272 if test -d "$ssldir/include" ; then
273 CFLAGS="-I$ssldir/include $saved_CFLAGS"
275 CFLAGS="-I$ssldir $saved_CFLAGS"
279 # Basic test to check for compatible version and correct linking
280 # *does not* test for RSA - that comes later.
284 #include <openssl/rand.h>
288 memset(a, 0, sizeof(a));
289 RAND_add(a, sizeof(a), sizeof(a));
290 return(RAND_status() <= 0);
299 if test ! -z "$found_crypto" ; then
304 if test -z "$ssldir" ; then
308 if test ! -z "$found_crypto" ; then
309 ac_cv_openssldir=$ssldir
311 ac_cv_openssldir="no"
315 LDFLAGS="$saved_LDFLAGS"
316 CFLAGS="$saved_CFLAGS"
318 if test "x$ac_cv_openssldir" != "xno" ; then
319 AC_DEFINE(HAVE_OPENSSL)
321 SSL_LIBS="-lssl -lcrypto"
322 dnl Need to recover ssldir - test above runs in subshell
323 ssldir=$ac_cv_openssldir
324 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
325 # Try to use $ssldir/lib if it exists, otherwise
327 if test -d "$ssldir/lib" ; then
328 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
329 if test ! -z "$need_dash_r" ; then
330 LDFLAGS="-R$ssldir/lib $LDFLAGS"
333 LDFLAGS="-L$ssldir $saved_LDFLAGS"
334 if test ! -z "$need_dash_r" ; then
335 LDFLAGS="-R$ssldir $LDFLAGS"
338 # Try to use $ssldir/include if it exists, otherwise
340 if test -d "$ssldir/include" ; then
341 CFLAGS="-I$ssldir/include $saved_CFLAGS"
343 CFLAGS="-I$ssldir $saved_CFLAGS"
349 dnl Checks for header files.
355 dnl TODO: for the DB header checks, we should check whether the headers
356 dnl define db_env_create, somehow
358 AC_CHECK_HEADERS(curses.h ncurses.h dl.h fcntl.h limits.h termios.h sys/ioctl.h sys/select.h sys/time.h syslog.h unistd.h utmp.h utmpx.h paths.h db.h db3/db.h db4/db.h)
360 AC_CHECK_HEADER(resolv.h, [SMTP=modules/libsmtp.la; DOMAIN=domain.c])
364 dnl some systems require -pthread, -D_REENTRANT, etc to be passed to cc if we
365 dnl include pthread.h:
366 save_CPPFLAGS=$CPPFLAGS
367 CPPFLAGS="$CPPFLAGS $PTHREAD_DEFS"
368 AC_CHECK_HEADERS(pthread.h)
369 CPPFLAGS=$save_CPPFLAGS
371 dnl Checks for typedefs, structures, and compiler characteristics.
377 dnl defined in acinclude.m4:
380 dnl Check the size of various builtin types; see typesize.h (error)
381 AC_CHECK_SIZEOF(char, 0)
382 AC_CHECK_SIZEOF(short, 0)
383 AC_CHECK_SIZEOF(int, 0)
384 AC_CHECK_SIZEOF(long, 0)
385 dnl AC_CHECK_SIZEOF(long long, 0)
387 AC_CACHE_CHECK([for ut_type in struct utmp], ac_cv_struct_ut_type,
388 [AC_TRY_COMPILE([#include <sys/types.h>
389 #include <utmp.h>], [struct utmp ut; ut.ut_type;],
390 ac_cv_struct_ut_type=yes, ac_cv_struct_ut_type=no)])
391 if test $ac_cv_struct_ut_type = yes; then
392 AC_DEFINE(HAVE_UT_TYPE)
395 AC_CACHE_CHECK([for ut_host in struct utmp], ac_cv_struct_ut_host,
396 [AC_TRY_COMPILE([#include <sys/types.h>
397 #include <utmp.h>], [struct utmp ut; ut.ut_host;],
398 ac_cv_struct_ut_host=yes, ac_cv_struct_ut_host=no)])
399 if test $ac_cv_struct_ut_host = yes; then
400 AC_DEFINE(HAVE_UT_HOST)
403 dnl Checks for library functions.
405 AC_PROG_GCC_TRADITIONAL
408 AC_CHECK_FUNCS(getspnam getutxline mkdir mkfifo mktime rmdir select socket strerror strcasecmp strncasecmp)
410 dnl Now check for pthreads -- set up variables so that the compiler will be run
411 dnl with proper flags for pthread programs
413 LIBS="$PTHREAD_LIBS $LIBS"
415 dnl On some platforms, AC_CHECK_FUNC[S] doesn't work for pthreads programs;
416 dnl we need to include pthread.h
418 AC_CACHE_CHECK([for pthread_cancel], ac_cv_func_pthread_cancel,
419 [AC_TRY_LINK([#include <pthread.h>],
422 /* The GNU C library defines this for functions which it implements
423 to always fail with ENOSYS. Some functions are actually named
424 something starting with __ and the normal name is an alias. */
425 #if defined (__stub_pthread_cancel) || defined (__stub___pthread_cancel)
428 pthread_cancel(thread);
430 ac_cv_func_pthread_cancel=yes, ac_cv_func_pthread_cancel=no)])
431 if test "$ac_cv_func_pthread_cancel" = yes; then
432 AC_DEFINE(HAVE_PTHREAD_CANCEL)
435 AC_CACHE_CHECK([for pthread_create], ac_cv_func_pthread_create,
436 [AC_TRY_LINK([#include <pthread.h>],
437 [ /* The GNU C library defines this for functions which it implements
438 to always fail with ENOSYS. Some functions are actually named
439 something starting with __ and the normal name is an alias. */
440 #if defined (__stub_pthread_cancel) || defined (__stub___pthread_cancel)
443 pthread_create(NULL, NULL, NULL, NULL);
445 ac_cv_func_pthread_create=yes, ac_cv_func_pthread_create=no)])
446 if test "$ac_cv_func_pthread_create" = yes; then
447 test "$DATABASE" && TARGETS="client server utils serv_modules"
448 if test "x$enable_threaded_client" != xno; then
449 AC_DEFINE(THREADED_CLIENT)
450 CLIENT_PTLIBS=$PTHREAD_LIBS
451 CL_LIBOBJS='$(LIBOBJS:.o=.ro)'
456 if test "x$CX" != x.ro; then
457 CL_LIBOBJS='$(LIBOBJS)'
461 dnl Now restore the old libs so we don't pass the wrong stuff to makefile
464 AC_REPLACE_FUNCS(snprintf getutline)
466 dnl Done! Now write the Makefile and sysdep.h
473 AC_SUBST(chkpwd_LIBS)
475 AC_SUBST(PTHREAD_DEFS)
476 AC_SUBST(PTHREAD_LIBS)
477 AC_SUBST(CLIENT_PTLIBS)
482 AC_CONFIG_HEADER(sysdep.h)
483 AC_CONFIG_FILES([Makefile weekly])
486 if test -z "$DATABASE"; then
487 AC_MSG_WARN([No database driver was found. Please install Berkeley DB.])