* Mercilessly ripped out all of the gratuitously complex GNU libintl
[citadel.git] / webcit / configure.in
index 53687536cdb6c7285e9d415e6f9b984b9ebef6ea..de39baae765c18e6d1e41f2b4d218b45df7b0d55 100644 (file)
@@ -3,17 +3,30 @@ dnl $Id$
 AC_INIT(webserver.c)
 
 
-
-
-AC_ARG_WITH(with_zlib, [  --with-zlib             use zlib compression if present])
-AC_ARG_WITH(with_libical, [  --with-libical          use libical calendaring library])
-
-
-
-
+PACKAGE=webcit
+VERSION=6.40
+AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
+AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
+AC_SUBST(PACKAGE)
+AC_SUBST(VERSION)
+AC_SUBST(PROG_SUBDIRS)
 
 AC_CANONICAL_HOST
+AC_PROG_INSTALL
+AC_CHECK_PROG(SED, sed, sed, no)
+AC_PREFIX_DEFAULT(/usr/local/webcit)
 
+AC_ARG_WITH(with_libical, [  --with-libical          use libical calendaring library])
+AC_ARG_WITH(with_zlib,    [  --with-zlib             use zlib compression if present])
+AC_ARG_WITH(with_newt,    [  --with-newt             use newt window library])
+AC_ARG_WITH(ssl,
+       [  --with-ssl=PATH         Specify path to OpenSSL installation ],
+       [
+               if test "x$withval" != "xno" ; then
+                       tryssldir=$withval
+               fi
+       ]
+)
 dnl Set some system-specific variables which are OK to set before compiler
 dnl checks:
 PTHREAD_DEFS=-D_REENTRANT
@@ -51,8 +64,8 @@ if test "$GCC" = yes; then
        esac
 fi
 
-missing_dir=`cd $ac_aux_dir && pwd`
-AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
+dnl ### missing_dir=`cd $ac_aux_dir && pwd`
+dnl ### AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
 
 dnl Checks for libraries.
 if test "$LIBS" != -pthread; then
@@ -67,6 +80,9 @@ AC_HEADER_STDC
 dnl AC_HEADER_SYS_WAIT
 AC_CHECK_HEADERS(fcntl.h limits.h sys/time.h unistd.h)
 
+
+
+
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
 AC_TYPE_OFF_T
@@ -79,30 +95,254 @@ dnl AC_FUNC_VPRINTF
 dnl AC_CHECK_FUNCS(strerror)
 AC_REPLACE_FUNCS(snprintf)
 
+dnl Checks for the libical calendaring library.
+if test "x$with_libical" != xno ; then
+        AC_CHECK_HEADERS(ical.h,
+                [AC_CHECK_LIB(ical, icalcomponent_new,
+                        [ok_libical=yes],,
+        )])
+fi
 
-
-
+if test "x$ok_libical" = xyes ; then
+
+       AC_TRY_RUN(
+               [
+#include <ical.h>
+main() {
+        int major, minor, v;
+        sscanf(ICAL_VERSION, "%d.%d", &major, &minor);
+        v = 100*major + minor;
+        printf("libical version: %i\n", v);
+        if (v >= 24) {
+                printf("This version is ok.\n");
+               return(0);
+       }
+       printf("libical 0.24 or newer required.\n");
+       printf("Citadel will be built without calendar support.\n");
+       return(1);
+}
+               ], 
+               [
+                       LIBS="-lical $LIBS"
+                       AC_DEFINE(HAVE_LIBICAL)
+               ]
+       )
+fi
 
 
 
 dnl Checks for the zlib compression library.
 if test "x$with_zlib" != xno ; then
-       AC_CHECK_HEADERS(zlib.h,
-               [AC_CHECK_LIB(z, zlibVersion,
-                       [ok_zlib=yes],,
+        AC_CHECK_HEADERS(zlib.h,
+                [AC_CHECK_LIB(z, zlibVersion,
+                        [ok_zlib=yes],,
+        )])
+fi
+
+if test "x$ok_zlib" = xyes ; then
+        LIBS="-lz $LIBS"
+        AC_DEFINE(HAVE_ZLIB)
+fi
+
+dnl Checks for the newt window library.
+if test "x$with_newt" != xno ; then
+       AC_CHECK_HEADERS(newt.h,
+               [AC_CHECK_LIB(newt, newtInit,
+                       [ok_newt=yes],,
        )])
 fi
 
-if test "x$ok_zlib" != xno ; then
-       LIBS="-lz $LIBS"
-       AC_DEFINE(HAVE_ZLIB)
+if test "x$ok_newt" = xyes ; then
+       SETUP_LIBS="-lnewt $SETUP_LIBS"
+       AC_DEFINE(HAVE_NEWT)
+fi
+
+# The big search for OpenSSL
+if test "$with_ssl" != "no"; then
+       saved_LIBS="$LIBS"
+       saved_LDFLAGS="$LDFLAGS"
+       saved_CFLAGS="$CFLAGS"
+       if test "x$prefix" != "xNONE"; then
+               tryssldir="$tryssldir $prefix"
+       fi
+       AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
+               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
+                       CFLAGS="$saved_CFLAGS"
+                       LDFLAGS="$saved_LDFLAGS"
+                       LIBS="$saved_LIBS -lssl -lcrypto"
+       
+                       # Skip directories if they don't exist
+                       if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
+                               continue;
+                       fi
+                       if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
+                               # Try to use $ssldir/lib if it exists, otherwise
+                               # $ssldir
+                               if test -d "$ssldir/lib" ; then
+                                       LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
+                                       if test ! -z "$need_dash_r" ; then
+                                               LDFLAGS="-R$ssldir/lib $LDFLAGS"
+                                       fi
+                               else
+                                       LDFLAGS="-L$ssldir $saved_LDFLAGS"
+                                       if test ! -z "$need_dash_r" ; then
+                                               LDFLAGS="-R$ssldir $LDFLAGS"
+                                       fi
+                               fi
+                               # Try to use $ssldir/include if it exists, otherwise
+                               # $ssldir
+                               if test -d "$ssldir/include" ; then
+                                       CFLAGS="-I$ssldir/include $saved_CFLAGS"
+                               else
+                                       CFLAGS="-I$ssldir $saved_CFLAGS"
+                               fi
+                       fi
+       
+                       # Basic test to check for compatible version and correct linking
+                       # *does not* test for RSA - that comes later.
+                       AC_TRY_RUN(
+                               [
+       #include <string.h>
+       #include <openssl/rand.h>
+       int main(void)
+       {
+               char a[2048];
+               memset(a, 0, sizeof(a));
+               RAND_add(a, sizeof(a), sizeof(a));
+               return(RAND_status() <= 0);
+       }
+                               ],
+                               [
+                                       found_crypto=1
+                                       break;
+                               ], []
+                       )
+       
+                       if test ! -z "$found_crypto" ; then
+                               break;
+                       fi
+               done
+       
+               if test -z "$ssldir" ; then
+                       ssldir="(system)"
+               fi
+       
+               if test ! -z "$found_crypto" ; then
+                       ac_cv_openssldir=$ssldir
+               else
+                       ac_cv_openssldir="no"
+               fi
+       ])
+       LIBS="$saved_LIBS"
+       LDFLAGS="$saved_LDFLAGS"
+       CFLAGS="$saved_CFLAGS"
+       
+       if test "x$ac_cv_openssldir" != "xno" ; then
+               AC_DEFINE(HAVE_OPENSSL)
+               LIBS="-lssl -lcrypto $LIBS"
+               dnl Need to recover ssldir - test above runs in subshell
+               ssldir=$ac_cv_openssldir
+               if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
+                       # Try to use $ssldir/lib if it exists, otherwise
+                       # $ssldir
+                       if test -d "$ssldir/lib" ; then
+                               LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
+                               if test ! -z "$need_dash_r" ; then
+                                       LDFLAGS="-R$ssldir/lib $LDFLAGS"
+                               fi
+                       else
+                               LDFLAGS="-L$ssldir $saved_LDFLAGS"
+                               if test ! -z "$need_dash_r" ; then
+                                       LDFLAGS="-R$ssldir $LDFLAGS"
+                               fi
+                       fi
+                       # Try to use $ssldir/include if it exists, otherwise
+                       # $ssldir
+                       if test -d "$ssldir/include" ; then
+                               CFLAGS="-I$ssldir/include $saved_CFLAGS"
+                       else
+                               CFLAGS="-I$ssldir $saved_CFLAGS"
+                       fi
+               fi
+       fi
+fi
+
+dnl Here is the check for a usable iconv
+
+AC_ARG_ENABLE(iconv,
+       [  --disable-iconv         do not use iconv charset conversion],
+       ok_iconv=no, ok_iconv=yes)
+
+if test "$ok_nls" != "no"; then
+       AC_MSG_RESULT(Checking to see if your system supports iconv...)
+       AC_TRY_RUN([
+               #include <iconv.h>
+               main() {
+                       iconv_t ic = (iconv_t)(-1) ;
+                       ic = iconv_open("UTF-8", "us-ascii");
+                       iconv_close(ic);
+                       exit(0);
+               }
+       ],
+               ok_iconv=yes,
+               ok_iconv=no
+       )
+fi
+
+if test "$ok_iconv" != "no"; then
+       AC_MSG_RESULT(WebCit will be built with character set conversion.)
+       AC_DEFINE(HAVE_ICONV)
+else
+       AC_MSG_RESULT(WebCit will be built without character set conversion.)
 fi
 
 
 
+dnl Here is the check for libintl etc.
+
+AC_ARG_ENABLE(nls,
+       [  --disable-nls           do not use Native Language Support],
+       ok_nls=no, ok_nls=yes)
+
+if test "$ok_nls" != "no"; then
+       AC_MSG_RESULT(Checking to see if your system supports multithreaded NLS...)
+       AC_TRY_RUN([
+               #define _GNU_SOURCE
+               #include <locale.h>
+               #include <libintl.h>
+               main() {
+                       char *foo;
+                       uselocale(LC_GLOBAL_LOCALE);
+                       foo = gettext("bar");
+                       exit(0);
+               }
+       ],
+               ok_nls=yes,
+               ok_nls=no
+       )
+fi
+
+if test "$ok_nls" != "no"; then
+       AC_CHECK_PROG(ok_nls, xgettext, yes, no)
+fi
+
+if test "$ok_nls" != "no"; then
+       AC_CHECK_PROG(ok_nls, msgmerge, yes, no)
+fi
 
+if test "$ok_nls" != "no"; then
+       AC_CHECK_PROG(ok_nls, msgfmt, yes, no)
+fi
 
+if test "$ok_nls" != "no"; then
+       AC_MSG_RESULT(WebCit will be built with national language support.)
+       AC_DEFINE(ENABLE_NLS)
+       PROG_SUBDIRS="$PROG_SUBDIRS po"
+else
+       AC_MSG_RESULT(WebCit will be built without national language support.)
+fi
 
+AC_SUBST(SETUP_LIBS)
 
+AC_OUTPUT(Makefile po/Makefile )
 
-AC_OUTPUT(Makefile)