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