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
101 sscanf(ICAL_VERSION, "%f", &v);
102 printf("libical version: %0.2f\n", v);
106 printf("This version is ok.\n");
107 printf("WebCit will be built with calendar support.\n");
110 printf("libical 0.24 or newer is required.\n");
111 printf("WebCit will be built without calendar support.\n");
117 AC_DEFINE(HAVE_LIBICAL)
124 dnl Checks for the zlib compression library.
125 if test "x$with_zlib" != xno ; then
126 AC_CHECK_HEADERS(zlib.h,
127 [AC_CHECK_LIB(z, zlibVersion,
132 if test "x$ok_zlib" = xyes ; then
138 dnl Checks for the newt window library.
139 if test "x$with_newt" != xno ; then
140 AC_CHECK_HEADERS(newt.h,
141 [AC_CHECK_LIB(newt, newtInit,
146 if test "x$ok_newt" = xyes ; then
147 SETUP_LIBS="-lnewt $SETUP_LIBS"
151 # The big search for OpenSSL
152 if test "$with_ssl" != "no"; then
154 saved_LDFLAGS="$LDFLAGS"
155 saved_CFLAGS="$CFLAGS"
156 if test "x$prefix" != "xNONE"; then
157 tryssldir="$tryssldir $prefix"
159 AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
160 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
161 CFLAGS="$saved_CFLAGS"
162 LDFLAGS="$saved_LDFLAGS"
163 LIBS="$saved_LIBS -lssl -lcrypto"
165 # Skip directories if they don't exist
166 if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
169 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
170 # Try to use $ssldir/lib if it exists, otherwise
172 if test -d "$ssldir/lib" ; then
173 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
174 if test ! -z "$need_dash_r" ; then
175 LDFLAGS="-R$ssldir/lib $LDFLAGS"
178 LDFLAGS="-L$ssldir $saved_LDFLAGS"
179 if test ! -z "$need_dash_r" ; then
180 LDFLAGS="-R$ssldir $LDFLAGS"
183 # Try to use $ssldir/include if it exists, otherwise
185 if test -d "$ssldir/include" ; then
186 CFLAGS="-I$ssldir/include $saved_CFLAGS"
188 CFLAGS="-I$ssldir $saved_CFLAGS"
192 # Basic test to check for compatible version and correct linking
193 # *does not* test for RSA - that comes later.
197 #include <openssl/rand.h>
201 memset(a, 0, sizeof(a));
202 RAND_add(a, sizeof(a), sizeof(a));
203 return(RAND_status() <= 0);
212 if test ! -z "$found_crypto" ; then
217 if test -z "$ssldir" ; then
221 if test ! -z "$found_crypto" ; then
222 ac_cv_openssldir=$ssldir
224 ac_cv_openssldir="no"
228 LDFLAGS="$saved_LDFLAGS"
229 CFLAGS="$saved_CFLAGS"
231 if test "x$ac_cv_openssldir" != "xno" ; then
232 AC_DEFINE(HAVE_OPENSSL)
233 LIBS="-lssl -lcrypto $LIBS"
234 dnl Need to recover ssldir - test above runs in subshell
235 ssldir=$ac_cv_openssldir
236 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
237 # Try to use $ssldir/lib if it exists, otherwise
239 if test -d "$ssldir/lib" ; then
240 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
241 if test ! -z "$need_dash_r" ; then
242 LDFLAGS="-R$ssldir/lib $LDFLAGS"
245 LDFLAGS="-L$ssldir $saved_LDFLAGS"
246 if test ! -z "$need_dash_r" ; then
247 LDFLAGS="-R$ssldir $LDFLAGS"
250 # Try to use $ssldir/include if it exists, otherwise
252 if test -d "$ssldir/include" ; then
253 CFLAGS="-I$ssldir/include $saved_CFLAGS"
255 CFLAGS="-I$ssldir $saved_CFLAGS"