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