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