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