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