[lua] make our modules be extensible (accept new values).
[apps/madmutt.git] / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2
3 dnl !!! WHEN ADDING NEW CONFIGURE TESTS, PLEASE ADD CODE TO MAIN.C !!!
4 dnl !!! TO DUMP THEIR RESULTS WHEN MUTT -V IS CALLED            !!!
5
6 AC_PREREQ([2.50])
7 AC_INIT([mutt.h])
8 AM_CONFIG_HEADER(config.h)
9 AM_INIT_AUTOMAKE(madmutt, `cat "$srcdir/VERSION.in"`)
10
11 AC_SUBST([CONFIGURE_DEPENDENCIES], ['$(top_srcdir)/VERSION.in'])
12
13 AC_GNU_SOURCE
14
15 ALL_LINGUAS="de ru it es uk fr pl nl cs id sk ko el zh_TW zh_CN pt_BR eo gl sv da lt tr ja hu et ca bg"
16
17 AC_CANONICAL_HOST
18
19 AC_PROG_CPP
20 AC_PROG_CC_C99
21 AC_ISC_POSIX
22 AC_HEADER_STDC
23
24 PKG_PROG_PKG_CONFIG
25 AC_PROG_MAKE_SET
26 AC_PROG_INSTALL
27 AC_PROG_RANLIB
28 AC_PROG_GPERF
29 AC_CHECK_TOOL(AR, ar, ar)
30
31 AC_SYS_LARGEFILE
32 AC_FUNC_FSEEKO
33 AC_CHECK_SIZEOF(off_t)
34
35 AH_TEMPLATE([sig_atomic_t],
36             [Define to 'int' if <signal.h> doesn't define.])
37 AH_TEMPLATE([HAVE_START_COLOR],
38             [Define if you have start_color, as a function or macro.])
39 AH_TEMPLATE([HAVE_TYPEAHEAD],
40             [Define if you have typeahead, as a function or macro.])
41 AH_TEMPLATE([HAVE_BKGDSET],
42             [Define if you have bkgdset, as a function or macro.])
43 AH_TEMPLATE([HAVE_CURS_SET],
44             [Define if you have curs_set, as a function or macro.])
45 AH_TEMPLATE([HAVE_META],
46             [Define if you have meta, as a function or macro.])
47 AH_TEMPLATE([HAVE_USE_DEFAULT_COLORS],
48             [Define if you have use_default_colors, as a function or macro.])
49 AH_TEMPLATE([HAVE_RESIZETERM],
50             [Define if you have resizeterm, as a function or macro.])
51 AH_TEMPLATE([SIG_ATOMIC_VOLATILE_T],
52             [Some systems declare sig_atomic_t as volatile, some others -- no.
53              This define will have value `sig_atomic_t' or
54              `volatile sig_atomic_t' accordingly.])
55 AH_TEMPLATE([ICONV_NONTRANS],
56             [Define as 1 if iconv() only converts exactly and we should treat
57              all return values other than (size_t)(-1) as equivalent.])
58
59 dnl ---------------- sendmail ----------------
60
61 ac_aux_path_sendmail=/usr/sbin:/usr/lib
62 AC_PATH_PROG(SENDMAIL, sendmail, /usr/sbin/sendmail, $PATH:$ac_aux_path_sendmail)
63 AC_DEFINE_UNQUOTED(SENDMAIL,"$ac_cv_path_SENDMAIL",[ Where to find sendmail on your system. ])
64
65 dnl ---------------- gpgme ----------------
66 PKG_CHECK_MODULES(LUA,lua5.1,[
67     CPPFLAGS="$CPPFLAGS $LUA_CFLAGS"
68     LDFLAGS="$LDFLAGS $LUA_LIBS"
69 ],[AC_MSG_ERROR([could not find lua5.1])])
70
71 dnl ---------------- gpgme ----------------
72
73 AC_ARG_ENABLE(gpgme, AC_HELP_STRING([--enable-gpgme], [Enable GPGME support]),[
74     if test x$enableval = xyes; then
75         AM_PATH_GPGME(,,[AC_MSG_ERROR(GPGME not found)])
76         MUTTLIBS="$MUTTLIBS $GPGME_LIBS"
77         AC_DEFINE(CRYPT_BACKEND_GPGME, 1, [Defined, if GPGME support is enabled])
78         AM_CONDITIONAL(BUILD_GPGME, true)
79     else
80         AM_CONDITIONAL(BUILD_GPGME, false)
81     fi
82 ])
83
84 AC_PATH_PROG(MIXMASTER, mixmaster, mixmaster)
85 AC_DEFINE_UNQUOTED(MIXMASTER,"$MIXMASTER",[Where to find mixmaster on your system.])
86
87 AC_ARG_WITH(slang, AC_HELP_STRING([--with-slang[=DIR]], [Use S-Lang instead of ncurses]),
88     [AC_CACHE_CHECK([if this is a BSD system], mutt_cv_bsdish,
89         [AC_TRY_RUN([#include <sys/param.h>
90
91 main ()
92 {
93 #ifdef BSD
94         exit (0);
95 #else
96         exit (1);
97 #endif
98 }],
99         mutt_cv_bsdish=yes,
100         mutt_cv_bsdish=no,
101         mutt_cv_bsdish=no)])
102
103         AC_MSG_CHECKING(for S-Lang)
104         if test $withval = yes; then
105             if test -d $srcdir/../slang; then
106                 mutt_cv_slang=$srcdir/../slang/src
107                 CFLAGS="$CFLAGS -I${mutt_cv_slang}"
108                 LDFLAGS="$LDFLAGS -L${mutt_cv_slang}/objs"
109             else
110                 if test -d ${prefix}/include/slang; then
111                     CFLAGS="$CFLAGS -I${prefix}/include/slang"
112                 elif test -d /usr/include/slang; then
113                     CFLAGS="$CFLAGS -I/usr/include/slang"
114                 fi
115                 mutt_cv_slang=yes
116             fi
117         else
118             dnl ---Check to see if $withval is a source directory
119             if test -f $withval/src/slang.h; then
120                 mutt_cv_slang=$withval/src
121                 CFLAGS="$CFLAGS -I${mutt_cv_slang}"
122                 LDFLAGS="$LDFLAGS -L${mutt_cv_slang}/objs"
123             else
124                 dnl ---Must be installed somewhere
125                 mutt_cv_slang=$withval
126                 if test -d $withval/include/slang; then
127                         CFLAGS="$CFLAGS -I${withval}/include/slang"
128                 elif test -d $withval/include; then
129                         CFLAGS="$CFLAGS -I${withval}/include"
130                 fi
131                 LDFLAGS="$LDFLAGS -L${withval}/lib"
132             fi
133         fi
134         AC_MSG_RESULT($mutt_cv_slang)
135         if test $mutt_cv_bsdish = yes; then
136             AC_CHECK_LIB(termlib, main)
137         fi
138         AC_DEFINE(USE_SLANG_CURSES,1, [ Define if you compile with SLang instead of curses/ncurses. ])
139
140         dnl --- now that we've found it, check the link
141
142         AC_CHECK_LIB(slang, SLtt_get_terminfo,
143             [MUTTLIBS="$MUTTLIBS -lslang -lm"],
144             [AC_MSG_ERROR(unable to compile.  check config.log)], -lm)
145     ],
146     [   mutt_cv_curses=/usr
147         AC_ARG_WITH(curses, AC_HELP_STRING([--with-curses=DIR], [Where ncurses is installed]), [
148             if test $withval != yes; then
149                 mutt_cv_curses=$withval
150             fi
151             if test x$mutt_cv_curses != x/usr; then
152                 LDFLAGS="-L${mutt_cv_curses}/lib $LDFLAGS"
153                 CPPFLAGS="$CPPFLAGS -I${mutt_cv_curses}/include"
154             fi
155         ])
156
157         AC_CHECK_FUNC(initscr,,[
158         cf_ncurses="ncurses"
159         for lib in ncursesw ncurses; do
160             AC_CHECK_LIB($lib, waddnwstr, [cf_ncurses="$lib"; break])
161         done
162         AC_CHECK_LIB($cf_ncurses, initscr,
163             [   MUTTLIBS="$MUTTLIBS -l$cf_ncurses"
164                 if test x$mutt_cv_curses = x/usr -a -d /usr/include/ncurses; then
165                     CPPFLAGS="$CPPFLAGS -I/usr/include/ncurses"
166                 fi
167
168                 if test "$cf_ncurses" = ncursesw; then
169                     AC_CHECK_HEADERS(ncurses/ncurses.h,[cf_cv_ncurses_header="ncurses/ncurses.h"])
170                     AC_CHECK_HEADERS(ncursesw/ncurses.h,[cf_cv_ncurses_header="ncursesw/ncurses.h"])
171                 else
172                     AC_CHECK_HEADERS(ncurses.h,[cf_cv_ncurses_header="ncurses.h"])
173                 fi
174             ],
175             [CF_CURSES_LIBS])
176         ])
177
178         old_LIBS="$LIBS"
179         LIBS="$LIBS $MUTTLIBS"
180         CF_CHECK_FUNCDECLS([#include <${cf_cv_ncurses_header-curses.h}>],
181                            [start_color typeahead bkgdset curs_set meta use_default_colors resizeterm])
182         if test "$ac_cv_func_decl_start_color" != yes; then
183             AC_MSG_ERROR([Your curses library does not supports color.])
184         fi
185         LIBS="$old_LIBS"
186     ])
187
188 AC_CHECK_HEADERS(stdarg.h sys/ioctl.h ioctl.h sysexits.h)
189 AC_CHECK_HEADERS(sys/time.h sys/resource.h)
190 AC_CHECK_HEADERS(unix.h)
191
192 AC_CHECK_FUNCS(setrlimit getsid isctype)
193
194 AC_TYPE_SIGNAL
195
196 AC_MSG_CHECKING(for sig_atomic_t in signal.h)
197 AC_EGREP_HEADER(sig_atomic_t,signal.h,
198     [   ac_cv_type_sig_atomic_t=yes;
199         AC_EGREP_HEADER(volatile.*sig_atomic_t,
200                         signal.h,
201                         [is_sig_atomic_t_volatile=yes; AC_MSG_RESULT([yes, volatile])],
202                         [is_sig_atomic_t_volatile=no;  AC_MSG_RESULT([yes, non volatile])])
203     ],
204     [   AC_MSG_RESULT(no)
205         AC_CHECK_TYPE(sig_atomic_t, int)
206         is_sig_atomic_t_volatile=no
207     ])
208 if test $is_sig_atomic_t_volatile = 'yes'
209 then
210     AC_DEFINE(SIG_ATOMIC_VOLATILE_T, sig_atomic_t)
211 else
212     AC_DEFINE(SIG_ATOMIC_VOLATILE_T, [volatile sig_atomic_t])
213 fi
214
215 AC_DECL_SYS_SIGLIST
216 AC_TYPE_PID_T
217
218 AC_CHECK_FUNC(getopt)
219 if test $ac_cv_func_getopt = yes; then
220     AC_CHECK_HEADERS(getopt.h)
221 fi
222
223 AC_CHECK_FUNC(regcomp)
224 if test $ac_cv_func_regcomp = yes; then
225    AC_CHECK_HEADERS(regex.h)
226 fi
227
228 AC_ARG_WITH(homespool,
229             AC_HELP_STRING([--with-homespool[=FILE]],
230                            [File in user's directory where new mail is spooled]),
231                            with_homespool=${withval})
232 if test x$with_homespool != x; then
233     if test $with_homespool = yes; then
234             with_homespool=mailbox
235     fi
236     AC_DEFINE_UNQUOTED(MAILPATH,"$with_homespool",[ Where new mail is spooled. ])
237     AC_DEFINE(HOMESPOOL,1,
238     [   Is mail spooled to the user's home directory?  If defined,
239         MAILPATH should be set to the filename of the spool mailbox
240         relative the the home directory.
241         use: configure --with-homespool=FILE
242     ])
243     mutt_cv_setgid=no
244 else
245     AC_ARG_WITH(mailpath, AC_HELP_STRING([--with-mailpath=DIR], [Directory where spool mailboxes are located]),
246         [mutt_cv_mailpath=$withval],
247         [ AC_CACHE_CHECK(where new mail is stored, mutt_cv_mailpath,
248             [mutt_cv_mailpath=no
249             if test -d /var/mail; then
250                 mutt_cv_mailpath=/var/mail
251             elif test -d /var/spool/mail; then
252                 mutt_cv_mailpath=/var/spool/mail
253             elif test -d /usr/spool/mail; then
254                 mutt_cv_mailpath=/usr/spool/mail
255             elif test -d /usr/mail; then
256                 mutt_cv_mailpath=/usr/mail
257             fi])
258         ])
259     if test "$mutt_cv_mailpath" = no; then
260         AC_MSG_ERROR("Could not determine where new mail is stored.")
261     fi
262     AC_DEFINE_UNQUOTED(MAILPATH,"$mutt_cv_mailpath",[ Where new mail is spooled. ])
263
264     AC_CACHE_CHECK(if $mutt_cv_mailpath is world writable, mutt_cv_worldwrite, [AC_TRY_RUN([#include <sys/types.h>
265 #include <sys/stat.h>
266
267 int main (int argc, char **argv)
268 {
269         struct stat s;
270
271         stat ("$mutt_cv_mailpath", &s);
272         if (s.st_mode & S_IWOTH) exit (0);
273         exit (1);
274 }], mutt_cv_worldwrite=yes, mutt_cv_worldwrite=no, mutt_cv_worldwrite=no)])
275
276         mutt_cv_setgid=no
277         if test $mutt_cv_worldwrite != yes; then
278                 AC_CACHE_CHECK(if $mutt_cv_mailpath is group writable, mutt_cv_groupwrite, [AC_TRY_RUN([#include <sys/types.h>
279 #include <sys/stat.h>
280
281 int main (int argc, char **argv)
282 {
283         struct stat s;
284
285         stat ("$mutt_cv_mailpath", &s);
286         if (s.st_mode & S_IWGRP) exit (0);
287         exit (1);
288 }], mutt_cv_groupwrite=yes, mutt_cv_groupwrite=no, mutt_cv_groupwrite=no)])
289
290         if test $mutt_cv_groupwrite = yes; then
291             AC_DEFINE(USE_SETGID,1,[ Define if mutt should run setgid "mail". ])
292             mutt_cv_setgid=yes
293         fi
294     fi
295 fi
296
297 AC_MSG_CHECKING(where to put the documentation)
298 AC_ARG_WITH(docdir, AC_HELP_STRING([--with-docdir=PATH], [Specify where to put the documentation]),
299         [mutt_cv_docdir=$withval],
300         [mutt_cv_docdir="${prefix}/doc/madmutt"])
301 AC_MSG_RESULT($mutt_cv_docdir)
302
303 docdir=$mutt_cv_docdir
304 AC_SUBST(docdir)
305
306 if test x$mutt_cv_setgid = xyes; then
307     DOTLOCK_GROUP='mail'
308     DOTLOCK_PERMISSION=2755
309 else
310     DOTLOCK_GROUP=''
311     DOTLOCK_PERMISSION=755
312 fi
313 AC_SUBST(DOTLOCK_GROUP)
314 AC_SUBST(DOTLOCK_PERMISSION)
315
316 dnl -- socket dependencies --
317
318 AC_ARG_ENABLE(nntp, AC_HELP_STRING([--enable-nntp],[Enable NNTP support]),[
319     if test x$enableval = xyes ; then
320         AC_DEFINE(USE_NNTP,1,[ Compiling with newsreading support with NNTP ])
321         LIBNNTP="-Lnntp -lnntp"
322         LIBNNTPDEPS="\$(top_srcdir)/nntp/nntp.h nntp/libnntp.a"
323         need_nntp="yes"
324     fi
325 ])
326 AM_CONDITIONAL(BUILD_NNTP, test x$need_nntp = xyes)
327
328 AC_MSG_CHECKING([for socklen_t])
329 AC_EGREP_HEADER(socklen_t, sys/socket.h, AC_MSG_RESULT([yes]),
330         AC_MSG_RESULT([no])
331         AC_DEFINE(socklen_t,int, [ Define to 'int' if <sys/socket.h> doesn't have it. ]))
332 AC_CHECK_FUNC(gethostent, , AC_CHECK_LIB(nsl, gethostent))
333 AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt))
334 AC_CHECK_FUNCS(getaddrinfo)
335
336 dnl -- imap dependencies --
337
338 AC_ARG_WITH(gss, AC_HELP_STRING([--with-gss], [Compile in GSSAPI authentication for IMAP]),[
339     if test x$with_gss != xno; then
340         PKG_CHECK_MODULES(GSSAPI,libgssapi,[
341             CPPFLAGS="$CPPFLAGS $GSSAPI_CFLAGS"
342             MUTTLIBS="$MUTTLIBS $GSSAPI_LIBS"
343             AC_DEFINE(USE_GSS,1,[ Define if you have GSSAPI libraries available ])
344             AC_CHECK_HEADERS(xom.h)
345         ],[
346            AC_MSG_ERROR([could not find libgssapi])
347         ])
348     fi
349 ])
350
351 AC_ARG_WITH(ssl, AC_HELP_STRING([--with-ssl[=PFX]], [Compile in SSL support for POP/IMAP]),
352 [   if test "$with_ssl" != "no"; then
353         if test "$with_ssl" != "yes"; then
354             LDFLAGS="$LDFLAGS -L$withval/lib"
355             CPPFLAGS="$CPPFLAGS -I$withval/include"
356         fi
357         saved_LIBS="$LIBS"
358
359         AC_CHECK_LIB(crypto, X509_new,, AC_MSG_ERROR([Unable to find SSL library]))
360         AC_CHECK_LIB(ssl, SSL_new,, AC_MSG_ERROR([Unable to find SSL library]), -lcrypto)
361
362         AC_CHECK_FUNCS(RAND_status RAND_egd)
363
364         AC_DEFINE(USE_SSL,1,[ Define if you want support for SSL. ])
365         LIBS="$saved_LIBS"
366         MUTTLIBS="$MUTTLIBS -lssl -lcrypto"
367         need_ssl=yes
368     fi
369 ])
370
371 AC_ARG_WITH([gnutls], AC_HELP_STRING([--with-gnutls], [Enable SSL support using gnutls]),
372             [gnutls_prefix="$withval"], [gnutls_prefix="no"])
373 if test "$gnutls_prefix" != "no"; then
374     if test x"$need_ssl" = x"yes"; then
375         AC_MSG_ERROR([Only either OpenSSL or GNUTLS may be used])
376     fi
377     AM_PATH_LIBGNUTLS(,[
378         CPPFLAGS="$CPPFLAGS $LIBGNUTLS_CFLAGS"
379         MUTTLIBS="$MUTTLIBS $LIBGNUTLS_LIBS"
380         AC_DEFINE(USE_GNUTLS, 1, [Define if you want support for SSL via the gnutls library.])
381         need_ssl=yes],
382         [AC_MSG_ERROR([could not find libgnutls])
383     ])
384 fi
385 AM_CONDITIONAL(USE_SSL, test x$need_ssl = xyes)
386 AC_SUBST(MUTT_SSL_OBJECTS)
387
388 AC_ARG_WITH(sasl2, AC_HELP_STRING([--with-sasl2[=PFX]],
389             [Use Cyrus SASL library version 2 for POP/IMAP authentication]),[
390     if test "$with_sasl2" != "no"; then
391         if test "$with_sasl2" != "yes"; then
392             CPPFLAGS="$CPPFLAGS -I$with_sasl2/include"
393             LDFLAGS="$LDFLAGS -L$with_sasl2/lib"
394         fi
395
396         saved_LIBS="$LIBS"
397
398         AC_CHECK_LIB(sasl2, sasl_client_init,,AC_MSG_ERROR([could not find libsasl2]))
399
400         MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS mutt_sasl.o"
401         MUTTLIBS="$MUTTLIBS -lsasl2"
402         LIBS="$saved_LIBS"
403         AC_DEFINE(USE_SASL,1,
404                   [Define if want to use version 2 of the Cyrus SASL library.])
405         need_sasl=yes
406     fi
407 ])
408 AM_CONDITIONAL(USE_SASL, test x$need_sasl = xyes)
409
410 AC_ARG_WITH(idn, AC_HELP_STRING([--with-idn], [Use GNU libidn for domain names]),[
411     if test x$with_idn != xno ; then
412         PKG_CHECK_MODULES(IDN,libidn,[
413             if $PKG_CONFIG --atleast-version=0.6; then
414                 AC_MSG_ERROR([libidn is too old, want 0.6 at least])
415             fi
416             CPPFLAGS="$CPPFLAGS $IDN_CFLAGS"
417             LDFLAGS="$LDFLAGS $IDN_LIBS"
418         ],[AC_MSG_ERROR([could not find libidn])])
419     fi
420 ])
421
422 dnl -- end socket --
423
424 AC_ARG_ENABLE(flock, AC_HELP_STRING([--enable-flock], [Use flock() to lock files]),
425         [if test $enableval = yes; then
426                 AC_DEFINE(USE_FLOCK,1, [ Define to use flock() to lock mailboxes. ])
427         fi])
428
429 mutt_cv_fcntl=yes
430 AC_ARG_ENABLE(fcntl, AC_HELP_STRING([--disable-fcntl], [Do NOT use fcntl() to lock files]),
431         [if test $enableval = no; then mutt_cv_fcntl=no; fi])
432
433 if test $mutt_cv_fcntl = yes; then
434         AC_DEFINE(USE_FCNTL,1, [ Define to use fcntl() to lock folders. ])
435 fi
436
437 AC_MSG_CHECKING(whether struct dirent defines d_ino)
438 ac_cv_dirent_d_ino=no
439 AC_TRY_LINK([#include <dirent.h>],[struct dirent dp; (void)dp.d_ino],[ac_cv_dirent_d_ino=yes])
440 if test x$ac_cv_dirent_d_ino = xyes ; then
441   AC_DEFINE(HAVE_DIRENT_D_INO,1,
442             [Define to 1 if your system has the dirent::d_ino member])
443 fi
444 AC_MSG_RESULT($ac_cv_dirent_d_ino)
445
446 dnl -- start cache --
447 AC_ARG_ENABLE(hcache, AC_HELP_STRING([--enable-hcache], [Enable header caching]),
448 [if test x$enableval = xyes; then
449     AC_DEFINE(USE_HCACHE, 1, [Enable header caching])
450
451     OLDCPPFLAGS="$CPPFLAGS"
452     OLDLIBS="$LIBS"
453
454     need_md5="yes"
455
456     ac_prefer_qdbm=yes
457     AC_ARG_WITH(qdbm, AC_HELP_STRING([--without-qdbm], [Don't use qdbm even if it is available]),
458         ac_prefer_qdbm=$withval)
459     if test x$ac_prefer_qdbm != xno; then
460         PKG_CHECK_MODULES(QDBM,qdbm,[ac_qdbm_here=yes],[ac_qdbm_here=no])
461     fi
462
463     ac_prefer_gdbm=yes
464     AC_ARG_WITH(gdbm, AC_HELP_STRING([--without-gdbm], [Don't use gdbm even if it is available]),
465         ac_prefer_gdbm=$withval)
466     if test x$ac_prefer_gdbm != xno -a x$ac_qdbm_here != xyes; then
467         ac_cv_gdbmopen=no
468         GDBM_DIRS="${prefix} /usr/local /usr"
469         AC_MSG_CHECKING([for gdbm_open])
470         for d in $GDBM_DIRS; do
471           if test x$ac_cv_gdbmopen = xno && test -d "$d/include" && test -d "$d/lib"; then
472             GDBM_INC="-I$d/include"
473             GDBM_LIB="-L$d/lib"
474             CPPFLAGS="$OLDCPPFLAGS $GDBM_INC"
475             LIBS="$OLDLIBS $GDBM_LIB -lgdbm"
476             AC_TRY_LINK([#include <gdbm.h>],[gdbm_open(0,0,0,0,0);],[ac_cv_gdbmopen=yes])
477           fi
478         done
479         if test x$ac_cv_gdbmopen = xyes; then
480           AC_MSG_RESULT(yes)
481         else
482           AC_MSG_RESULT(no)
483         fi
484     fi
485
486     ac_bdb_prefix=yes
487     AC_ARG_WITH(bdb, AC_HELP_STRING([--with-bdb[=DIR]], [Use BerkeleyDB4 if gdbm is not available ]),
488         ac_bdb_prefix=$withval)
489     if test x$ac_bdb_prefix != xno -a x$ac_cv_gdbmopen != xyes -a x$ac_qdbm_here != xyes; then
490         test x$ac_bdb_prefix = xyes && ac_bdb_prefix="${prefix} /opt/csw/bdb4 /opt /usr/local /usr"
491         for d in $ac_bdb_prefix; do
492             bdbpfx="$bdbpfx $d"
493             for v in BerkeleyDB.4.3 BerkeleyDB.4.2 BerkeleyDB.4.1; do
494                 bdbpfx="$bdbpfx $d/$v"
495             done
496         done
497         BDB_VERSIONS="db-4 db4 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db ''"
498         AC_MSG_CHECKING([for BerkeleyDB > 4.0])
499         for d in $bdbpfx; do
500             BDB_INCLUDE_DIR=""
501             BDB_LIB_DIR=""
502             for v in / $BDB_VERSIONS; do
503                 if test -r "$d/include/$v/db.h"; then
504                     BDB_INCLUDE_DIR="$d/include/$v"
505                     if test -d "$d/lib/$v"; then
506                         BDB_LIB_DIR="$d/lib/$v"
507                         for l in `echo $BDB_VERSIONS`; do
508                             CPPFLAGS="-I$BDB_INCLUDE_DIR $OLDCPPFLAGS"
509                             LIBS="$OLDLIBS -L$BDB_LIB_DIR -l$l"
510                             AC_TRY_LINK([
511                                 #include <stdlib.h>
512                                 #include <db.h>
513                             ],[
514                                 DB *db = NULL;
515                                 db->open(db,NULL,NULL,NULL,0,0,0);
516                             ],[
517                                 ac_cv_dbcreate=yes
518                                 BDB_LIB="$l"
519                                 break
520                             ])
521                         done
522                         test x$ac_cv_dbcreate = xyes && break
523                     fi
524                 fi
525             done
526             test x$BDB_LIB != x && break
527         done
528         if test x$ac_cv_dbcreate = xyes; then
529             AC_MSG_RESULT(yes)
530         else
531             AC_MSG_RESULT(no)
532         fi
533     fi
534
535     if test x$ac_qdbm_here = xyes; then
536         CPPFLAGS="$OLDCPPFLAGS $QDBM_CFLAGS"
537         LIBS="$OLDLIBS $QDBM_LIBS"
538         AC_DEFINE(HAVE_QDBM, 1, [QDBM Support])
539     elif test x$ac_cv_gdbmopen = xyes; then
540         CPPFLAGS="$OLDCPPFLAGS $GDBM_INC"
541         LIBS="$OLDLIBS $GDBM_LIB -lgdbm";
542         AC_DEFINE(HAVE_GDBM, 1, [GDBM Support])
543     elif test x$ac_cv_dbcreate = xyes; then
544         CPPFLAGS="-I$BDB_INCLUDE_DIR $OLDCPPFLAGS"
545         LIBS="$OLDLIBS -L$BDB_LIB_DIR -l$BDB_LIB"
546         AC_DEFINE(HAVE_DB4, 1, [Sleepycat DB4 Support])
547     else
548         AC_MSG_ERROR([You need one of: QDBM, GDBM or Sleepycat DB4 for --enable-hcache])
549     fi
550 fi])
551 dnl -- end cache --
552
553 AC_SUBST(MUTTLIBS)
554 AC_SUBST(MUTT_LIB_OBJECTS)
555 AC_SUBST(LIBNNTP)
556 AC_SUBST(LIBNNTPDEPS)
557
558 dnl -- iconv/gettext --
559
560 AC_ARG_ENABLE(iconv, AC_HELP_STRING([--disable-iconv], [Disable iconv support]),
561         [if test x$enableval = xno ; then
562                 am_cv_func_iconv=no
563         fi
564 ])
565
566 AM_GNU_GETTEXT
567
568 if test "$am_cv_func_iconv" != "yes"; then
569     AC_MSG_WARN([Configuring without iconv support. See INSTALL for details])
570 else
571
572     AC_CHECK_HEADERS(iconv.h,
573         [AC_MSG_CHECKING(whether iconv.h defines iconv_t)
574          AC_EGREP_HEADER([typedef.*iconv_t],iconv.h,
575                 [AC_MSG_RESULT(yes)
576                  AC_DEFINE(HAVE_ICONV_T_DEF, 1,
577                         [Define if <iconv.h> defines iconv_t.])],
578                  AC_MSG_RESULT(no))])
579
580     dnl (1) Some implementations of iconv won't convert from UTF-8 to UTF-8.
581     dnl (2) In glibc-2.1.2 and earlier there is a bug that messes up ob and
582     dnl     obl when args 2 and 3 are 0 (fixed in glibc-2.1.3).
583     AC_CACHE_CHECK([whether this iconv is good enough], mutt_cv_iconv_good,
584                    mutt_save_LIBS="$LIBS"
585                    LIBS="$LIBS $LIBICONV"
586                    AC_TRY_RUN([
587 #include <iconv.h>
588 int main()
589 {
590   iconv_t cd;
591 changequote(, )dnl
592   char buf[4];
593 changequote([, ])dnl
594   char *ob;
595   size_t obl;
596   ob = buf, obl = sizeof(buf);
597   return ((cd = iconv_open("UTF-8", "UTF-8")) != (iconv_t)(-1) &&
598           (iconv(cd, 0, 0, &ob, &obl) ||
599            !(ob == buf && obl == sizeof(buf)) ||
600            iconv_close(cd)));
601 }
602                    ],
603                    mutt_cv_iconv_good=yes,
604                    mutt_cv_iconv_good=no,
605                    mutt_cv_iconv_good=yes)
606                    LIBS="$mutt_save_LIBS")
607     if test "$mutt_cv_iconv_good" = no; then
608         AC_MSG_ERROR(Try using libiconv instead)
609     fi
610
611 fi # libiconv
612
613 dnl -- locales --
614
615 AC_CHECK_HEADERS(locale.h wchar.h wctype.h)
616 AC_CHECK_FUNCS(iswalnum iswalpha  iswcntrl iswdigit)
617 AC_CHECK_FUNCS(iswgraph iswlower iswprint iswpunct iswspace iswupper)
618 AC_CHECK_FUNCS(iswxdigit towupper towlower)
619 AC_TYPE_MBSTATE_T
620
621 AC_CACHE_CHECK([for nl_langinfo and CODESET], mutt_cv_langinfo_codeset,
622                [AC_TRY_LINK([#include <langinfo.h>],
623                             [char* cs = nl_langinfo(CODESET);],
624                             mutt_cv_langinfo_codeset=yes,
625                             mutt_cv_langinfo_codeset=no)])
626 if test $mutt_cv_langinfo_codeset = yes; then
627     AC_DEFINE(HAVE_LANGINFO_CODESET,1,
628               [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
629 fi
630
631 AC_CACHE_CHECK([for nl_langinfo and YESEXPR], mutt_cv_langinfo_yesexpr,
632                [AC_TRY_LINK([#include <langinfo.h>],
633                             [char* cs = nl_langinfo(YESEXPR);],
634                             mutt_cv_langinfo_yesexpr=yes,
635                             mutt_cv_langinfo_yesexpr=no)])
636 if test $mutt_cv_langinfo_yesexpr = yes; then
637     AC_DEFINE(HAVE_LANGINFO_YESEXPR,1,
638               [Define if you have <langinfo.h> and nl_langinfo(YESEXPR).])
639 fi
640
641 dnl -- libesmtp --
642 MUTT_AM_LIBESMTP
643 if test x$use_libesmtp = xyes; then
644     CFLAGS="$CFLAGS $mutt_libesmtp_cflags"
645     dnl HACK MUTTLIBS="$MUTTLIBS $mutt_libesmtp_libs"
646     MUTTLIBS="$MUTTLIBS -lesmtp"
647     MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS mutt_libesmtp.o"
648     AC_DEFINE(USE_LIBESMTP, 1, [Define to enable the use of libesmtp])
649 fi
650 dnl -- end libesmtp --
651
652 dnl -- sgml tools --
653
654 dnl Documentation tools
655 have_openjade="no"
656 AC_PATH_PROG([OSPCAT], [ospcat], [none])
657 if test "x$OSPCAT" != "xnone"; then
658     AC_MSG_CHECKING([for openjade docbook stylesheets])
659     dslosfile=`ospcat --public-id="-//Norman Walsh//DOCUMENT DocBook Print Stylesheet//EN"`
660     DSLROOT=`echo $dslosfile | sed -n -e "s/.*SOIBASE='\(@<:@^'@:>@*\)\/catalog'.*/\1/p"`
661     # ospcat may spit out an absolute path without an SOIBASE
662     if test -z "$DSLROOT"; then
663         DSLROOT=`echo $dslosfile | sed -e 's|<OSFILE>\(.*\)/print/docbook.dsl|\1|'`
664     fi
665     if test -f $DSLROOT/print/docbook.dsl; then
666         AC_MSG_RESULT([in $DSLROOT])
667         have_openjade="yes"
668     else
669         AC_MSG_RESULT([not found: PDF documentation will not be built.])
670     fi
671 fi
672 AC_SUBST(DSLROOT)
673
674 AC_MSG_CHECKING([for lynx])
675 AC_PATH_PROG([HTML2TXT_CMD], [lynx], [none])
676 if test x"$HTML2TXT_CMD" = x"none"; then
677     AC_MSG_CHECKING([for w3m])
678     AC_PATH_PROG([HTML2TXT_CMD], [w3m], [none])
679 fi
680 if test x"$HTML2TXT_CMD" = x"none"; then
681     AC_MSG_CHECKING([for elinks])
682     AC_PATH_PROG([HTML2TXT_CMD], [elinks], [none])
683 fi
684 case "$HTML2TXT_CMD" in
685   *elinks*)
686     HTML2TXT_CMD="$HTML2TXT_CMD -dump -no-numbering -no-references \$^ > \$@"
687     ;;
688   *lynx*)
689     HTML2TXT_CMD="$HTML2TXT_CMD -dump -nolist -with_backspaces \$^ > \$@"
690     ;;
691   *w3m*)
692     HTML2TXT_CMD="$HTML2TXT_CMD -dump \$^ > \$@"
693     ;;
694   *)
695     HTML2TXT_CMD="true"
696     ;;
697 esac
698 AC_SUBST(HTML2TXT_CMD)
699
700 AC_MSG_CHECKING([for tidy])
701 AC_PATH_PROG([HTMLCLEAN_CMD], [tidy], [none])
702
703 if test x"$HTMLCLEAN_CMD" != x"none"; then
704     HTMLCLEAN_CMD="$HTMLCLEAN_CMD -q -i -m -asxml -utf8 "
705 else
706     HTMLCLEAN_CMD="echo "
707 fi
708 AC_SUBST(HTMLCLEAN_CMD)
709
710 AC_ARG_ENABLE(doc,
711   [  --enable-doc            build documentation (needs doxygen and LaTeX)])
712 # Build documentation?
713 DOXYGEN="no"
714 LATEX="no"
715 if test "${enable_doc}" != "no"; then
716   AC_PATH_PROG(DOXYGEN, doxygen, no)
717   if test "${DOXYGEN}" != "no"; then
718     # Build LaTeX documentation?
719     AC_PATH_PROG(LATEX, pdflatex, no)
720     AC_PATH_PROG(DVIPS, dvips, no)
721     if test "${DVIPS}" = "no"; then
722       LATEX="no"
723     fi
724     AC_MSG_CHECKING(for a4wide.sty)
725     if test -f /usr/share/texmf/tex/latex/misc/a4wide.sty; then
726       AC_MSG_RESULT(yes)
727     elif test -f /usr/share/texmf-tetex/tex/latex/a4wide/a4wide.sty; then
728       AC_MSG_RESULT(yes)
729     else
730       LATEX="no"
731       AC_MSG_RESULT(no)
732     fi
733   fi
734 fi
735 AM_CONDITIONAL(BUILD_DOCUMENTATION, test "${DOXYGEN}" != "no")
736 AM_CONDITIONAL(USE_LATEX, test "${LATEX}" != "no")
737
738 AC_OUTPUT(Makefile
739           Madmuttrc.head
740           intl/Makefile
741           m4/Makefile
742           po/Makefile.in
743           apidoc/Makefile apidoc/doxygen.cfg
744           doc/Makefile doc/instdoc.sh
745           contrib/Makefile
746           lib-lib/Makefile
747           lib-lua/Makefile
748           lib-mime/Makefile
749           lib-crypt/Makefile
750           lib-hash/Makefile
751           lib-mx/Makefile
752           lib-sys/Makefile
753           lib-ui/Makefile
754           imap/Makefile
755           pop/Makefile
756           nntp/Makefile
757 )