acabc4268274ea24112ea39644977f4ba6a7ff0d
[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
6 PACKAGE=webcit
7 VERSION=6.21
8 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
9 AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
10 AC_SUBST(PACKAGE)
11 AC_SUBST(VERSION)
12
13 AC_CANONICAL_HOST
14 AC_PROG_INSTALL
15 AC_PREFIX_DEFAULT(/usr/local/webcit)
16
17 AC_ARG_WITH(with_libical, [  --with-libical      use libical calendaring library])
18 AC_ARG_WITH(with_zlib,    [  --with-zlib         use zlib compression if present])
19 AC_ARG_WITH(with_newt,    [  --with-newt         use newt window library])
20 AC_ARG_WITH(ssl,
21         [  --with-ssl=PATH     Specify path to OpenSSL installation ],
22         [
23                 if test "x$withval" != "xno" ; then
24                         tryssldir=$withval
25                 fi
26         ]
27 )
28 dnl Set some system-specific variables which are OK to set before compiler
29 dnl checks:
30 PTHREAD_DEFS=-D_REENTRANT
31 case "$host" in
32         dnl Tru64 Unix requires we use -pthread instead of linking the threads
33         dnl libraries directly, and we can't build threaded programs with gcc
34         dnl due to header file problems.
35         alpha*-dec-osf*)
36                 test -z "$CC" && CC=cc
37                 LIBS=-pthread
38         ;;
39         dnl FreeBSD is similar:
40         *-*-freebsd*)
41                 LIBS=-pthread
42                 PTHREAD_DEFS=-D_THREAD_SAFE
43         ;;
44         *-*-solaris*)
45                 PTHREAD_DEFS='-D_REENTRANT -D_PTHREADS'
46         ;;
47 esac
48 AC_SUBST(PTHREAD_DEFS)
49
50 dnl Checks for programs.
51 AC_PROG_CC
52
53 dnl Configure compiler flags for GCC
54 if test "$GCC" = yes; then
55         case "$host" in
56                 *-*-solaris*)
57                         CFLAGS="$CFLAGS -Wall -Wno-char-subscripts"
58                 ;;
59                 *)
60                         CFLAGS="$CFLAGS -Wall"
61                 ;;
62         esac
63 fi
64
65 missing_dir=`cd $ac_aux_dir && pwd`
66 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
67
68 dnl Checks for libraries.
69 if test "$LIBS" != -pthread; then
70         AC_CHECK_LIB(pthread, pthread_create)
71         AC_CHECK_LIB(pthreads, pthread_create)
72 fi
73 AC_SEARCH_LIBS(gethostbyname, nsl)
74 AC_SEARCH_LIBS(connect, socket)
75
76 dnl Checks for header files.
77 AC_HEADER_STDC
78 dnl AC_HEADER_SYS_WAIT
79 AC_CHECK_HEADERS(fcntl.h limits.h sys/time.h unistd.h)
80
81 dnl Checks for typedefs, structures, and compiler characteristics.
82 AC_C_CONST
83 AC_TYPE_OFF_T
84 AC_TYPE_SIZE_T
85 dnl AC_HEADER_TIME
86
87 dnl Checks for library functions.
88 AC_TYPE_SIGNAL
89 dnl AC_FUNC_VPRINTF
90 dnl AC_CHECK_FUNCS(strerror)
91 AC_REPLACE_FUNCS(snprintf)
92
93 dnl Checks for the libical calendaring library.
94 if test "x$with_libical" != xno ; then
95         AC_CHECK_HEADERS(ical.h,
96                 [AC_CHECK_LIB(ical, icalcomponent_new,
97                         [ok_libical=yes],,
98         )])
99 fi
100
101 if test "x$ok_libical" = xyes ; then
102
103         AC_TRY_RUN(
104                 [
105 #include <ical.h>
106 main() {
107         int major, minor, v;
108         sscanf(ICAL_VERSION, "%d.%d", &major, &minor);
109         v = 100*major + minor;
110         printf("libical version: %i\n", v);
111         if (v >= 24) {
112                 printf("This version is ok.\n");
113                 return(0);
114         }
115         printf("libical 0.24 or newer required.\n");
116         printf("Citadel will be built without calendar support.\n");
117         return(1);
118 }
119                 ], 
120                 [
121                         LIBS="-lical $LIBS"
122                         AC_DEFINE(HAVE_LIBICAL)
123                 ]
124         )
125 fi
126
127
128
129 dnl Checks for the zlib compression library.
130 if test "x$with_zlib" != xno ; then
131         AC_CHECK_HEADERS(zlib.h,
132                 [AC_CHECK_LIB(z, zlibVersion,
133                         [ok_zlib=yes],,
134         )])
135 fi
136
137 if test "x$ok_zlib" = xyes ; then
138         LIBS="-lz $LIBS"
139         AC_DEFINE(HAVE_ZLIB)
140 fi
141
142 dnl Checks for the newt window library.
143 if test "x$with_newt" != xno ; then
144         AC_CHECK_HEADERS(newt.h,
145                 [AC_CHECK_LIB(newt, newtInit,
146                         [ok_newt=yes],,
147         )])
148 fi
149
150 if test "x$ok_newt" = xyes ; then
151         SETUP_LIBS="-lnewt $SETUP_LIBS"
152         AC_DEFINE(HAVE_NEWT)
153 fi
154
155 # The big search for OpenSSL
156 if test "$with_ssl" != "no"; then
157         saved_LIBS="$LIBS"
158         saved_LDFLAGS="$LDFLAGS"
159         saved_CFLAGS="$CFLAGS"
160         if test "x$prefix" != "xNONE"; then
161                 tryssldir="$tryssldir $prefix"
162         fi
163         AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
164                 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
165                         CFLAGS="$saved_CFLAGS"
166                         LDFLAGS="$saved_LDFLAGS"
167                         LIBS="$saved_LIBS -lssl -lcrypto"
168         
169                         # Skip directories if they don't exist
170                         if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
171                                 continue;
172                         fi
173                         if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
174                                 # Try to use $ssldir/lib if it exists, otherwise
175                                 # $ssldir
176                                 if test -d "$ssldir/lib" ; then
177                                         LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
178                                         if test ! -z "$need_dash_r" ; then
179                                                 LDFLAGS="-R$ssldir/lib $LDFLAGS"
180                                         fi
181                                 else
182                                         LDFLAGS="-L$ssldir $saved_LDFLAGS"
183                                         if test ! -z "$need_dash_r" ; then
184                                                 LDFLAGS="-R$ssldir $LDFLAGS"
185                                         fi
186                                 fi
187                                 # Try to use $ssldir/include if it exists, otherwise
188                                 # $ssldir
189                                 if test -d "$ssldir/include" ; then
190                                         CFLAGS="-I$ssldir/include $saved_CFLAGS"
191                                 else
192                                         CFLAGS="-I$ssldir $saved_CFLAGS"
193                                 fi
194                         fi
195         
196                         # Basic test to check for compatible version and correct linking
197                         # *does not* test for RSA - that comes later.
198                         AC_TRY_RUN(
199                                 [
200         #include <string.h>
201         #include <openssl/rand.h>
202         int main(void)
203         {
204                 char a[2048];
205                 memset(a, 0, sizeof(a));
206                 RAND_add(a, sizeof(a), sizeof(a));
207                 return(RAND_status() <= 0);
208         }
209                                 ],
210                                 [
211                                         found_crypto=1
212                                         break;
213                                 ], []
214                         )
215         
216                         if test ! -z "$found_crypto" ; then
217                                 break;
218                         fi
219                 done
220         
221                 if test -z "$ssldir" ; then
222                         ssldir="(system)"
223                 fi
224         
225                 if test ! -z "$found_crypto" ; then
226                         ac_cv_openssldir=$ssldir
227                 else
228                         ac_cv_openssldir="no"
229                 fi
230         ])
231         LIBS="$saved_LIBS"
232         LDFLAGS="$saved_LDFLAGS"
233         CFLAGS="$saved_CFLAGS"
234         
235         if test "x$ac_cv_openssldir" != "xno" ; then
236                 AC_DEFINE(HAVE_OPENSSL)
237                 LIBS="-lssl -lcrypto $LIBS"
238                 dnl Need to recover ssldir - test above runs in subshell
239                 ssldir=$ac_cv_openssldir
240                 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
241                         # Try to use $ssldir/lib if it exists, otherwise
242                         # $ssldir
243                         if test -d "$ssldir/lib" ; then
244                                 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
245                                 if test ! -z "$need_dash_r" ; then
246                                         LDFLAGS="-R$ssldir/lib $LDFLAGS"
247                                 fi
248                         else
249                                 LDFLAGS="-L$ssldir $saved_LDFLAGS"
250                                 if test ! -z "$need_dash_r" ; then
251                                         LDFLAGS="-R$ssldir $LDFLAGS"
252                                 fi
253                         fi
254                         # Try to use $ssldir/include if it exists, otherwise
255                         # $ssldir
256                         if test -d "$ssldir/include" ; then
257                                 CFLAGS="-I$ssldir/include $saved_CFLAGS"
258                         else
259                                 CFLAGS="-I$ssldir $saved_CFLAGS"
260                         fi
261                 fi
262         fi
263 fi
264
265 AM_GNU_GETTEXT
266
267 AC_SUBST(SETUP_LIBS)
268
269 AC_OUTPUT(Makefile intl/Makefile po/Makefile.in )
270