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