]> code.citadel.org Git - citadel.git/blob - webcit/configure.in
* When the "begin_burst() / end_burst()" semantics are in use, perform
[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         float v;
100         int i;
101         sscanf(ICAL_VERSION, "%f", &v);
102         printf("libical version: %0.2f\n", v);
103         v = v * 100.0;
104         i = (int) v;
105         if (i >= 24) {
106                 printf("This version is ok.\n");
107                 printf("WebCit will be built with calendar support.\n");
108                 return(0);
109         }
110         printf("libical 0.24 or newer is required.\n");
111         printf("WebCit will be built without calendar support.\n");
112         return(1);
113 }
114                 ], 
115                 [
116                         LIBS="-lical $LIBS"
117                         AC_DEFINE(HAVE_LIBICAL)
118                 ]
119         )
120 fi
121
122
123
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,
128                         [ok_zlib=yes],,
129         )])
130 fi
131
132 if test "x$ok_zlib" = xyes ; then
133         LIBS="-lz $LIBS"
134         AC_DEFINE(HAVE_ZLIB)
135 fi
136
137
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,
142                         [ok_newt=yes],,
143         )])
144 fi
145
146 if test "x$ok_newt" = xyes ; then
147         SETUP_LIBS="-lnewt $SETUP_LIBS"
148         AC_DEFINE(HAVE_NEWT)
149 fi
150
151 # The big search for OpenSSL
152 if test "$with_ssl" != "no"; then
153         saved_LIBS="$LIBS"
154         saved_LDFLAGS="$LDFLAGS"
155         saved_CFLAGS="$CFLAGS"
156         if test "x$prefix" != "xNONE"; then
157                 tryssldir="$tryssldir $prefix"
158         fi
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"
164         
165                         # Skip directories if they don't exist
166                         if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
167                                 continue;
168                         fi
169                         if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
170                                 # Try to use $ssldir/lib if it exists, otherwise
171                                 # $ssldir
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"
176                                         fi
177                                 else
178                                         LDFLAGS="-L$ssldir $saved_LDFLAGS"
179                                         if test ! -z "$need_dash_r" ; then
180                                                 LDFLAGS="-R$ssldir $LDFLAGS"
181                                         fi
182                                 fi
183                                 # Try to use $ssldir/include if it exists, otherwise
184                                 # $ssldir
185                                 if test -d "$ssldir/include" ; then
186                                         CFLAGS="-I$ssldir/include $saved_CFLAGS"
187                                 else
188                                         CFLAGS="-I$ssldir $saved_CFLAGS"
189                                 fi
190                         fi
191         
192                         # Basic test to check for compatible version and correct linking
193                         # *does not* test for RSA - that comes later.
194                         AC_TRY_RUN(
195                                 [
196         #include <string.h>
197         #include <openssl/rand.h>
198         int main(void)
199         {
200                 char a[2048];
201                 memset(a, 0, sizeof(a));
202                 RAND_add(a, sizeof(a), sizeof(a));
203                 return(RAND_status() <= 0);
204         }
205                                 ],
206                                 [
207                                         found_crypto=1
208                                         break;
209                                 ], []
210                         )
211         
212                         if test ! -z "$found_crypto" ; then
213                                 break;
214                         fi
215                 done
216         
217                 if test -z "$ssldir" ; then
218                         ssldir="(system)"
219                 fi
220         
221                 if test ! -z "$found_crypto" ; then
222                         ac_cv_openssldir=$ssldir
223                 else
224                         ac_cv_openssldir="no"
225                 fi
226         ])
227         LIBS="$saved_LIBS"
228         LDFLAGS="$saved_LDFLAGS"
229         CFLAGS="$saved_CFLAGS"
230         
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
238                         # $ssldir
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"
243                                 fi
244                         else
245                                 LDFLAGS="-L$ssldir $saved_LDFLAGS"
246                                 if test ! -z "$need_dash_r" ; then
247                                         LDFLAGS="-R$ssldir $LDFLAGS"
248                                 fi
249                         fi
250                         # Try to use $ssldir/include if it exists, otherwise
251                         # $ssldir
252                         if test -d "$ssldir/include" ; then
253                                 CFLAGS="-I$ssldir/include $saved_CFLAGS"
254                         else
255                                 CFLAGS="-I$ssldir $saved_CFLAGS"
256                         fi
257                 fi
258         fi
259 fi
260
261
262
263 AC_SUBST(SETUP_LIBS)
264
265 AC_OUTPUT(Makefile)
266