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