src/crypto.c: possible fix for memory leak related
[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([webcit],[6.80],[uncensored.citadel.org])
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_CHECK_LIB(iconv, libiconv, [LIBS="$LIBS -liconv"])   
99 AC_SEARCH_LIBS(gethostbyname, nsl)
100 AC_SEARCH_LIBS(connect, socket)
101
102 dnl Checks for header files.
103 AC_HEADER_STDC
104 dnl AC_HEADER_SYS_WAIT
105 AC_CHECK_HEADERS(fcntl.h limits.h sys/time.h unistd.h)
106
107
108
109
110 dnl Checks for typedefs, structures, and compiler characteristics.
111 AC_C_CONST
112 AC_TYPE_OFF_T
113 AC_TYPE_SIZE_T
114 dnl AC_HEADER_TIME
115
116 dnl Checks for library functions.
117 AC_TYPE_SIGNAL
118 dnl AC_FUNC_VPRINTF
119 AC_CHECK_FUNCS(backtrace)
120 AC_REPLACE_FUNCS(snprintf)
121
122 dnl Checks for the libical calendaring library.
123 AC_DEFINE([HAVE_LIBICAL], 
124           [--with-libical          use libical calendaring library],
125                   ok_libical=no, ok_libical=yes)
126
127 if test "x$with_libical" != xno ; then
128                   AC_CHECK_HEADERS(ical.h,
129                                      [AC_CHECK_LIB(ical, icalcomponent_new,
130                                    [ok_libical=yes],,)])
131 fi
132
133 if test "x$ok_libical" = xyes ; then
134
135         AC_TRY_RUN(
136                 [
137 #include <ical.h>
138 main() {
139         int major, minor, v;
140         sscanf(ICAL_VERSION, "%d.%d", &major, &minor);
141         v = 100*major + minor;
142         printf("libical version: %i\n", v);
143         if (v >= 24) {
144                 printf("This version is ok.\n");
145                 return(0);
146         }
147         printf("libical 0.24 or newer required.\n");
148         printf("Citadel will be built without calendar support.\n");
149         return(1);
150 }
151                 ], 
152                 [
153                         LIBS="$LIBS -lical"
154                         AC_DEFINE(HAVE_LIBICAL)
155                 ]
156         )
157 fi
158
159
160
161 dnl Checks for the zlib compression library.
162 AC_DEFINE([with_zlib],
163                   [  --with-zlib             use zlib compression if present],
164                   [ok_zlib=no], 
165                   [AC_CHECK_HEADERS(zlib.h,
166                                                         [AC_CHECK_LIB(z, zlibVersion,
167                                                         [ok_zlib=yes],,
168                                                         )])
169                 ])
170
171 if test "x$ok_zlib" = xyes ; then
172         LIBS="$LIBS -lz "
173 fi
174
175 dnl Checks for the newt window library.
176 AC_ARG_WITH([ok_newt],    [  --with-newt             use newt window library],ok_newt=no, [ AC_CHECK_HEADERS(newt.h,
177                                     [AC_CHECK_LIB(newt, newtInit,
178                                                       [ok_newt=yes],[ok_newt=no],
179                                               )
180                                                         ])
181                                   ]
182 )
183 if test "x$ok_newt" = xyes ; then
184         SETUP_LIBS="-lnewt $SETUP_LIBS"
185 fi
186
187 # The big search for OpenSSL
188 if test "$with_ssl" != "no"; then
189         saved_LIBS="$LIBS"
190         saved_LDFLAGS="$LDFLAGS"
191         saved_CFLAGS="$CFLAGS"
192         if test "x$prefix" != "xNONE"; then
193                 tryssldir="$tryssldir $prefix"
194         fi
195         AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
196                 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
197                         CFLAGS="$saved_CFLAGS"
198                         LDFLAGS="$saved_LDFLAGS"
199                         LIBS="$saved_LIBS -lssl -lcrypto"
200         
201                         # Skip directories if they don't exist
202                         if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
203                                 continue;
204                         fi
205                         if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
206                                 # Try to use $ssldir/lib if it exists, otherwise
207                                 # $ssldir
208                                 if test -d "$ssldir/lib" ; then
209                                         LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
210                                         if test ! -z "$need_dash_r" ; then
211                                                 LDFLAGS="-R$ssldir/lib $LDFLAGS"
212                                         fi
213                                 else
214                                         LDFLAGS="-L$ssldir $saved_LDFLAGS"
215                                         if test ! -z "$need_dash_r" ; then
216                                                 LDFLAGS="-R$ssldir $LDFLAGS"
217                                         fi
218                                 fi
219                                 # Try to use $ssldir/include if it exists, otherwise
220                                 # $ssldir
221                                 if test -d "$ssldir/include" ; then
222                                         CFLAGS="-I$ssldir/include $saved_CFLAGS"
223                                 else
224                                         CFLAGS="-I$ssldir $saved_CFLAGS"
225                                 fi
226                         fi
227         
228                         # Basic test to check for compatible version and correct linking
229                         # *does not* test for RSA - that comes later.
230                         AC_TRY_RUN(
231                                 [
232         #include <string.h>
233         #include <openssl/rand.h>
234         int main(void)
235         {
236                 char a[2048];
237                 memset(a, 0, sizeof(a));
238                 RAND_add(a, sizeof(a), sizeof(a));
239                 return(RAND_status() <= 0);
240         }
241                                 ],
242                                 [
243                                         found_crypto=1
244                                         break;
245                                 ], []
246                         )
247         
248                         if test ! -z "$found_crypto" ; then
249                                 break;
250                         fi
251                 done
252         
253                 if test -z "$ssldir" ; then
254                         ssldir="(system)"
255                 fi
256         
257                 if test ! -z "$found_crypto" ; then
258                         ac_cv_openssldir=$ssldir
259                 else
260                         ac_cv_openssldir="no"
261                 fi
262         ])
263         LIBS="$saved_LIBS"
264         LDFLAGS="$saved_LDFLAGS"
265         CFLAGS="$saved_CFLAGS"
266         
267         if test "x$ac_cv_openssldir" != "xno" ; then
268                 AC_DEFINE(HAVE_OPENSSL)
269                 LIBS="-lssl -lcrypto $LIBS"
270                 dnl Need to recover ssldir - test above runs in subshell
271                 ssldir=$ac_cv_openssldir
272                 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
273                         # Try to use $ssldir/lib if it exists, otherwise
274                         # $ssldir
275                         if test -d "$ssldir/lib" ; then
276                                 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
277                                 if test ! -z "$need_dash_r" ; then
278                                         LDFLAGS="-R$ssldir/lib $LDFLAGS"
279                                 fi
280                         else
281                                 LDFLAGS="-L$ssldir $saved_LDFLAGS"
282                                 if test ! -z "$need_dash_r" ; then
283                                         LDFLAGS="-R$ssldir $LDFLAGS"
284                                 fi
285                         fi
286                         # Try to use $ssldir/include if it exists, otherwise
287                         # $ssldir
288                         if test -d "$ssldir/include" ; then
289                                 CFLAGS="-I$ssldir/include $saved_CFLAGS"
290                         else
291                                 CFLAGS="-I$ssldir $saved_CFLAGS"
292                         fi
293                 fi
294         fi
295 fi
296
297 dnl Here is the check for a usable iconv
298
299 AC_DEFINE([HAVE_ICONV],
300         [  --disable-iconv         do not use iconv charset conversion],
301         ok_iconv=no, ok_iconv=yes)
302
303 if test "$ok_nls" != "no"; then
304         AC_MSG_RESULT(Checking to see if your system supports iconv...)
305         AC_TRY_RUN([
306                 #include <iconv.h>
307                 main() {
308                         iconv_t ic = (iconv_t)(-1) ;
309                         ic = iconv_open("UTF-8", "us-ascii");
310                         iconv_close(ic);
311                         exit(0);
312                 }
313         ],
314                 ok_iconv=yes,
315                 ok_iconv=no
316         )
317 fi
318
319 if test "$ok_iconv" != "no"; then
320         AC_MSG_RESULT(WebCit will be built with character set conversion.)
321         AC_DEFINE(HAVE_ICONV)
322 else
323         AC_MSG_RESULT(WebCit will be built without character set conversion.)
324 fi
325
326 AC_DEFINE_UNQUOTED([PREFIX],["$prefix"],where should we make our root?)
327 dnl AC_SUBST(PREFIX)
328
329 dnl dnl Here is the check for libintl etc.
330 dnl 
331 dnl AC_DEFINE([ENABLE_NLS],
332 dnl     [  --disable-nls           do not use Native Language Support],
333 dnl     ok_nls=no, ok_nls=yes)
334 dnl 
335 dnl if test "$ok_nls" != "no"; then
336 dnl     AC_MSG_RESULT(Checking for per-thread NLS support...)
337 dnl     AC_TRY_RUN([
338 dnl                 #define _GNU_SOURCE
339 dnl                 #include <libintl.h>
340 dnl                 #include <locale.h>
341 dnl                 #include <time.h>
342 dnl                 main() {
343 dnl                         char *foo = NULL;
344 dnl                         char baz[32];
345 dnl                     struct tm *tm;
346 dnl                         uselocale(LC_GLOBAL_LOCALE);
347 dnl                         foo = gettext("bar");
348 dnl                     if (0) {
349 dnl                             strftime_l(baz, sizeof baz, "%c", tm, LC_GLOBAL_LOCALE);
350 dnl                     }
351 dnl                         exit(0);
352 dnl             }
353 dnl     ],
354 dnl             ok_uselocale=yes,
355 dnl             ok_uselocale=no
356 dnl     )
357 dnl     ok_nls=$ok_uselocale
358 dnl fi
359 dnl 
360 dnl if test "$ok_nls" != "no"; then
361 dnl     AC_CHECK_PROG(ok_xgettext, xgettext, yes, no)
362 dnl     ok_nls=$ok_xgettext
363 dnl fi
364 dnl 
365 dnl if test "$ok_nls" != "no"; then
366 dnl     AC_CHECK_PROG(ok_msgmerge, msgmerge, yes, no)
367 dnl     ok_nls=$ok_msgmerge
368 dnl fi
369 dnl 
370 dnl if test "$ok_nls" != "no"; then
371 dnl     AC_CHECK_PROG(ok_msgfmt, msgfmt, yes, no)
372 dnl     ok_nls=$ok_msgfmt
373 dnl fi
374 dnl 
375 dnl if test "$ok_nls" != "no"; then
376 dnl     AC_MSG_RESULT(WebCit will be built with national language support.)
377 dnl     AC_DEFINE(ENABLE_NLS)
378 dnl      CFLAGS="$CFLAGS -I\$(top_srcdir)/po"
379 dnl     PROG_SUBDIRS="$PROG_SUBDIRS po"
380 dnl     AC_CHECK_LIB(intl, gettext)
381 dnl else
382 dnl     AC_MSG_RESULT(WebCit will be built without national language support.)
383 dnl fi
384 dnl Checks for programs.
385 AM_GNU_GETTEXT_VERSION([0.14])
386
387 #AM_GNU_GETTEXT
388 # if we have intl/... 
389 IT_PROG_INTLTOOL
390 AC_TRY_COMPILE([#include <locale.h>],
391                         [ extern locale_t wc_locales[]],
392                         [
393                         _nls_avail=yes
394                         AM_GNU_GETTEXT([external],[need-ngettext])
395                         ],
396                         [_nls_avail=no])
397
398
399
400
401                         
402
403 dnl 
404 dnl 
405 dnl AC_TRY_RUN([
406 dnl #include <libintl.h>
407 dnl #include <locale.h>
408 dnl int main(void)
409 dnl {
410 dnl     extern locale_t wc_locales[];
411 dnl     return 1;
412 dnl }
413 dnl ],
414 dnl                             [
415 dnl                                     found_crypto=1
416 dnl                                     break;
417 dnl                             ], []
418 dnl                     )
419 dnl 
420
421
422
423
424 AC_SUBST(CFLAGS)
425 AC_SUBST(SETUP_LIBS)
426
427 AC_ARG_WITH(rundir, [  --with-rundir=DIR          where to find the citadel servers sockets (overridable by -h  at runtime.)],
428                                            [ rundir=$withval ],[ rundir=/usr/local/citadel ] )
429 AC_DEFINE_UNQUOTED([RUNDIR],["$rundir"],[where should we make look for citadel sockets?])
430
431
432 AC_ARG_WITH(staticdir, [  --with-staticdir=DIR          where to put datafiles],
433                                            [ staticdir=$withval ],[ staticdir=$prefix ] )
434 AC_SUBST(staticdir)
435
436 AC_ARG_WITH(staticrundir, [  --with-staticrundir=DIR          where to search datafiles at runtime],
437                                                   [ staticrundir=$withval ],[ staticrundir=$staticdir ] )
438
439 AC_DEFINE_UNQUOTED([DATADIR],["$staticrundir"],[where should we make our root?])
440
441
442 AC_ARG_WITH(editordir, [  --with-editordir=DIR          where to search the editor at runtime],
443                                                   [ editordir=$withval ],[ editordir=$staticrundir ] )
444 AC_SUBST(editordir)
445 AC_DEFINE_UNQUOTED([EDITORDIR],["$editordir"],[where find the editor (tiny_mce)?])
446
447
448
449 AC_OUTPUT(Makefile src/Makefile po/Makefile.in)
450
451
452 echo ------------------------------------------------------------------------
453 echo 'zlib compression:                ' $ok_zlib
454 echo 'Calendar support:                ' $ok_libical
455 echo 'Character set conversion support:' $ok_iconv
456 echo 'National language support:       ' $_nls_avail
457 echo