webcit_before_automake is now the trunk
[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.72
8 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
9 AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
10 AC_SUBST(PACKAGE)
11 AC_SUBST(VERSION)
12
13 AC_SUBST(PROG_SUBDIRS)
14 AC_CANONICAL_HOST
15 AC_PROG_INSTALL
16 AC_CHECK_PROG(AUTOCONF, autoconf)
17 AC_CHECK_PROG(SED, sed, sed, no)
18 AC_PREFIX_DEFAULT(/usr/local/webcit)
19
20 AC_ARG_WITH(with_libical, [  --with-libical          use libical calendaring library])
21 AC_ARG_WITH(with_zlib,    [  --with-zlib             use zlib compression if present])
22 AC_ARG_WITH(with_newt,    [  --with-newt             use newt window library])
23 AC_ARG_WITH(ssl,
24         [  --with-ssl=PATH         Specify path to OpenSSL installation ],
25         [
26                 if test "x$withval" != "xno" ; then
27                         tryssldir=$withval
28                 fi
29         ]
30 )
31 dnl Set some system-specific variables which are OK to set before compiler
32 dnl checks:
33 PTHREAD_DEFS=-D_REENTRANT
34 case "$host" in
35         dnl Tru64 Unix requires we use -pthread instead of linking the threads
36         dnl libraries directly, and we can't build threaded programs with gcc
37         dnl due to header file problems.
38         alpha*-dec-osf*)
39                 test -z "$CC" && CC=cc
40                 LIBS=-pthread
41         ;;
42         dnl FreeBSD is similar:
43         *-*-freebsd*)
44                 LIBS=-pthread
45                 PTHREAD_DEFS=-D_THREAD_SAFE
46         ;;
47         *-*-solaris*)
48                 PTHREAD_DEFS='-D_REENTRANT -D_PTHREADS'
49         ;;
50 esac
51 AC_SUBST(PTHREAD_DEFS)
52
53 dnl Checks for programs.
54 AC_PROG_CC
55
56 dnl Configure compiler flags for GCC
57 if test "$GCC" = yes; then
58         case "$host" in
59                 *-*-solaris*)
60                         CFLAGS="$CFLAGS -Wall -Wno-char-subscripts"
61                 ;;
62                 *)
63                         CFLAGS="$CFLAGS -Wall"
64                 ;;
65         esac
66 fi
67
68 # missing_dir=`cd $ac_aux_dir && pwd`
69 # AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
70
71 dnl Checks for libraries.
72 if test "$LIBS" != -pthread; then
73         AC_CHECK_LIB(pthread, pthread_create)
74         AC_CHECK_LIB(pthreads, pthread_create)
75 fi
76 AC_SEARCH_LIBS(gethostbyname, nsl)
77 AC_SEARCH_LIBS(connect, socket)
78
79 dnl Checks for header files.
80 AC_HEADER_STDC
81 dnl AC_HEADER_SYS_WAIT
82 AC_CHECK_HEADERS(fcntl.h limits.h sys/time.h unistd.h)
83
84
85
86
87 dnl Checks for typedefs, structures, and compiler characteristics.
88 AC_C_CONST
89 AC_TYPE_OFF_T
90 AC_TYPE_SIZE_T
91 dnl AC_HEADER_TIME
92
93 dnl Checks for library functions.
94 AC_TYPE_SIGNAL
95 dnl AC_FUNC_VPRINTF
96 dnl AC_CHECK_FUNCS(strerror)
97 AC_REPLACE_FUNCS(snprintf)
98
99 dnl Checks for the libical calendaring library.
100 if test "x$with_libical" != xno ; then
101         AC_CHECK_HEADERS(ical.h,
102                 [AC_CHECK_LIB(ical, icalcomponent_new,
103                         [ok_libical=yes],,
104         )])
105 fi
106
107 if test "x$ok_libical" = xyes ; then
108
109         AC_TRY_RUN(
110                 [
111 #include <ical.h>
112 main() {
113         int major, minor, v;
114         sscanf(ICAL_VERSION, "%d.%d", &major, &minor);
115         v = 100*major + minor;
116         printf("libical version: %i\n", v);
117         if (v >= 24) {
118                 printf("This version is ok.\n");
119                 return(0);
120         }
121         printf("libical 0.24 or newer required.\n");
122         printf("Citadel will be built without calendar support.\n");
123         return(1);
124 }
125                 ], 
126                 [
127                         LIBS="-lical $LIBS"
128                         AC_DEFINE(HAVE_LIBICAL)
129                 ]
130         )
131 fi
132
133
134
135 dnl Checks for the zlib compression library.
136 if test "x$with_zlib" != xno ; then
137         AC_CHECK_HEADERS(zlib.h,
138                 [AC_CHECK_LIB(z, zlibVersion,
139                         [ok_zlib=yes],,
140         )])
141 fi
142
143 if test "x$ok_zlib" = xyes ; then
144         LIBS="-lz $LIBS"
145         AC_DEFINE(HAVE_ZLIB)
146 fi
147
148 dnl Checks for the newt window library.
149 if test "x$with_newt" != xno ; then
150         AC_CHECK_HEADERS(newt.h,
151                 [AC_CHECK_LIB(newt, newtInit,
152                         [ok_newt=yes],,
153         )])
154 fi
155
156 if test "x$ok_newt" = xyes ; then
157         SETUP_LIBS="-lnewt $SETUP_LIBS"
158         AC_DEFINE(HAVE_NEWT)
159 fi
160
161 # The big search for OpenSSL
162 if test "$with_ssl" != "no"; then
163         saved_LIBS="$LIBS"
164         saved_LDFLAGS="$LDFLAGS"
165         saved_CFLAGS="$CFLAGS"
166         if test "x$prefix" != "xNONE"; then
167                 tryssldir="$tryssldir $prefix"
168         fi
169         AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
170                 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
171                         CFLAGS="$saved_CFLAGS"
172                         LDFLAGS="$saved_LDFLAGS"
173                         LIBS="$saved_LIBS -lssl -lcrypto"
174         
175                         # Skip directories if they don't exist
176                         if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
177                                 continue;
178                         fi
179                         if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
180                                 # Try to use $ssldir/lib if it exists, otherwise
181                                 # $ssldir
182                                 if test -d "$ssldir/lib" ; then
183                                         LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
184                                         if test ! -z "$need_dash_r" ; then
185                                                 LDFLAGS="-R$ssldir/lib $LDFLAGS"
186                                         fi
187                                 else
188                                         LDFLAGS="-L$ssldir $saved_LDFLAGS"
189                                         if test ! -z "$need_dash_r" ; then
190                                                 LDFLAGS="-R$ssldir $LDFLAGS"
191                                         fi
192                                 fi
193                                 # Try to use $ssldir/include if it exists, otherwise
194                                 # $ssldir
195                                 if test -d "$ssldir/include" ; then
196                                         CFLAGS="-I$ssldir/include $saved_CFLAGS"
197                                 else
198                                         CFLAGS="-I$ssldir $saved_CFLAGS"
199                                 fi
200                         fi
201         
202                         # Basic test to check for compatible version and correct linking
203                         # *does not* test for RSA - that comes later.
204                         AC_TRY_RUN(
205                                 [
206         #include <string.h>
207         #include <openssl/rand.h>
208         int main(void)
209         {
210                 char a[2048];
211                 memset(a, 0, sizeof(a));
212                 RAND_add(a, sizeof(a), sizeof(a));
213                 return(RAND_status() <= 0);
214         }
215                                 ],
216                                 [
217                                         found_crypto=1
218                                         break;
219                                 ], []
220                         )
221         
222                         if test ! -z "$found_crypto" ; then
223                                 break;
224                         fi
225                 done
226         
227                 if test -z "$ssldir" ; then
228                         ssldir="(system)"
229                 fi
230         
231                 if test ! -z "$found_crypto" ; then
232                         ac_cv_openssldir=$ssldir
233                 else
234                         ac_cv_openssldir="no"
235                 fi
236         ])
237         LIBS="$saved_LIBS"
238         LDFLAGS="$saved_LDFLAGS"
239         CFLAGS="$saved_CFLAGS"
240         
241         if test "x$ac_cv_openssldir" != "xno" ; then
242                 AC_DEFINE(HAVE_OPENSSL)
243                 LIBS="-lssl -lcrypto $LIBS"
244                 dnl Need to recover ssldir - test above runs in subshell
245                 ssldir=$ac_cv_openssldir
246                 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
247                         # Try to use $ssldir/lib if it exists, otherwise
248                         # $ssldir
249                         if test -d "$ssldir/lib" ; then
250                                 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
251                                 if test ! -z "$need_dash_r" ; then
252                                         LDFLAGS="-R$ssldir/lib $LDFLAGS"
253                                 fi
254                         else
255                                 LDFLAGS="-L$ssldir $saved_LDFLAGS"
256                                 if test ! -z "$need_dash_r" ; then
257                                         LDFLAGS="-R$ssldir $LDFLAGS"
258                                 fi
259                         fi
260                         # Try to use $ssldir/include if it exists, otherwise
261                         # $ssldir
262                         if test -d "$ssldir/include" ; then
263                                 CFLAGS="-I$ssldir/include $saved_CFLAGS"
264                         else
265                                 CFLAGS="-I$ssldir $saved_CFLAGS"
266                         fi
267                 fi
268         fi
269 fi
270
271 dnl Here is the check for a usable iconv
272
273 AC_ARG_ENABLE(iconv,
274         [  --disable-iconv         do not use iconv charset conversion],
275         ok_iconv=no, ok_iconv=yes)
276
277 if test "$ok_nls" != "no"; then
278         AC_MSG_RESULT(Checking to see if your system supports iconv...)
279         AC_TRY_RUN([
280                 #include <iconv.h>
281                 main() {
282                         iconv_t ic = (iconv_t)(-1) ;
283                         ic = iconv_open("UTF-8", "us-ascii");
284                         iconv_close(ic);
285                         exit(0);
286                 }
287         ],
288                 ok_iconv=yes,
289                 ok_iconv=no
290         )
291 fi
292
293 if test "$ok_iconv" != "no"; then
294         AC_MSG_RESULT(WebCit will be built with character set conversion.)
295         AC_DEFINE(HAVE_ICONV)
296 else
297         AC_MSG_RESULT(WebCit will be built without character set conversion.)
298 fi
299
300
301
302 dnl Here is the check for libintl etc.
303
304 AC_ARG_ENABLE(nls,
305         [  --disable-nls           do not use Native Language Support],
306         ok_nls=no, ok_nls=yes)
307
308 if test "$ok_nls" != "no"; then
309         AC_MSG_RESULT(Checking for per-thread NLS support...)
310         AC_TRY_RUN([
311                 #define _GNU_SOURCE
312                 #include <libintl.h>
313                 #include <locale.h>
314                 #include <time.h>
315                 main() {
316                         char *foo = NULL;
317                         char baz[32];
318                         struct tm *tm;
319                         uselocale(LC_GLOBAL_LOCALE);
320                         foo = gettext("bar");
321                         if (0) {
322                                 strftime_l(baz, sizeof baz, "%c", tm, LC_GLOBAL_LOCALE);
323                         }
324                         exit(0);
325                 }
326         ],
327                 ok_uselocale=yes,
328                 ok_uselocale=no
329         )
330         ok_nls=$ok_uselocale
331 fi
332
333 if test "$ok_nls" != "no"; then
334         AC_CHECK_PROG(ok_xgettext, xgettext, yes, no)
335         ok_nls=$ok_xgettext
336 fi
337
338 if test "$ok_nls" != "no"; then
339         AC_CHECK_PROG(ok_msgmerge, msgmerge, yes, no)
340         ok_nls=$ok_msgmerge
341 fi
342
343 if test "$ok_nls" != "no"; then
344         AC_CHECK_PROG(ok_msgfmt, msgfmt, yes, no)
345         ok_nls=$ok_msgfmt
346 fi
347
348 if test "$ok_nls" != "no"; then
349         AC_MSG_RESULT(WebCit will be built with national language support.)
350         AC_DEFINE(ENABLE_NLS)
351         PROG_SUBDIRS="$PROG_SUBDIRS po"
352 else
353         AC_MSG_RESULT(WebCit will be built without national language support.)
354 fi
355
356 AC_SUBST(SETUP_LIBS)
357
358 AC_OUTPUT(Makefile po/Makefile )
359
360 echo ------------------------------------------------------------------------
361 echo 'zlib compression:                ' $ok_zlib
362 echo 'Calendar support:                ' $ok_libical
363 echo 'Character set conversion support:' $ok_iconv
364 echo 'National language support:       ' $ok_nls
365 echo