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_iconv, [ --with-iconv use iconv character set conversion if present])
12 AC_ARG_WITH(with_newt, [ --with-newt use newt window library])
14 [ --with-ssl=PATH Specify path to OpenSSL installation ],
16 if test "x$withval" != "xno" ; then
21 dnl Set some system-specific variables which are OK to set before compiler
23 PTHREAD_DEFS=-D_REENTRANT
25 dnl Tru64 Unix requires we use -pthread instead of linking the threads
26 dnl libraries directly, and we can't build threaded programs with gcc
27 dnl due to header file problems.
29 test -z "$CC" && CC=cc
32 dnl FreeBSD is similar:
35 PTHREAD_DEFS=-D_THREAD_SAFE
38 PTHREAD_DEFS='-D_REENTRANT -D_PTHREADS'
41 AC_SUBST(PTHREAD_DEFS)
43 dnl Checks for programs.
46 dnl Configure compiler flags for GCC
47 if test "$GCC" = yes; then
50 CFLAGS="$CFLAGS -Wall -Wno-char-subscripts"
53 CFLAGS="$CFLAGS -Wall"
58 missing_dir=`cd $ac_aux_dir && pwd`
59 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
61 dnl Checks for libraries.
62 if test "$LIBS" != -pthread; then
63 AC_CHECK_LIB(pthread, pthread_create)
64 AC_CHECK_LIB(pthreads, pthread_create)
66 AC_SEARCH_LIBS(gethostbyname, nsl)
67 AC_SEARCH_LIBS(connect, socket)
69 dnl Checks for header files.
71 dnl AC_HEADER_SYS_WAIT
72 AC_CHECK_HEADERS(fcntl.h limits.h sys/time.h unistd.h)
74 dnl Checks for typedefs, structures, and compiler characteristics.
80 dnl Checks for library functions.
83 dnl AC_CHECK_FUNCS(strerror)
84 AC_REPLACE_FUNCS(snprintf)
86 dnl Checks for the libical calendaring library.
87 if test "x$with_libical" != xno ; then
88 AC_CHECK_HEADERS(ical.h,
89 [AC_CHECK_LIB(ical, icalcomponent_new,
94 if test "x$ok_libical" = xyes ; then
101 sscanf(ICAL_VERSION, "%d.%d", &major, &minor);
102 v = 100*major + minor;
103 printf("libical version: %i\n", v);
105 printf("This version is ok.\n");
108 printf("libical 0.24 or newer required.\n");
109 printf("Citadel will be built without calendar support.\n");
115 AC_DEFINE(HAVE_LIBICAL)
122 dnl Checks for the zlib compression library.
123 if test "x$with_zlib" != xno ; then
124 AC_CHECK_HEADERS(zlib.h,
125 [AC_CHECK_LIB(z, zlibVersion,
130 if test "x$ok_zlib" = xyes ; then
136 dnl Checks for the iconv charset conversion function facility.
137 if test "x$with_iconv" != xno ; then
138 AC_CHECK_HEADERS(iconv.h, [ok_iconv=yes])
141 if test "x$ok_iconv" = xyes ; then
142 AC_CHECK_LIB([iconv], [iconv], [
143 AC_DEFINE(HAVE_ICONV)
146 [ AC_CHECK_FUNC([iconv], [AC_DEFINE(HAVE_ICONV)] ]
152 dnl Checks for the newt window library.
153 if test "x$with_newt" != xno ; then
154 AC_CHECK_HEADERS(newt.h,
155 [AC_CHECK_LIB(newt, newtInit,
160 if test "x$ok_newt" = xyes ; then
161 SETUP_LIBS="-lnewt $SETUP_LIBS"
165 # The big search for OpenSSL
166 if test "$with_ssl" != "no"; then
168 saved_LDFLAGS="$LDFLAGS"
169 saved_CFLAGS="$CFLAGS"
170 if test "x$prefix" != "xNONE"; then
171 tryssldir="$tryssldir $prefix"
173 AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
174 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
175 CFLAGS="$saved_CFLAGS"
176 LDFLAGS="$saved_LDFLAGS"
177 LIBS="$saved_LIBS -lssl -lcrypto"
179 # Skip directories if they don't exist
180 if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
183 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
184 # Try to use $ssldir/lib if it exists, otherwise
186 if test -d "$ssldir/lib" ; then
187 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
188 if test ! -z "$need_dash_r" ; then
189 LDFLAGS="-R$ssldir/lib $LDFLAGS"
192 LDFLAGS="-L$ssldir $saved_LDFLAGS"
193 if test ! -z "$need_dash_r" ; then
194 LDFLAGS="-R$ssldir $LDFLAGS"
197 # Try to use $ssldir/include if it exists, otherwise
199 if test -d "$ssldir/include" ; then
200 CFLAGS="-I$ssldir/include $saved_CFLAGS"
202 CFLAGS="-I$ssldir $saved_CFLAGS"
206 # Basic test to check for compatible version and correct linking
207 # *does not* test for RSA - that comes later.
211 #include <openssl/rand.h>
215 memset(a, 0, sizeof(a));
216 RAND_add(a, sizeof(a), sizeof(a));
217 return(RAND_status() <= 0);
226 if test ! -z "$found_crypto" ; then
231 if test -z "$ssldir" ; then
235 if test ! -z "$found_crypto" ; then
236 ac_cv_openssldir=$ssldir
238 ac_cv_openssldir="no"
242 LDFLAGS="$saved_LDFLAGS"
243 CFLAGS="$saved_CFLAGS"
245 if test "x$ac_cv_openssldir" != "xno" ; then
246 AC_DEFINE(HAVE_OPENSSL)
247 LIBS="-lssl -lcrypto $LIBS"
248 dnl Need to recover ssldir - test above runs in subshell
249 ssldir=$ac_cv_openssldir
250 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
251 # Try to use $ssldir/lib if it exists, otherwise
253 if test -d "$ssldir/lib" ; then
254 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
255 if test ! -z "$need_dash_r" ; then
256 LDFLAGS="-R$ssldir/lib $LDFLAGS"
259 LDFLAGS="-L$ssldir $saved_LDFLAGS"
260 if test ! -z "$need_dash_r" ; then
261 LDFLAGS="-R$ssldir $LDFLAGS"
264 # Try to use $ssldir/include if it exists, otherwise
266 if test -d "$ssldir/include" ; then
267 CFLAGS="-I$ssldir/include $saved_CFLAGS"
269 CFLAGS="-I$ssldir $saved_CFLAGS"