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