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