]> code.citadel.org Git - citadel.git/blob - webcit/configure.in
* configure.in: fix libical version detection
[citadel.git] / webcit / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 dnl $Id$
3 AC_INIT(webserver.c)
4
5 AC_CANONICAL_HOST
6 AC_PROG_INSTALL
7 AC_PREFIX_DEFAULT(/usr/local/webcit)
8
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])
12 AC_ARG_WITH(ssl,
13         [  --with-ssl=PATH     Specify path to OpenSSL installation ],
14         [
15                 if test "x$withval" != "xno" ; then
16                         tryssldir=$withval
17                 fi
18         ]
19 )
20 dnl Set some system-specific variables which are OK to set before compiler
21 dnl checks:
22 PTHREAD_DEFS=-D_REENTRANT
23 case "$host" in
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.
27         alpha*-dec-osf*)
28                 test -z "$CC" && CC=cc
29                 LIBS=-pthread
30         ;;
31         dnl FreeBSD is similar:
32         *-*-freebsd*)
33                 LIBS=-pthread
34                 PTHREAD_DEFS=-D_THREAD_SAFE
35         ;;
36         *-*-solaris*)
37                 PTHREAD_DEFS='-D_REENTRANT -D_PTHREADS'
38         ;;
39 esac
40 AC_SUBST(PTHREAD_DEFS)
41
42 dnl Checks for programs.
43 AC_PROG_CC
44
45 dnl Configure compiler flags for GCC
46 if test "$GCC" = yes; then
47         case "$host" in
48                 *-*-solaris*)
49                         CFLAGS="$CFLAGS -Wall -Wno-char-subscripts"
50                 ;;
51                 *)
52                         CFLAGS="$CFLAGS -Wall"
53                 ;;
54         esac
55 fi
56
57 missing_dir=`cd $ac_aux_dir && pwd`
58 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
59
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)
64 fi
65 AC_SEARCH_LIBS(gethostbyname, nsl)
66 AC_SEARCH_LIBS(connect, socket)
67
68 dnl Checks for header files.
69 AC_HEADER_STDC
70 dnl AC_HEADER_SYS_WAIT
71 AC_CHECK_HEADERS(fcntl.h limits.h sys/time.h unistd.h)
72
73 dnl Checks for typedefs, structures, and compiler characteristics.
74 AC_C_CONST
75 AC_TYPE_OFF_T
76 AC_TYPE_SIZE_T
77 dnl AC_HEADER_TIME
78
79 dnl Checks for library functions.
80 AC_TYPE_SIGNAL
81 dnl AC_FUNC_VPRINTF
82 dnl AC_CHECK_FUNCS(strerror)
83 AC_REPLACE_FUNCS(snprintf)
84
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,
89                         [ok_libical=yes],,
90         )])
91 fi
92
93 if test "x$ok_libical" = xyes ; then
94
95         AC_TRY_RUN(
96                 [
97 #include <ical.h>
98 main() {
99         int major, minor, v;
100         sscanf(ICAL_VERSION, "%d.%d", &major, &minor);
101         v = 100*major + minor;
102         printf("libical version: %i\n", v);
103         if (v >= 24) {
104                 printf("This version is ok.\n");
105                 return(0);
106         }
107         printf("libical 0.24 or newer required.\n");
108         printf("Citadel will be built without calendar support.\n");
109         return(1);
110 }
111                 ], 
112                 [
113                         LIBS="-lical $LIBS"
114                         AC_DEFINE(HAVE_LIBICAL)
115                 ]
116         )
117 fi
118
119
120
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,
125                         [ok_zlib=yes],,
126         )])
127 fi
128
129 if test "x$ok_zlib" = xyes ; then
130         LIBS="-lz $LIBS"
131         AC_DEFINE(HAVE_ZLIB)
132 fi
133
134
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,
139                         [ok_newt=yes],,
140         )])
141 fi
142
143 if test "x$ok_newt" = xyes ; then
144         SETUP_LIBS="-lnewt $SETUP_LIBS"
145         AC_DEFINE(HAVE_NEWT)
146 fi
147
148 # The big search for OpenSSL
149 if test "$with_ssl" != "no"; then
150         saved_LIBS="$LIBS"
151         saved_LDFLAGS="$LDFLAGS"
152         saved_CFLAGS="$CFLAGS"
153         if test "x$prefix" != "xNONE"; then
154                 tryssldir="$tryssldir $prefix"
155         fi
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"
161         
162                         # Skip directories if they don't exist
163                         if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
164                                 continue;
165                         fi
166                         if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
167                                 # Try to use $ssldir/lib if it exists, otherwise
168                                 # $ssldir
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"
173                                         fi
174                                 else
175                                         LDFLAGS="-L$ssldir $saved_LDFLAGS"
176                                         if test ! -z "$need_dash_r" ; then
177                                                 LDFLAGS="-R$ssldir $LDFLAGS"
178                                         fi
179                                 fi
180                                 # Try to use $ssldir/include if it exists, otherwise
181                                 # $ssldir
182                                 if test -d "$ssldir/include" ; then
183                                         CFLAGS="-I$ssldir/include $saved_CFLAGS"
184                                 else
185                                         CFLAGS="-I$ssldir $saved_CFLAGS"
186                                 fi
187                         fi
188         
189                         # Basic test to check for compatible version and correct linking
190                         # *does not* test for RSA - that comes later.
191                         AC_TRY_RUN(
192                                 [
193         #include <string.h>
194         #include <openssl/rand.h>
195         int main(void)
196         {
197                 char a[2048];
198                 memset(a, 0, sizeof(a));
199                 RAND_add(a, sizeof(a), sizeof(a));
200                 return(RAND_status() <= 0);
201         }
202                                 ],
203                                 [
204                                         found_crypto=1
205                                         break;
206                                 ], []
207                         )
208         
209                         if test ! -z "$found_crypto" ; then
210                                 break;
211                         fi
212                 done
213         
214                 if test -z "$ssldir" ; then
215                         ssldir="(system)"
216                 fi
217         
218                 if test ! -z "$found_crypto" ; then
219                         ac_cv_openssldir=$ssldir
220                 else
221                         ac_cv_openssldir="no"
222                 fi
223         ])
224         LIBS="$saved_LIBS"
225         LDFLAGS="$saved_LDFLAGS"
226         CFLAGS="$saved_CFLAGS"
227         
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
235                         # $ssldir
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"
240                                 fi
241                         else
242                                 LDFLAGS="-L$ssldir $saved_LDFLAGS"
243                                 if test ! -z "$need_dash_r" ; then
244                                         LDFLAGS="-R$ssldir $LDFLAGS"
245                                 fi
246                         fi
247                         # Try to use $ssldir/include if it exists, otherwise
248                         # $ssldir
249                         if test -d "$ssldir/include" ; then
250                                 CFLAGS="-I$ssldir/include $saved_CFLAGS"
251                         else
252                                 CFLAGS="-I$ssldir $saved_CFLAGS"
253                         fi
254                 fi
255         fi
256 fi
257
258
259
260 AC_SUBST(SETUP_LIBS)
261
262 AC_OUTPUT(Makefile)
263