1 dnl Process this file with autoconf to produce a configure script.
7 AC_PREFIX_DEFAULT(/usr/local/webcit)
9 AC_ARG_WITH(with_libical, [ --with-libical use libical calendaring library])
10 AC_ARG_WITH(with_zlib, [ --with-zlib use zlib compression if present])
11 AC_ARG_WITH(with_newt, [ --with-newt use newt window library])
13 [ --with-ssl=PATH Specify path to OpenSSL installation ],
15 if test "x$withval" != "xno" ; then
20 dnl Set some system-specific variables which are OK to set before compiler
22 PTHREAD_DEFS=-D_REENTRANT
24 dnl Tru64 Unix requires we use -pthread instead of linking the threads
25 dnl libraries directly, and we can't build threaded programs with gcc
26 dnl due to header file problems.
28 test -z "$CC" && CC=cc
31 dnl FreeBSD is similar:
34 PTHREAD_DEFS=-D_THREAD_SAFE
37 PTHREAD_DEFS='-D_REENTRANT -D_PTHREADS'
40 AC_SUBST(PTHREAD_DEFS)
42 dnl Checks for programs.
45 dnl Configure compiler flags for GCC
46 if test "$GCC" = yes; then
49 CFLAGS="$CFLAGS -Wall -Wno-char-subscripts"
52 CFLAGS="$CFLAGS -Wall"
57 missing_dir=`cd $ac_aux_dir && pwd`
58 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
60 dnl Checks for libraries.
61 if test "$LIBS" != -pthread; then
62 AC_CHECK_LIB(pthread, pthread_create)
63 AC_CHECK_LIB(pthreads, pthread_create)
65 AC_SEARCH_LIBS(gethostbyname, nsl)
66 AC_SEARCH_LIBS(connect, socket)
68 dnl Checks for header files.
70 dnl AC_HEADER_SYS_WAIT
71 AC_CHECK_HEADERS(fcntl.h limits.h sys/time.h unistd.h)
73 dnl Checks for typedefs, structures, and compiler characteristics.
79 dnl Checks for library functions.
82 dnl AC_CHECK_FUNCS(strerror)
83 AC_REPLACE_FUNCS(snprintf)
85 dnl Checks for the libical calendaring library.
86 if test "x$with_libical" != xno ; then
87 AC_CHECK_HEADERS(ical.h,
88 [AC_CHECK_LIB(ical, icalcomponent_new,
93 if test "x$ok_libical" = xyes ; then
100 sscanf(ICAL_VERSION, "%d.%d", &major, &minor);
101 v = 100*major + minor;
102 printf("libical version: %i\n", v);
104 printf("This version is ok.\n");
107 printf("libical 0.24 or newer required.\n");
108 printf("Citadel will be built without calendar support.\n");
114 AC_DEFINE(HAVE_LIBICAL)
121 dnl Checks for the zlib compression library.
122 if test "x$with_zlib" != xno ; then
123 AC_CHECK_HEADERS(zlib.h,
124 [AC_CHECK_LIB(z, zlibVersion,
129 if test "x$ok_zlib" = xyes ; then
135 dnl Checks for the newt window library.
136 if test "x$with_newt" != xno ; then
137 AC_CHECK_HEADERS(newt.h,
138 [AC_CHECK_LIB(newt, newtInit,
143 if test "x$ok_newt" = xyes ; then
144 SETUP_LIBS="-lnewt $SETUP_LIBS"
148 # The big search for OpenSSL
149 if test "$with_ssl" != "no"; then
151 saved_LDFLAGS="$LDFLAGS"
152 saved_CFLAGS="$CFLAGS"
153 if test "x$prefix" != "xNONE"; then
154 tryssldir="$tryssldir $prefix"
156 AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
157 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
158 CFLAGS="$saved_CFLAGS"
159 LDFLAGS="$saved_LDFLAGS"
160 LIBS="$saved_LIBS -lssl -lcrypto"
162 # Skip directories if they don't exist
163 if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
166 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
167 # Try to use $ssldir/lib if it exists, otherwise
169 if test -d "$ssldir/lib" ; then
170 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
171 if test ! -z "$need_dash_r" ; then
172 LDFLAGS="-R$ssldir/lib $LDFLAGS"
175 LDFLAGS="-L$ssldir $saved_LDFLAGS"
176 if test ! -z "$need_dash_r" ; then
177 LDFLAGS="-R$ssldir $LDFLAGS"
180 # Try to use $ssldir/include if it exists, otherwise
182 if test -d "$ssldir/include" ; then
183 CFLAGS="-I$ssldir/include $saved_CFLAGS"
185 CFLAGS="-I$ssldir $saved_CFLAGS"
189 # Basic test to check for compatible version and correct linking
190 # *does not* test for RSA - that comes later.
194 #include <openssl/rand.h>
198 memset(a, 0, sizeof(a));
199 RAND_add(a, sizeof(a), sizeof(a));
200 return(RAND_status() <= 0);
209 if test ! -z "$found_crypto" ; then
214 if test -z "$ssldir" ; then
218 if test ! -z "$found_crypto" ; then
219 ac_cv_openssldir=$ssldir
221 ac_cv_openssldir="no"
225 LDFLAGS="$saved_LDFLAGS"
226 CFLAGS="$saved_CFLAGS"
228 if test "x$ac_cv_openssldir" != "xno" ; then
229 AC_DEFINE(HAVE_OPENSSL)
230 LIBS="-lssl -lcrypto $LIBS"
231 dnl Need to recover ssldir - test above runs in subshell
232 ssldir=$ac_cv_openssldir
233 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
234 # Try to use $ssldir/lib if it exists, otherwise
236 if test -d "$ssldir/lib" ; then
237 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
238 if test ! -z "$need_dash_r" ; then
239 LDFLAGS="-R$ssldir/lib $LDFLAGS"
242 LDFLAGS="-L$ssldir $saved_LDFLAGS"
243 if test ! -z "$need_dash_r" ; then
244 LDFLAGS="-R$ssldir $LDFLAGS"
247 # Try to use $ssldir/include if it exists, otherwise
249 if test -d "$ssldir/include" ; then
250 CFLAGS="-I$ssldir/include $saved_CFLAGS"
252 CFLAGS="-I$ssldir $saved_CFLAGS"