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