* Unfinished code is now disabled.
[citadel.git] / webcit / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2 dnl $Id$
3 AC_INIT([WebCit], [7.24], [http://www.citadel.org/])
4
5 AC_SUBST(PROG_SUBDIRS)
6 AC_DEFINE(PROG_SUBDIRS, [], [Program dirs])
7 AC_CANONICAL_HOST
8 AC_PROG_INSTALL
9 missing_dir=`cd $ac_aux_dir && pwd`
10 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
11 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
12
13 dnl Make sure we see all GNU and Solaris extensions.
14 AC_GNU_SOURCE
15
16 AC_CHECK_PROG(SED, sed, sed, no)
17 AC_PREFIX_DEFAULT(/usr/local/webcit)
18 if test "$prefix" = NONE; then
19         AC_DEFINE_UNQUOTED(WEBCITDIR, "$ac_default_prefix", [define this to the Citadel home directory])
20         ssl_dir="$ac_default_prefix/keys"
21 else
22         AC_DEFINE_UNQUOTED(WEBCITDIR, "$prefix", [define this to the Citadel home directory])
23         ssl_dir="$prefix/keys"
24 fi
25
26 AC_ARG_WITH(with_libical, [  --with-libical          use libical calendaring library])
27 AC_ARG_WITH(with_zlib,    [  --with-zlib             use zlib compression if present])
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 dnl Set some system-specific variables which are OK to set before compiler
37 dnl checks:
38 PTHREAD_DEFS=-D_REENTRANT
39 case "$host" in
40         dnl Tru64 Unix requires we use -pthread instead of linking the threads
41         dnl libraries directly, and we can't build threaded programs with gcc
42         dnl due to header file problems.
43         alpha*-dec-osf*)
44                 test -z "$CC" && CC=cc
45                 LIBS=-pthread
46         ;;
47         dnl FreeBSD is similar:
48         *-*-freebsd*)
49                 LIBS=-pthread
50                 PTHREAD_DEFS=-D_THREAD_SAFE
51         ;;
52         *-*-solaris*)
53                 PTHREAD_DEFS='-D_REENTRANT -D_PTHREADS'
54         ;;
55 esac
56 AC_SUBST(PTHREAD_DEFS)
57
58 dnl Checks for programs.
59 AC_PROG_CC
60
61 dnl Configure compiler flags for GCC
62 if test "$GCC" = yes; then
63         case "$host" in
64                 *-*-solaris*)
65                         CFLAGS="$CFLAGS -Wall -Wno-char-subscripts"
66                 ;;
67                 *)
68                         CFLAGS="$CFLAGS -Wall"
69                 ;;
70         esac
71 fi
72
73 # missing_dir=`cd $ac_aux_dir && pwd`
74 # AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
75
76 dnl Checks for libraries.
77 if test "$LIBS" != -pthread; then
78         AC_CHECK_LIB(pthread, pthread_create)
79         AC_CHECK_LIB(pthreads, pthread_create)
80 fi
81 AC_SEARCH_LIBS(gethostbyname, nsl)
82 AC_SEARCH_LIBS(connect, socket)
83
84 dnl Checks for header files.
85 AC_HEADER_STDC
86 dnl AC_HEADER_SYS_WAIT
87 AC_CHECK_HEADERS(fcntl.h limits.h sys/time.h unistd.h)
88
89
90
91
92 dnl Checks for typedefs, structures, and compiler characteristics.
93 AC_C_CONST
94 AC_TYPE_OFF_T
95 AC_TYPE_SIZE_T
96 dnl AC_HEADER_TIME
97
98 dnl Checks for library functions.
99 AC_TYPE_SIGNAL
100 dnl AC_FUNC_VPRINTF
101 AC_REPLACE_FUNCS(snprintf)
102
103
104 dnl Check for libcitadel
105 AC_CHECK_HEADER(libcitadel.h,
106         [AC_CHECK_LIB(citadel, libcitadel_version_string,
107                 [
108                         LIBS="-lcitadel $LIBS"
109                 ],
110                 [
111                         AC_MSG_ERROR(libcitadel was not found or is not usable.  Please install libcitadel.)
112                 ]
113         ,
114         )],
115         [
116                 AC_MSG_ERROR(libcitadel.h was not found or is not usable.  Please install libcitadel.)
117         ]
118 )
119
120
121 dnl Check to see if libcitadel is new enough
122 AC_MSG_CHECKING(checking libcitadel version)
123 AC_TRY_RUN(
124         [
125 #include "webcit.h"
126 main() {
127         if (LIBCITADEL_VERSION_NUMBER >= LIBCITADEL_MIN) {
128                 return(0);
129         }
130         return(1);
131 }
132         ], 
133         AC_MSG_RESULT(ok),
134         AC_MSG_ERROR(libcitadel is too old.  Please upgrade it first.)
135 )
136
137
138
139 webcit_with_calendar_service=no
140 dnl Checks for the libical calendaring library.
141 if test "x$with_libical" != xno ; then
142         AC_CHECK_HEADERS(ical.h,
143                 [AC_CHECK_LIB(ical, icalcomponent_new,
144                         [ok_libical=yes],,
145         )])
146 fi
147
148 if test "x$ok_libical" = xyes ; then
149
150         AC_TRY_RUN(
151                 [
152 #include <ical.h>
153 main() {
154         int major, minor, v;
155         sscanf(ICAL_VERSION, "%d.%d", &major, &minor);
156         v = 100*major + minor;
157         printf("libical version: %i\n", v);
158         if (v >= 30) {
159                 printf("This version is ok.\n");
160                 return(0);
161         }
162         printf("libical 0.30 or newer required.\n");
163         printf("Citadel will be built without calendar support.\n");
164         return(1);
165 }
166                 ], 
167                 [
168                         LIBS="-lical $LIBS"
169                         AC_DEFINE(HAVE_LIBICAL,[],[whether we have libical available])
170                         webcit_with_calendar_service=yes
171                 ]
172         )
173 fi
174 ok_libical=$webcit_with_calendar_service
175
176
177 if test "$webcit_with_calendar_service" == "yes"; then
178                         AC_DEFINE(WEBCIT_WITH_CALENDAR_SERVICE,[],[whether we can do with calendar.])
179 fi
180
181 dnl Checks for the zlib compression library.
182 if test "x$with_zlib" != xno ; then
183         AC_CHECK_HEADERS(zlib.h,
184                 [AC_CHECK_LIB(z, zlibVersion,
185                         [ok_zlib=yes],,
186         )])
187 fi
188
189 if test "x$ok_zlib" = xyes ; then
190         LIBS="-lz $LIBS"
191         AC_DEFINE(HAVE_ZLIB,[],[whether we have zlib])
192 fi
193
194
195 # The big search for OpenSSL
196 if test "$with_ssl" != "no"; then
197         saved_LIBS="$LIBS"
198         saved_LDFLAGS="$LDFLAGS"
199         saved_CFLAGS="$CFLAGS"
200         if test "x$prefix" != "xNONE"; then
201                 tryssldir="$tryssldir $prefix"
202         fi
203         AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
204                 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
205                         CFLAGS="$saved_CFLAGS"
206                         LDFLAGS="$saved_LDFLAGS"
207                         LIBS="$saved_LIBS -lssl -lcrypto"
208         
209                         # Skip directories if they don't exist
210                         if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
211                                 continue;
212                         fi
213                         if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
214                                 # Try to use $ssldir/lib if it exists, otherwise
215                                 # $ssldir
216                                 if test -d "$ssldir/lib" ; then
217                                         LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
218                                         if test ! -z "$need_dash_r" ; then
219                                                 LDFLAGS="-R$ssldir/lib $LDFLAGS"
220                                         fi
221                                 else
222                                         LDFLAGS="-L$ssldir $saved_LDFLAGS"
223                                         if test ! -z "$need_dash_r" ; then
224                                                 LDFLAGS="-R$ssldir $LDFLAGS"
225                                         fi
226                                 fi
227                                 # Try to use $ssldir/include if it exists, otherwise
228                                 # $ssldir
229                                 if test -d "$ssldir/include" ; then
230                                         CFLAGS="-I$ssldir/include $saved_CFLAGS"
231                                 else
232                                         CFLAGS="-I$ssldir $saved_CFLAGS"
233                                 fi
234                         fi
235         
236                         # Basic test to check for compatible version and correct linking
237                         # *does not* test for RSA - that comes later.
238                         AC_TRY_RUN(
239                                 [
240         #include <string.h>
241         #include <openssl/rand.h>
242         int main(void)
243         {
244                 char a[2048];
245                 memset(a, 0, sizeof(a));
246                 RAND_add(a, sizeof(a), sizeof(a));
247                 return(RAND_status() <= 0);
248         }
249                                 ],
250                                 [
251                                         found_crypto=1
252                                         break;
253                                 ], []
254                         )
255         
256                         if test ! -z "$found_crypto" ; then
257                                 break;
258                         fi
259                 done
260         
261                 if test -z "$ssldir" ; then
262                         ssldir="(system)"
263                 fi
264         
265                 if test ! -z "$found_crypto" ; then
266                         ac_cv_openssldir=$ssldir
267                 else
268                         ac_cv_openssldir="no"
269                 fi
270         ])
271         LIBS="$saved_LIBS"
272         LDFLAGS="$saved_LDFLAGS"
273         CFLAGS="$saved_CFLAGS"
274         
275         if test "x$ac_cv_openssldir" != "xno" ; then
276                 AC_DEFINE(HAVE_OPENSSL,[],[whethe we have openssl])
277                 LIBS="-lssl -lcrypto $LIBS"
278                 dnl Need to recover ssldir - test above runs in subshell
279                 ssldir=$ac_cv_openssldir
280                 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
281                         # Try to use $ssldir/lib if it exists, otherwise
282                         # $ssldir
283                         if test -d "$ssldir/lib" ; then
284                                 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
285                                 if test ! -z "$need_dash_r" ; then
286                                         LDFLAGS="-R$ssldir/lib $LDFLAGS"
287                                 fi
288                         else
289                                 LDFLAGS="-L$ssldir $saved_LDFLAGS"
290                                 if test ! -z "$need_dash_r" ; then
291                                         LDFLAGS="-R$ssldir $LDFLAGS"
292                                 fi
293                         fi
294                         # Try to use $ssldir/include if it exists, otherwise
295                         # $ssldir
296                         if test -d "$ssldir/include" ; then
297                                 CFLAGS="-I$ssldir/include $saved_CFLAGS"
298                         else
299                                 CFLAGS="-I$ssldir $saved_CFLAGS"
300                         fi
301                 fi
302         fi
303 fi
304 dnl Checks for the SSLdir
305 dnl this is a bit different than the rest, 
306 dnl because of the citadel used to have a keys/ subdir.
307 AC_ARG_WITH(ssldir, 
308                     [  --with-ssldir          directory to store the ssl certificates under],
309                         [ if test "x$withval" != "xno" ; then
310                                               
311                                                   ssl_dir="$withval"
312                           fi
313                         AC_SUBST(MAKE_SSL_DIR)
314                         ]
315 )
316 AC_DEFINE_UNQUOTED(SSL_DIR, "$ssl_dir", [were should we put our keys?])
317
318 dnl Here is the check for a usable iconv
319
320 AC_ARG_ENABLE(iconv,
321         [  --disable-iconv         do not use iconv charset conversion],
322         ok_iconv=no, ok_iconv=yes)
323
324 if test "$ok_nls" != "no"; then
325         AC_MSG_RESULT(Checking to see if your system supports iconv...)
326         AC_TRY_RUN([
327                 #include <iconv.h>
328                 main() {
329                         iconv_t ic = (iconv_t)(-1) ;
330                         ic = iconv_open("UTF-8", "us-ascii");
331                         iconv_close(ic);
332                         exit(0);
333                 }
334         ],
335                 ok_iconv=yes,
336                 ok_iconv=no
337         )
338 fi
339
340 if test "$ok_iconv" = "no"; then
341         LD_FLAGS_BEFORE=$LDFLAGS
342         LDFLAGS="$LDFLAGS -liconv"
343                 AC_TRY_RUN([
344                         #include <iconv.h>
345                         main() {
346                                iconv_t ic = (iconv_t)(-1) ;
347                                ic = iconv_open("UTF-8", "us-ascii");
348                                iconv_close(ic);
349                                exit(0);
350                         }
351                         ],
352                         ok_iconv=yes,
353                         ok_iconv=no
354                 )
355                 if test "$ok_iconv" != "no"; then
356                    LDFLAGS=$LD_FLAGS_BEFORE 
357                    LIBS="$LIBS -liconv"
358                 fi
359 fi
360
361 if test "$ok_iconv" != "no"; then
362         AC_MSG_RESULT(WebCit will be built with character set conversion.)
363         AC_DEFINE(HAVE_ICONV,[],[whether we have iconv for charset conversion])
364 else
365         AC_MSG_RESULT(WebCit will be built without character set conversion.)
366 fi
367
368
369
370 dnl Here is the check for libintl etc.
371
372 AC_ARG_ENABLE(nls,
373         [  --disable-nls           do not use Native Language Support],
374         ok_nls=no, ok_nls=yes)
375
376 if test "$ok_nls" != "no"; then
377         AC_MSG_RESULT(Checking for per-thread NLS support...)
378         AC_TRY_RUN([
379                 #define _GNU_SOURCE
380                 #include <libintl.h>
381                 #include <locale.h>
382                 #include <time.h>
383                 main() {
384                         char *foo = NULL;
385                         char baz[32];
386                         struct tm *tm;
387                         uselocale(LC_GLOBAL_LOCALE);
388                         foo = gettext("bar");
389                         if (0) {
390                                 strftime_l(baz, sizeof baz, "%c", tm, LC_GLOBAL_LOCALE);
391                         }
392                         exit(0);
393                 }
394         ],
395                 ok_uselocale=yes,
396                 ok_uselocale=no
397         )
398         ok_nls=$ok_uselocale
399 fi
400
401 if test "$ok_nls" != "no"; then
402         AC_CHECK_PROG(ok_xgettext, xgettext, yes, no)
403         ok_nls=$ok_xgettext
404 fi
405
406 if test "$ok_nls" != "no"; then
407         AC_CHECK_PROG(ok_msgmerge, msgmerge, yes, no)
408         ok_nls=$ok_msgmerge
409 fi
410
411 if test "$ok_nls" != "no"; then
412         AC_CHECK_PROG(ok_msgfmt, msgfmt, yes, no)
413         ok_nls=$ok_msgfmt
414 fi
415
416 if test "$ok_nls" != "no"; then
417         AC_MSG_RESULT(WebCit will be built with national language support.)
418         AC_DEFINE(ENABLE_NLS, [], [whether we have NLS support])
419         PROG_SUBDIRS="$PROG_SUBDIRS po"
420 else
421         AC_MSG_RESULT(WebCit will be built without national language support.)
422 fi
423
424 AC_SUBST(SETUP_LIBS)
425
426 dnl disable backtrace if we don't want it.
427 AC_ARG_WITH(gprof, 
428                     [  --with-gprof          enable profiling],
429                         [ if test "x$withval" != "xno" ; then
430                              CFLAGS="$CFLAGS  -pg "
431                              LDFLAGS="$LDFLAGS  -pg "
432                           fi
433                         ]
434 )
435
436 dnl disable backtrace if we don't want it.
437 AC_ARG_WITH(backtrace, 
438                     [  --with-backtrace          enable backtrace dumps in the syslog],
439                         [ if test "x$withval" != "xno" ; then
440                              CFLAGS="$CFLAGS  -rdynamic "
441                              LDFLAGS="$LDFLAGS  -rdynamic "
442                              AC_CHECK_FUNCS(backtrace)
443                           fi
444                         ]
445 )
446
447 if test "$prefix" = NONE; then
448         datadir=$ac_default_prefix
449         localedir=$ac_default_prefix
450         wwwdir=$ac_default_prefix
451         rundir=$ac_default_prefix
452         editordir=$ac_default_prefix/tiny_mce
453 else
454         localedir=$prefix
455         wwwdir=$prefix
456         datadir=$prefix
457         rundir=$prefix
458         editordir=$prefix/tiny_mce
459 fi
460
461 dnl where to put the locale files
462 AC_ARG_WITH(localedir, 
463                     [  --with-localedir          directory to put the locale files to],
464                         [ if test "x$withval" != "xno" ; then
465                             localedir=$withval
466                           fi
467                         ]
468 )
469 AC_DEFINE_UNQUOTED(LOCALEDIR, "$localedir",[where to find our pot files])
470 LOCALEDIR=$localedir
471 AC_SUBST(LOCALEDIR)
472
473 dnl Checks where to put our templates
474 AC_ARG_WITH(wwwdir, 
475                     [  --with-wwwdir             directory to put our templates],
476                         [ if test "x$withval" != "xno" ; then
477                                 wwwdir=$withval
478                           fi
479                         ]
480 )
481 AC_DEFINE_UNQUOTED(WWWDIR, "$wwwdir", [where to find our templates and pics])
482 WWWDIR=$wwwdir
483 AC_SUBST(WWWDIR)
484
485
486 dnl Checks for the run-dir for the sockets
487 AC_ARG_WITH(rundir, 
488                         [  --with-rundir           directory to place runtime files (UDS) to?],
489                         [ if test "x$withval" != "xno" ; then
490                                             AC_DEFINE(HAVE_RUN_DIR, [], [should we put our non volatile files elsewhere?])
491                                                 
492                                                 rundir=$withval
493                                                 AC_SUBST(MAKE_RUN_DIR)
494                           fi
495                         ]
496 )
497 AC_DEFINE_UNQUOTED(RUNDIR, "$rundir", [define, where the config should go in unix style])
498
499 dnl Checks for the Datadir
500 AC_ARG_WITH(datadir, 
501                     [  --with-datadir          directory to store the databases under],
502                         [ if test "x$withval" != "xno" ; then
503                                               datadir=$withval
504                           fi
505                         ]
506 )
507 AC_DEFINE_UNQUOTED(DATADIR, "$datadir",[define, if the user suplied a data-directory to use.])
508
509 dnl Checks where to put our editor
510 AC_ARG_WITH(editordir, 
511                     [  --with-editordir             directory to put our editor],
512                         [ if test "x$withval" != "xno" ; then
513                                 editordir=$withval
514                           fi
515                         ]
516 )
517 AC_DEFINE_UNQUOTED(EDITORDIR, "$editordir", [where to find our mail editor])
518
519 AC_CONFIG_HEADER(sysdep.h)
520 AC_OUTPUT(Makefile po/Makefile )
521
522 echo ------------------------------------------------------------------------
523 echo 'zlib compression:                ' $ok_zlib
524 echo 'Calendar support:                ' $ok_libical
525 echo 'Character set conversion support:' $ok_iconv
526 echo 'National language support:       ' $ok_nls
527 echo