]> code.citadel.org Git - citadel.git/blobdiff - citadel/configure.in
Fixes for Cygwin (see ChangeLog)
[citadel.git] / citadel / configure.in
index 813325cd650296e48920e90a6e1cac516612abd7..7033a63774c6e9cf737a33c6049f1d9649ecce06 100644 (file)
@@ -1,5 +1,6 @@
 dnl Process this file with autoconf to produce a configure script.
-AC_PREREQ(2.12)
+dnl $Id$
+AC_PREREQ(2.13)
 AC_INIT(citserver.c)
 AC_PREFIX_DEFAULT(/usr/local/citadel)
 if test "$prefix" = NONE; then
@@ -8,41 +9,81 @@ else
        AC_DEFINE_UNQUOTED(BBSDIR, "$prefix")
 fi
 
-AC_ARG_ENABLE(autologin, [  --enable-autologin      enable autologin (default is disabled)],[if test "$enableval" = yes; then
-       AC_DEFINE(ENABLE_AUTOLOGIN)
-fi])
-
-AC_ARG_ENABLE(ansi-color, [  --enable-ansi-color     enable ANSI color (default is disabled)],[if test "$enableval" = yes; then
-       AC_DEFINE(ANSI_COLOR)
-fi])
+AC_ARG_ENABLE(autologin, [  --disable-autologin     disable autologin (default is enabled if possible)])
 
+dnl By default, we only build the client (citadel and whobbs) unless we can
+dnl figure out how to build with POSIX threads.
 TARGETS=client
 
+dnl Check for Digital Unix: it has a different way of building for pthreads,
+dnl and we can't build pthreads programs with gcc due to header problems.
 AC_CANONICAL_HOST
 case "$host" in
        alpha*-dec-osf*)
-               dnl We can't use gcc on Digital UNIX due to header file probs
                if test -z "$CC"; then
                        CC=cc
                fi
                SERVER_LDFLAGS=-pthread
                TARGETS="client server utils serv_modules"
        ;;
+       i?86-pc-cygwin32)
+               SUFFIX=.exe
+       ;;
 esac
 
 dnl Checks for programs.
 AC_PROG_CC
 if test "$GCC" = yes; then
        CFLAGS="$CFLAGS -Wall -Wstrict-prototypes"
-       SERVER_LDFLAGS=-rdynamic
+       dnl pass -rdynamic to the linker to enable dlopen() modules to
+       dnl refer to symbols in the main executable (applies to citserver)
+       case "$host" in
+               mips*-sgi-irix*)
+               ;;
+               *)
+                       SERVER_LDFLAGS=-rdynamic
+               ;;
+       esac
+       PICFLAGS=-fPIC
 fi
 AC_PROG_RANLIB
+AC_PROG_INSTALL
+missing_dir=`cd $ac_aux_dir && pwd`
+AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
 
 dnl Checks for libraries.
-AC_CHECK_LIB(crypt, crypt)
-AC_CHECK_LIB(dl, dlopen)
+
+dnl libdl, libgdbm, and libcrypt are only used in the server, so the
+dnl Makefile only passes $(LIBS) to that target. If other programs start
+dnl requiring additional libraries, we'll have to use other variables, as is
+dnl done with curses.
+
+dnl We want to test for crypt() and dlopen() in libc before checking for
+dnl -lcrypt and -ldl, because some systems (like Irix) have both.
+AC_CHECK_FUNCS(crypt dlopen)
+
+dnl We only need crypt() if we're using autologin. FIXME: implement shadow
+dnl passwords and/or PAM...
+if test "$enable_autologin" != no -a "$ac_cv_func_crypt" = no; then
+       AC_CHECK_LIB(crypt, crypt)
+fi
+
+dnl Enable autologin if the feature is requested (which is the default) and
+dnl a crypt() functin is available.
+if test "$enable_autologin" != no -a \( "$ac_cv_func_crypt" = yes -o "$ac_cv_lib_crypt_crypt" = yes \); then
+       AC_DEFINE(ENABLE_AUTOLOGIN)
+fi
+
+if test "$ac_cv_func_dlopen" = no; then
+       AC_CHECK_LIB(dl, dlopen)
+fi
+
 AC_CHECK_LIB(gdbm, gdbm_open)
 AC_CHECK_LIB(curses, initscr, CURSES=-lcurses)
+
+dnl Check for libpthread(s) if we're not using Digital UNIX. (On which the
+dnl -pthread flag takes care of this.) If we find one of the libraries, then
+dnl set up the TARGETS variable to build the server as well as the client.
 if test "$SERVER_LDFLAGS" != -pthread; then
        AC_CHECK_LIB(pthread, pthread_create, [LIBS="$LIBS -lpthread"
                TARGETS="client server utils serv_modules"])
@@ -54,7 +95,7 @@ dnl Checks for header files.
 AC_HEADER_DIRENT
 AC_HEADER_STDC
 AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS(curses.h fcntl.h limits.h termios.h strings.h sys/ioctl.h sys/select.h sys/time.h syslog.h unistd.h)
+AC_CHECK_HEADERS(curses.h fcntl.h limits.h termios.h strings.h sys/ioctl.h sys/select.h sys/time.h syslog.h unistd.h pthread.h gdbm.h)
 
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
@@ -68,15 +109,19 @@ AC_FUNC_GETPGRP
 AC_PROG_GCC_TRADITIONAL
 AC_TYPE_SIGNAL
 AC_FUNC_VPRINTF
-AC_CHECK_FUNCS(snprintf mkdir mktime rmdir select socket strerror)
+AC_CHECK_FUNCS(snprintf mkdir mkfifo mktime rmdir select socket strerror)
 
+dnl Tell the Makefile whether we need to use our snprintf() replacement.
 if test "$ac_cv_func_snprintf" = no; then
        SNPRINTF=snprintf.o
 fi
 
+dnl Done! Now write the Makefile and sysdep.h
 AC_SUBST(CURSES)
 AC_SUBST(TARGETS)
 AC_SUBST(SERVER_LDFLAGS)
 AC_SUBST(SNPRINTF)
+AC_SUBST(PICFLAGS)
+AC_SUBST(SUFFIX)
 AC_CONFIG_HEADER(sysdep.h)
-AC_OUTPUT(Makefile)
+AC_OUTPUT(Makefile weekly)