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_newt, [ --with-newt use newt window library])
12 [ --with-ssl=PATH Specify path to OpenSSL installation ],
14 if test "x$withval" != "xno" ; then
19 dnl Set some system-specific variables which are OK to set before compiler
21 PTHREAD_DEFS=-D_REENTRANT
23 dnl Tru64 Unix requires we use -pthread instead of linking the threads
24 dnl libraries directly, and we can't build threaded programs with gcc
25 dnl due to header file problems.
27 test -z "$CC" && CC=cc
30 dnl FreeBSD is similar:
33 PTHREAD_DEFS=-D_THREAD_SAFE
36 PTHREAD_DEFS='-D_REENTRANT -D_PTHREADS'
39 AC_SUBST(PTHREAD_DEFS)
41 dnl Checks for programs.
44 dnl Configure compiler flags for GCC
45 if test "$GCC" = yes; then
48 CFLAGS="$CFLAGS -Wall -Wno-char-subscripts"
51 CFLAGS="$CFLAGS -Wall"
56 missing_dir=`cd $ac_aux_dir && pwd`
57 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
59 dnl Checks for libraries.
60 if test "$LIBS" != -pthread; then
61 AC_CHECK_LIB(pthread, pthread_create)
62 AC_CHECK_LIB(pthreads, pthread_create)
64 AC_SEARCH_LIBS(gethostbyname, nsl)
65 AC_SEARCH_LIBS(connect, socket)
67 dnl Checks for header files.
69 dnl AC_HEADER_SYS_WAIT
70 AC_CHECK_HEADERS(fcntl.h limits.h sys/time.h unistd.h)
72 dnl Checks for typedefs, structures, and compiler characteristics.
78 dnl Checks for library functions.
81 dnl AC_CHECK_FUNCS(strerror)
82 AC_REPLACE_FUNCS(snprintf)
84 dnl Checks for the libical calendaring library.
85 if test "x$with_libical" != xno ; then
86 AC_CHECK_HEADERS(ical.h,
87 [AC_CHECK_LIB(ical, icalcomponent_new,
92 if test "x$ok_libical" = xyes ; then
100 sscanf(ICAL_VERSION, "%f", &v);
101 printf("libical version: %0.2f\n", v);
105 printf("This version is ok.\n");
106 printf("WebCit will be built with calendar support.\n");
109 printf("libical 0.24 or newer is required.\n");
110 printf("WebCit will be built without calendar support.\n");
116 AC_DEFINE(HAVE_LIBICAL)
121 dnl Checks for the newt window library.
122 if test "x$with_newt" != xno ; then
123 AC_CHECK_HEADERS(newt.h,
124 [AC_CHECK_LIB(newt, newtInit,
129 if test "x$ok_newt" = xyes ; then
130 SETUP_LIBS="-lnewt $SETUP_LIBS"
134 # The big search for OpenSSL
135 if test "$with_ssl" != "no"; then
137 saved_LDFLAGS="$LDFLAGS"
138 saved_CFLAGS="$CFLAGS"
139 if test "x$prefix" != "xNONE"; then
140 tryssldir="$tryssldir $prefix"
142 AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
143 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
144 CFLAGS="$saved_CFLAGS"
145 LDFLAGS="$saved_LDFLAGS"
146 LIBS="$saved_LIBS -lssl -lcrypto"
148 # Skip directories if they don't exist
149 if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
152 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
153 # Try to use $ssldir/lib if it exists, otherwise
155 if test -d "$ssldir/lib" ; then
156 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
157 if test ! -z "$need_dash_r" ; then
158 LDFLAGS="-R$ssldir/lib $LDFLAGS"
161 LDFLAGS="-L$ssldir $saved_LDFLAGS"
162 if test ! -z "$need_dash_r" ; then
163 LDFLAGS="-R$ssldir $LDFLAGS"
166 # Try to use $ssldir/include if it exists, otherwise
168 if test -d "$ssldir/include" ; then
169 CFLAGS="-I$ssldir/include $saved_CFLAGS"
171 CFLAGS="-I$ssldir $saved_CFLAGS"
175 # Basic test to check for compatible version and correct linking
176 # *does not* test for RSA - that comes later.
180 #include <openssl/rand.h>
184 memset(a, 0, sizeof(a));
185 RAND_add(a, sizeof(a), sizeof(a));
186 return(RAND_status() <= 0);
195 if test ! -z "$found_crypto" ; then
200 if test -z "$ssldir" ; then
204 if test ! -z "$found_crypto" ; then
205 ac_cv_openssldir=$ssldir
207 ac_cv_openssldir="no"
211 LDFLAGS="$saved_LDFLAGS"
212 CFLAGS="$saved_CFLAGS"
214 if test "x$ac_cv_openssldir" != "xno" ; then
215 AC_DEFINE(HAVE_OPENSSL)
216 LIBS="-lssl -lcrypto $LIBS"
217 dnl Need to recover ssldir - test above runs in subshell
218 ssldir=$ac_cv_openssldir
219 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
220 # Try to use $ssldir/lib if it exists, otherwise
222 if test -d "$ssldir/lib" ; then
223 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
224 if test ! -z "$need_dash_r" ; then
225 LDFLAGS="-R$ssldir/lib $LDFLAGS"
228 LDFLAGS="-L$ssldir $saved_LDFLAGS"
229 if test ! -z "$need_dash_r" ; then
230 LDFLAGS="-R$ssldir $LDFLAGS"
233 # Try to use $ssldir/include if it exists, otherwise
235 if test -d "$ssldir/include" ; then
236 CFLAGS="-I$ssldir/include $saved_CFLAGS"
238 CFLAGS="-I$ssldir $saved_CFLAGS"