put some comments to make the header reading easier
[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
10 mutt_cv_version=`cat "$srcdir/VERSION.in"`
11
12 AM_INIT_AUTOMAKE(muttng, $mutt_cv_version)
13 AC_SUBST([CONFIGURE_DEPENDENCIES], ['$(top_srcdir)/VERSION.in'])
14
15 AC_GNU_SOURCE
16
17 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"
18
19 AC_CANONICAL_HOST
20
21 AC_MSG_CHECKING([for prefix])
22 if test x$prefix = xNONE; then
23     mutt_cv_prefix=$ac_default_prefix
24 else
25     mutt_cv_prefix=$prefix
26 fi
27 AC_MSG_RESULT($mutt_cv_prefix)
28
29 AC_PROG_CC
30 AC_ISC_POSIX
31 AM_C_PROTOTYPES
32 if test "x$U" != "x"; then
33     AC_MSG_ERROR(Compiler not ANSI compliant)
34 fi
35 AC_PROG_CPP
36 AC_PROG_MAKE_SET
37 AC_PROG_INSTALL
38 AC_PROG_RANLIB
39 AC_CHECK_TOOL(AR, ar, ar)
40
41 AC_C_INLINE
42 AC_C_CONST
43
44 AC_SYS_LARGEFILE
45 AC_FUNC_FSEEKO
46 AC_CHECK_SIZEOF(off_t)
47
48 AC_PATH_PROG(DBX, dbx, no)
49 AC_PATH_PROG(GDB, gdb, no)
50 AC_PATH_PROG(SDB, sdb, no)
51
52 if test $GDB != no ; then
53     DEBUGGER=$GDB
54 elif test $DBX != no ; then
55     DEBUGGER=$DBX
56 elif test $SDB != no ; then
57     DEBUGGER=$SDB
58 else
59     DEBUGGER=no
60 fi
61
62 AC_SUBST([DEBUGGER])
63
64 AH_TEMPLATE([sig_atomic_t],
65             [Define to 'int' if <signal.h> doesn't define.])
66 AH_TEMPLATE([HAVE_START_COLOR],
67             [Define if you have start_color, as a function or macro.])
68 AH_TEMPLATE([HAVE_TYPEAHEAD],
69             [Define if you have typeahead, as a function or macro.])
70 AH_TEMPLATE([HAVE_BKGDSET],
71             [Define if you have bkgdset, as a function or macro.])
72 AH_TEMPLATE([HAVE_CURS_SET],
73             [Define if you have curs_set, as a function or macro.])
74 AH_TEMPLATE([HAVE_META],
75             [Define if you have meta, as a function or macro.])
76 AH_TEMPLATE([HAVE_USE_DEFAULT_COLORS],
77             [Define if you have use_default_colors, as a function or macro.])
78 AH_TEMPLATE([HAVE_RESIZETERM],
79             [Define if you have resizeterm, as a function or macro.])
80 AH_TEMPLATE([SIG_ATOMIC_VOLATILE_T],
81             [Some systems declare sig_atomic_t as volatile, some others -- no.
82              This define will have value `sig_atomic_t' or
83              `volatile sig_atomic_t' accordingly.])
84 AH_TEMPLATE([ICONV_NONTRANS],
85             [Define as 1 if iconv() only converts exactly and we should treat
86              all return values other than (size_t)(-1) as equivalent.])
87
88 MUTT_C99_INTTYPES
89
90 dnl ---------------- sendmail ----------------
91
92 ac_aux_path_sendmail=/usr/sbin:/usr/lib
93 AC_PATH_PROG(SENDMAIL, sendmail, /usr/sbin/sendmail, $PATH:$ac_aux_path_sendmail)
94 AC_DEFINE_UNQUOTED(SENDMAIL,"$ac_cv_path_SENDMAIL",[ Where to find sendmail on your system. ])
95
96
97 OPS='$(srcdir)/OPS'
98
99 dnl ---------------- gpgme ----------------
100
101     AC_ARG_ENABLE(gpgme, AC_HELP_STRING([--enable-gpgme], [Enable GPGME support]),
102     [   if test x$enableval = xyes; then
103             have_gpgme=yes
104         fi
105     ])
106     AC_ARG_WITH(gpgme-prefix, AC_HELP_STRING([--with-gpgme-prefix=PFX], [prefix where GPGME is installed (optional)]),
107     gpgme_config_prefix="$withval", gpgme_config_prefix="")
108
109     if test x$have_gpgme = xyes; then
110         if test x$gpgme_config_prefix != x; then
111             GPGME_CONFIG="$gpgme_config_prefix/bin/gpgme-config"
112         else
113             AC_PATH_PROG(GPGME_CONFIG, gpgme-config, no)
114         fi
115         if test "x$GPGME_CONFIG" = "xno"; then
116             AC_MSG_ERROR([GPGME not found])
117         else
118             LIBGPGME_CFLAGS=`$GPGME_CONFIG --cflags`
119             LIBGPGME_LIBS=`$GPGME_CONFIG --libs`
120             MUTTLIBS="$MUTTLIBS $LIBGPGME_LIBS"
121             MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS crypt-gpgme.o crypt-mod-pgp-gpgme.o crypt-mod-smime-gpgme.o"
122             AC_DEFINE(CRYPT_BACKEND_GPGME, 1, [Defined, if GPGME support is enabled])
123         fi
124     fi
125     AC_SUBST(LIBGPGME_CFLAGS)
126     AC_SUBST(LIBGPGME_LIBS)
127
128 dnl ---------------- mixmaster ----------------
129
130     AC_ARG_WITH(mixmaster, AC_HELP_STRING([--with-mixmaster[=PATH]], [Include Mixmaster support]),
131     [   if test -x "$withval" ; then
132             MIXMASTER="$withval"
133         else
134             MIXMASTER="mixmaster"
135         fi
136         OPS="$OPS \$(srcdir)/OPS.MIX"
137         MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS remailer.o"
138         AC_DEFINE_UNQUOTED(MIXMASTER,"$MIXMASTER", [ Where to find mixmaster on your system. ])
139     ])
140
141 # We now require all OPS
142 OPS="$OPS \$(srcdir)/OPS.PGP \$(srcdir)/OPS.SMIME \$(srcdir)/OPS.CRYPT "
143 AC_SUBST([OPS])
144
145 AC_PATH_PROG(ISPELL, ispell, no)
146 if test $ISPELL != no; then
147     AC_DEFINE_UNQUOTED(ISPELL,"$ISPELL",[ Where to find ispell on your system. ])
148 fi
149
150 AC_ARG_WITH(slang, AC_HELP_STRING([--with-slang[=DIR]], [Use S-Lang instead of ncurses]),
151     [AC_CACHE_CHECK([if this is a BSD system], mutt_cv_bsdish,
152         [AC_TRY_RUN([#include <sys/param.h>
153
154 main ()
155 {
156 #ifdef BSD
157         exit (0);
158 #else
159         exit (1);
160 #endif
161 }],
162         mutt_cv_bsdish=yes,
163         mutt_cv_bsdish=no,
164         mutt_cv_bsdish=no)])
165
166         AC_MSG_CHECKING(for S-Lang)
167         if test $withval = yes; then
168             if test -d $srcdir/../slang; then
169                 mutt_cv_slang=$srcdir/../slang/src
170                 CFLAGS="$CFLAGS -I${mutt_cv_slang}"
171                 LDFLAGS="$LDFLAGS -L${mutt_cv_slang}/objs"
172             else
173                 if test -d $mutt_cv_prefix/include/slang; then
174                     CFLAGS="$CFLAGS -I$mutt_cv_prefix/include/slang"
175                 elif test -d /usr/include/slang; then
176                     CFLAGS="$CFLAGS -I/usr/include/slang"
177                 fi
178                 mutt_cv_slang=yes
179             fi
180         else
181             dnl ---Check to see if $withval is a source directory
182             if test -f $withval/src/slang.h; then
183                 mutt_cv_slang=$withval/src
184                 CFLAGS="$CFLAGS -I${mutt_cv_slang}"
185                 LDFLAGS="$LDFLAGS -L${mutt_cv_slang}/objs"
186             else
187                 dnl ---Must be installed somewhere
188                 mutt_cv_slang=$withval
189                 if test -d $withval/include/slang; then
190                         CFLAGS="$CFLAGS -I${withval}/include/slang"
191                 elif test -d $withval/include; then
192                         CFLAGS="$CFLAGS -I${withval}/include"
193                 fi
194                 LDFLAGS="$LDFLAGS -L${withval}/lib"
195             fi
196         fi
197         AC_MSG_RESULT($mutt_cv_slang)
198         if test $mutt_cv_bsdish = yes; then
199             AC_CHECK_LIB(termlib, main)
200         fi
201         AC_DEFINE(USE_SLANG_CURSES,1, [ Define if you compile with SLang instead of curses/ncurses. ])
202         AC_DEFINE(HAVE_COLOR,1,[ Define if your curses library supports color. ])
203         MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS resize.o"
204
205         dnl --- now that we've found it, check the link
206
207         AC_CHECK_LIB(slang, SLtt_get_terminfo,
208             [MUTTLIBS="$MUTTLIBS -lslang -lm"],
209             [AC_MSG_ERROR(unable to compile.  check config.log)], -lm)
210         ],
211
212         [   mutt_cv_curses=/usr
213             AC_ARG_WITH(curses, AC_HELP_STRING([--with-curses=DIR], [Where ncurses is installed]),
214             [   if test $withval != yes; then
215                     mutt_cv_curses=$withval
216                 fi
217                 if test x$mutt_cv_curses != x/usr; then
218                     LDFLAGS="-L${mutt_cv_curses}/lib $LDFLAGS"
219                     CPPFLAGS="$CPPFLAGS -I${mutt_cv_curses}/include"
220                 fi
221             ])
222
223             AC_CHECK_FUNC(initscr,,[
224             cf_ncurses="ncurses"
225             for lib in ncursesw ncurses; do
226                 AC_CHECK_LIB($lib, waddnwstr, [cf_ncurses="$lib"; break])
227             done
228             AC_CHECK_LIB($cf_ncurses, initscr,
229                 [   MUTTLIBS="$MUTTLIBS -l$cf_ncurses"
230                     if test x$mutt_cv_curses = x/usr -a -d /usr/include/ncurses; then
231                         CPPFLAGS="$CPPFLAGS -I/usr/include/ncurses"
232                     fi
233
234                     if test "$cf_ncurses" = ncursesw; then
235                         AC_CHECK_HEADERS(ncurses/ncurses.h,[cf_cv_ncurses_header="ncurses/ncurses.h"])
236                         AC_CHECK_HEADERS(ncursesw/ncurses.h,[cf_cv_ncurses_header="ncursesw/ncurses.h"])
237                     else
238                         AC_CHECK_HEADERS(ncurses.h,[cf_cv_ncurses_header="ncurses.h"])
239                     fi
240                 ],
241                 [CF_CURSES_LIBS])
242             ])
243
244             old_LIBS="$LIBS"
245             LIBS="$LIBS $MUTTLIBS"
246             CF_CHECK_FUNCDECLS([#include <${cf_cv_ncurses_header-curses.h}>],
247                                [start_color typeahead bkgdset curs_set meta use_default_colors resizeterm])
248             if test "$ac_cv_func_decl_start_color" = yes; then
249                 AC_DEFINE(HAVE_COLOR,1,[ Define if your curses library supports color. ])
250             fi
251             if test "$ac_cv_func_decl_resizeterm" = yes; then
252                 MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS resize.o"
253             fi
254             LIBS="$old_LIBS"
255         ])
256
257 AC_HEADER_STDC
258
259 AC_CHECK_HEADERS(stdarg.h sys/ioctl.h ioctl.h sysexits.h)
260 AC_CHECK_HEADERS(sys/time.h sys/resource.h)
261 AC_CHECK_HEADERS(unix.h)
262
263 AC_CHECK_FUNCS(setrlimit getsid isctype)
264
265 AC_TYPE_SIGNAL
266
267 AC_MSG_CHECKING(for sig_atomic_t in signal.h)
268 AC_EGREP_HEADER(sig_atomic_t,signal.h,
269     [   ac_cv_type_sig_atomic_t=yes;
270         AC_EGREP_HEADER(volatile.*sig_atomic_t,
271                         signal.h,
272                         [is_sig_atomic_t_volatile=yes; AC_MSG_RESULT([yes, volatile])],
273                         [is_sig_atomic_t_volatile=no;  AC_MSG_RESULT([yes, non volatile])])
274     ],
275     [   AC_MSG_RESULT(no)
276         AC_CHECK_TYPE(sig_atomic_t, int)
277         is_sig_atomic_t_volatile=no
278     ])
279 if test $is_sig_atomic_t_volatile = 'yes'
280 then
281     AC_DEFINE(SIG_ATOMIC_VOLATILE_T, sig_atomic_t)
282 else
283     AC_DEFINE(SIG_ATOMIC_VOLATILE_T, [volatile sig_atomic_t])
284 fi
285
286 AC_DECL_SYS_SIGLIST
287
288 AC_TYPE_PID_T
289
290 AC_CHECK_FUNCS(fgetpos memmove setegid srand48 strerror)
291 AC_REPLACE_FUNCS(strcasecmp setenv)
292 AC_CHECK_FUNCS(snprintf vsnprintf)
293
294 AC_CHECK_FUNC(getopt)
295 if test $ac_cv_func_getopt = yes; then
296     AC_CHECK_HEADERS(getopt.h)
297 fi
298
299 AC_ARG_WITH(regex, AC_HELP_STRING([--with-regex], [Use the GNU regex library]),
300         [mutt_cv_regex=yes],
301         [AC_CHECK_FUNCS(regcomp, mutt_cv_regex=no, mutt_cv_regex=yes)])
302
303 if test $mutt_cv_regex = no ; then
304     AC_CACHE_CHECK([whether your system's regexp library is completely broken],
305         [mutt_cv_regex_broken],
306         AC_TRY_RUN([
307 #include <unistd.h>
308 #include <regex.h>
309 main() { regex_t blah ; regmatch_t p; p.rm_eo = p.rm_eo; return regcomp(&blah, "foo.*bar", REG_NOSUB) || regexec (&blah, "foobar", 0, NULL, 0); }],
310         mutt_cv_regex_broken=no, mutt_cv_regex_broken=yes, mutt_cv_regex_broken=yes))
311     if test $mutt_cv_regex_broken = yes ; then
312         echo "Using the included GNU regex instead." >&AC_FD_MSG
313         mutt_cv_regex=yes
314     fi
315 fi
316
317 if test $mutt_cv_regex = yes; then
318     AC_DEFINE(USE_GNU_REGEX,1,[ Define if you want to use the included regex.c. ])
319     LIBOBJS="$LIBOBJS regex.o"
320 fi
321
322
323 AC_ARG_WITH(homespool,
324             AC_HELP_STRING([--with-homespool[=FILE]],
325                            [File in user's directory where new mail is spooled]),
326                            with_homespool=${withval})
327 if test x$with_homespool != x; then
328     if test $with_homespool = yes; then
329             with_homespool=mailbox
330     fi
331     AC_DEFINE_UNQUOTED(MAILPATH,"$with_homespool",[ Where new mail is spooled. ])
332     AC_DEFINE(HOMESPOOL,1,
333     [   Is mail spooled to the user's home directory?  If defined,
334         MAILPATH should be set to the filename of the spool mailbox
335         relative the the home directory.
336         use: configure --with-homespool=FILE
337     ])
338     AC_DEFINE(USE_DOTLOCK,1,[ Define to use dotlocking for mailboxes. ])
339     mutt_cv_setgid=no
340 else
341     AC_ARG_WITH(mailpath, AC_HELP_STRING([--with-mailpath=DIR], [Directory where spool mailboxes are located]),
342         [mutt_cv_mailpath=$withval],
343         [ AC_CACHE_CHECK(where new mail is stored, mutt_cv_mailpath,
344             [mutt_cv_mailpath=no
345             if test -d /var/mail; then
346                 mutt_cv_mailpath=/var/mail
347             elif test -d /var/spool/mail; then
348                 mutt_cv_mailpath=/var/spool/mail
349             elif test -d /usr/spool/mail; then
350                 mutt_cv_mailpath=/usr/spool/mail
351             elif test -d /usr/mail; then
352                 mutt_cv_mailpath=/usr/mail
353             fi])
354         ])
355     if test "$mutt_cv_mailpath" = no; then
356         AC_MSG_ERROR("Could not determine where new mail is stored.")
357     fi
358     AC_DEFINE_UNQUOTED(MAILPATH,"$mutt_cv_mailpath",[ Where new mail is spooled. ])
359
360     AC_CACHE_CHECK(if $mutt_cv_mailpath is world writable, mutt_cv_worldwrite, [AC_TRY_RUN([#include <sys/types.h>
361 #include <sys/stat.h>
362
363 int main (int argc, char **argv)
364 {
365         struct stat s;
366
367         stat ("$mutt_cv_mailpath", &s);
368         if (s.st_mode & S_IWOTH) exit (0);
369         exit (1);
370 }], mutt_cv_worldwrite=yes, mutt_cv_worldwrite=no, mutt_cv_worldwrite=no)])
371
372         mutt_cv_setgid=no
373         if test $mutt_cv_worldwrite = yes; then
374                 AC_DEFINE(USE_DOTLOCK,1,[ Define to use dotlocking for mailboxes. ])
375         else
376
377                 AC_CACHE_CHECK(if $mutt_cv_mailpath is group writable, mutt_cv_groupwrite, [AC_TRY_RUN([#include <sys/types.h>
378 #include <sys/stat.h>
379
380 int main (int argc, char **argv)
381 {
382         struct stat s;
383
384         stat ("$mutt_cv_mailpath", &s);
385         if (s.st_mode & S_IWGRP) exit (0);
386         exit (1);
387 }], mutt_cv_groupwrite=yes, mutt_cv_groupwrite=no, mutt_cv_groupwrite=no)])
388
389         if test $mutt_cv_groupwrite = yes; then
390             AC_DEFINE(USE_DOTLOCK,1,[ Define to use dotlocking for mailboxes. ])
391             AC_DEFINE(USE_SETGID,1,[ Define if mutt should run setgid "mail". ])
392             mutt_cv_setgid=yes
393         fi
394     fi
395 fi
396
397 AC_MSG_CHECKING(where to put the documentation)
398 AC_ARG_WITH(docdir, AC_HELP_STRING([--with-docdir=PATH], [Specify where to put the documentation]),
399         [mutt_cv_docdir=$withval],
400         [mutt_cv_docdir="${prefix}/doc/muttng"])
401 AC_MSG_RESULT($mutt_cv_docdir)
402
403 docdir=$mutt_cv_docdir
404 AC_SUBST(docdir)
405
406 if test x$mutt_cv_setgid = xyes; then
407     DOTLOCK_GROUP='mail'
408     DOTLOCK_PERMISSION=2755
409 else
410     DOTLOCK_GROUP=''
411     DOTLOCK_PERMISSION=755
412 fi
413 AC_SUBST(DOTLOCK_GROUP)
414 AC_SUBST(DOTLOCK_PERMISSION)
415
416 dnl -- socket dependencies --
417
418 AC_ARG_ENABLE(nntp, [  --enable-nntp              Enable NNTP support],
419 [   if test x$enableval = xyes ; then
420         AC_DEFINE(USE_NNTP,1,[ Compiling with newsreading support with NNTP ])
421         LIBNNTP="-Lnntp -lnntp"
422         LIBNNTPDEPS="\$(top_srcdir)/nntp/nntp.h nntp/libnntp.a"
423         need_nntp="yes"
424     fi
425 ])
426 AM_CONDITIONAL(BUILD_NNTP, test x$need_nntp = xyes)
427
428 dnl -- end socket dependencies --
429
430 AC_MSG_CHECKING([for socklen_t])
431 AC_EGREP_HEADER(socklen_t, sys/socket.h, AC_MSG_RESULT([yes]),
432         AC_MSG_RESULT([no])
433         AC_DEFINE(socklen_t,int, [ Define to 'int' if <sys/socket.h> doesn't have it. ]))
434 AC_CHECK_FUNC(gethostent, , AC_CHECK_LIB(nsl, gethostent))
435 AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt))
436 AC_CHECK_FUNCS(getaddrinfo)
437
438 dnl -- imap dependencies --
439
440 AC_ARG_WITH(gss, AC_HELP_STRING([--with-gss[=PFX]], [Compile in GSSAPI authentication for IMAP]),
441     gss_prefix="$withval", gss_prefix="no")
442 if test "$gss_prefix" != "no"
443 then
444     MUTT_AM_PATH_GSSAPI(gss_prefix)
445     AC_MSG_CHECKING(GSSAPI implementation)
446     AC_MSG_RESULT($GSSAPI_IMPL)
447     if test "$GSSAPI_IMPL" = "none"
448     then
449       AC_CACHE_SAVE
450       AC_MSG_RESULT([GSSAPI libraries not found])
451     fi
452     if test "$GSSAPI_IMPL" = "Heimdal"
453     then
454       AC_DEFINE(HAVE_HEIMDAL,1,[ Define if your GSSAPI implementation is Heimdal ])
455     fi
456     CPPFLAGS="$CPPFLAGS $GSSAPI_CFLAGS"
457     MUTTLIBS="$MUTTLIBS $GSSAPI_LIBS"
458     AC_DEFINE(USE_GSS,1,[ Define if you have GSSAPI libraries available ])
459     need_gss="yes"
460 fi
461 AM_CONDITIONAL(USE_GSS, test x$need_gss = xyes)
462
463 dnl -- end imap dependencies --
464
465 AC_ARG_WITH(ssl, AC_HELP_STRING([--with-ssl[=PFX]], [Compile in SSL support for POP/IMAP]),
466 [       if test "$with_ssl" != "no"
467         then
468           if test "$with_ssl" != "yes"
469           then
470            LDFLAGS="$LDFLAGS -L$withval/lib"
471            CPPFLAGS="$CPPFLAGS -I$withval/include"
472           fi
473           saved_LIBS="$LIBS"
474
475           AC_CHECK_LIB(crypto, X509_new,, AC_MSG_ERROR([Unable to find SSL library]))
476           AC_CHECK_LIB(ssl, SSL_new,, AC_MSG_ERROR([Unable to find SSL library]), -lcrypto)
477
478           AC_CHECK_FUNCS(RAND_status RAND_egd)
479
480           AC_DEFINE(USE_SSL,1,[ Define if you want support for SSL. ])
481           LIBS="$saved_LIBS"
482           MUTTLIBS="$MUTTLIBS -lssl -lcrypto"
483           MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS mutt_ssl.o"
484           need_ssl=yes
485
486         fi
487 ])
488
489 AC_ARG_WITH([gnutls], AC_HELP_STRING([--with-gnutls[=PFX]], [Enable SSL support using gnutls]),
490     [gnutls_prefix="$withval"], [gnutls_prefix="no"])
491 if test "$gnutls_prefix" != "no"
492 then
493   if test x"$need_ssl" = x"yes"
494   then
495     AC_MSG_ERROR([Only either OpenSSL or GNUTLS may be used])
496   fi
497   MUTT_AM_PATH_GNUTLS([$gnutls_prefix],
498     [dnl GNUTLS found
499     CPPFLAGS="$CPPFLAGS $LIBGNUTLS_CFLAGS"
500     MUTTLIBS="$MUTTLIBS $LIBGNUTLS_LIBS"
501     AC_DEFINE(USE_GNUTLS, 1, [Define if you want support for SSL via the gnutls library.])
502
503     MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS mutt_ssl_gnutls.o"
504     need_ssl=yes],
505     [dnl GNUTLS not found
506       AC_MSG_ERROR([could not find libgnutls])
507     ])
508 fi
509
510 AM_CONDITIONAL(USE_SSL, test x$need_ssl = xyes)
511
512 AC_ARG_WITH(sasl2, AC_HELP_STRING([--with-sasl2[=PFX]],
513             [Use Cyrus SASL library version 2 for POP/IMAP authentication]),
514         [
515         if test "$with_sasl2" != "no"
516         then
517           if test "$with_sasl2" != "yes"
518           then
519             CPPFLAGS="$CPPFLAGS -I$with_sasl2/include"
520             LDFLAGS="$LDFLAGS -L$with_sasl2/lib"
521           fi
522
523           saved_LIBS="$LIBS"
524
525           AC_CHECK_LIB(sasl2, sasl_client_init,,
526             AC_MSG_ERROR([could not find libsasl2]),)
527
528           MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS mutt_sasl.o"
529           MUTTLIBS="$MUTTLIBS -lsasl2"
530           LIBS="$saved_LIBS"
531           AC_DEFINE(USE_SASL,1,
532                   [ Define if want to use version 2 of the Cyrus SASL library. ])
533           need_sasl=yes
534         fi
535         ])
536 AM_CONDITIONAL(USE_SASL, test x$need_sasl = xyes)
537
538 AC_ARG_WITH(idn, AC_HELP_STRING([--with-idn=[PFX]], [Use GNU libidn for domain names]),
539                  [
540                   if test "$with_idn" != "no" ; then
541                         if test "$with_idn" != "yes" ; then
542                            CPPFLAGS="$CPPFLAGS -I$with_idn/include"
543                            LDFLAGS="$LDFLAGS -L$with_idn/lib"
544                         fi
545                   fi
546                  ]
547 )
548
549 if test "x$with_idn" != "xno"; then
550     AC_CHECK_LIB(idn, stringprep_check_version)
551     AC_CHECK_FUNCS(idna_to_unicode_utf8_from_utf8 idna_to_unicode_8z8z)
552     AC_CHECK_FUNCS(idna_to_ascii_from_utf8 idna_to_ascii_8z)
553     AC_CHECK_FUNCS(idna_to_ascii_lz idna_to_ascii_from_locale)
554 fi
555
556 dnl -- end socket --
557
558 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging support]),
559     [ if test x$enableval = xyes ; then
560             AC_DEFINE(DEBUG,1,[ Define to enable debugging info. ])
561       fi
562      ])
563
564 AC_ARG_ENABLE(flock, AC_HELP_STRING([--enable-flock], [Use flock() to lock files]),
565         [if test $enableval = yes; then
566                 AC_DEFINE(USE_FLOCK,1, [ Define to use flock() to lock mailboxes. ])
567         fi])
568
569 mutt_cv_fcntl=yes
570 AC_ARG_ENABLE(fcntl, AC_HELP_STRING([--disable-fcntl], [Do NOT use fcntl() to lock files]),
571         [if test $enableval = no; then mutt_cv_fcntl=no; fi])
572
573 if test $mutt_cv_fcntl = yes; then
574         AC_DEFINE(USE_FCNTL,1, [ Define to use fcntl() to lock folders. ])
575 fi
576
577 AC_MSG_CHECKING(whether struct dirent defines d_ino)
578 ac_cv_dirent_d_ino=no
579 AC_TRY_LINK([#include <dirent.h>],[struct dirent dp; (void)dp.d_ino],[ac_cv_dirent_d_ino=yes])
580 if test x$ac_cv_dirent_d_ino = xyes ; then
581   AC_DEFINE(HAVE_DIRENT_D_INO,1,
582             [Define to 1 if your system has the dirent::d_ino member])
583 fi
584 AC_MSG_RESULT($ac_cv_dirent_d_ino)
585
586 AC_ARG_ENABLE(buffy-size, AC_HELP_STRING([--enable-buffy-size], [Use file size attribute instead of access time]),
587         [if test x$enableval = xyes; then
588                 AC_DEFINE(BUFFY_SIZE,1,[ Define to enable the "buffy_size" feature. ])
589         fi])
590
591 dnl -- start cache --
592 AC_ARG_ENABLE(hcache, AC_HELP_STRING([--enable-hcache], [Enable header caching]),
593 [if test x$enableval = xyes; then
594     AC_DEFINE(USE_HCACHE, 1, [Enable header caching])
595
596     OLDCPPFLAGS="$CPPFLAGS"
597     OLDLIBS="$LIBS"
598
599     need_md5="yes"
600
601     ac_prefer_qdbm=yes
602     AC_ARG_WITH(qdbm, AC_HELP_STRING([--without-qdbm], [Don't use qdbm even if it is available]),
603         ac_prefer_qdbm=$withval)
604     if test x$ac_prefer_qdbm != xno; then
605         ac_cv_vlopen=no
606         QDBM_DIRS="$mutt_cv_prefix /usr/local /usr"
607         AC_MSG_CHECKING([for vlopen])
608         for d in $QDBM_DIRS; do
609           if test x$ac_cv_vlopen = xno && test -d "$d/include" && test -d "$d/lib"; then
610             QDBM_INC="-I$d/include"
611             QDBM_LIB="-L$d/lib"
612             CPPFLAGS="$OLDCPPFLAGS $QDBM_INC"
613             LIBS="$OLDLIBS $QDBM_LIB -lqdbm"
614             AC_TRY_LINK([#include <villa.h>],[vlopen(0,0,0);],[ac_cv_vlopen=yes])
615           fi
616         done
617         if test x$ac_cv_vlopen = xyes; then
618           AC_MSG_RESULT(yes)
619         else
620           AC_MSG_RESULT(no)
621         fi
622     fi
623
624     ac_prefer_gdbm=yes
625     AC_ARG_WITH(gdbm, AC_HELP_STRING([--without-gdbm], [Don't use gdbm even if it is available]),
626         ac_prefer_gdbm=$withval)
627     if test x$ac_prefer_gdbm != xno -a x$ac_cv_vlopen != xyes; then
628         ac_cv_gdbmopen=no
629         GDBM_DIRS="$mutt_cv_prefix /usr/local /usr"
630         AC_MSG_CHECKING([for gdbm_open])
631         for d in $GDBM_DIRS; do
632           if test x$ac_cv_gdbmopen = xno && test -d "$d/include" && test -d "$d/lib"; then
633             GDBM_INC="-I$d/include"
634             GDBM_LIB="-L$d/lib"
635             CPPFLAGS="$OLDCPPFLAGS $GDBM_INC"
636             LIBS="$OLDLIBS $GDBM_LIB -lgdbm"
637             AC_TRY_LINK([#include <gdbm.h>],[gdbm_open(0,0,0,0,0);],[ac_cv_gdbmopen=yes])
638           fi
639         done
640         if test x$ac_cv_gdbmopen = xyes; then
641           AC_MSG_RESULT(yes)
642         else
643           AC_MSG_RESULT(no)
644         fi
645     fi
646    
647     ac_bdb_prefix=yes
648     AC_ARG_WITH(bdb, AC_HELP_STRING([--with-bdb[=DIR]], [Use BerkeleyDB4 if gdbm is not available ]),
649         ac_bdb_prefix=$withval)
650     if test x$ac_bdb_prefix != xno -a x$ac_cv_gdbmopen != xyes -a x$ac_cv_vlopen != xyes; then
651         test x$ac_bdb_prefix = xyes && ac_bdb_prefix="$mutt_cv_prefix /opt/csw/bdb4 /opt /usr/local /usr"
652         for d in $ac_bdb_prefix; do
653             bdbpfx="$bdbpfx $d"
654             for v in BerkeleyDB.4.3 BerkeleyDB.4.2 BerkeleyDB.4.1; do
655                 bdbpfx="$bdbpfx $d/$v"
656             done
657         done
658         BDB_VERSIONS="db-4 db4 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db ''"
659         AC_MSG_CHECKING([for BerkeleyDB > 4.0])
660         for d in $bdbpfx; do
661             BDB_INCLUDE_DIR=""
662             BDB_LIB_DIR=""
663             for v in / $BDB_VERSIONS; do
664                 if test -r "$d/include/$v/db.h"; then
665                     BDB_INCLUDE_DIR="$d/include/$v"
666                     if test -d "$d/lib/$v"; then
667                         BDB_LIB_DIR="$d/lib/$v"
668                         for l in `echo $BDB_VERSIONS`; do
669                             CPPFLAGS="-I$BDB_INCLUDE_DIR $OLDCPPFLAGS"
670                             LIBS="$OLDLIBS -L$BDB_LIB_DIR -l$l"
671                             AC_TRY_LINK([
672                                 #include <stdlib.h>
673                                 #include <db.h>
674                             ],[
675                                 DB *db = NULL;
676                                 db->open(db,NULL,NULL,NULL,0,0,0);
677                             ],[
678                                 ac_cv_dbcreate=yes
679                                 BDB_LIB="$l"
680                                 break
681                             ])
682                         done
683                         test x$ac_cv_dbcreate = xyes && break
684                     fi
685                 fi
686             done
687             test x$BDB_LIB != x && break
688         done
689         if test x$ac_cv_dbcreate = xyes; then
690             AC_MSG_RESULT(yes)
691         else
692             AC_MSG_RESULT(no)
693         fi
694     fi
695
696     if test x$ac_cv_vlopen = xyes; then
697         CPPFLAGS="$OLDCPPFLAGS $QDBM_INC"
698         LIBS="$OLDLIBS $QDBM_LIB -lqdbm"
699         AC_DEFINE(HAVE_QDBM, 1, [QDBM Support])
700     elif test x$ac_cv_gdbmopen = xyes; then
701         CPPFLAGS="$OLDCPPFLAGS $GDBM_INC"
702         LIBS="$OLDLIBS $GDBM_LIB -lgdbm";
703         AC_DEFINE(HAVE_GDBM, 1, [GDBM Support])
704     elif test x$ac_cv_dbcreate = xyes; then
705         CPPFLAGS="-I$BDB_INCLUDE_DIR $OLDCPPFLAGS"
706         LIBS="$OLDLIBS -L$BDB_LIB_DIR -l$BDB_LIB"
707         AC_DEFINE(HAVE_DB4, 1, [Sleepycat DB4 Support])
708     else
709         AC_MSG_ERROR([You need one of: QDBM, GDBM or Sleepycat DB4 for --enable-hcache])
710     fi
711 fi])
712 dnl -- end cache --
713
714 AC_SUBST(MUTTLIBS)
715 AC_SUBST(MUTT_LIB_OBJECTS)
716 AC_SUBST(LIBNNTP)
717 AC_SUBST(LIBNNTPDEPS)
718
719 dnl -- iconv/gettext --
720
721 AC_ARG_ENABLE(iconv, AC_HELP_STRING([--disable-iconv], [Disable iconv support]),
722         [if test x$enableval = xno ; then
723                 am_cv_func_iconv=no
724         fi
725 ])
726
727 AM_GNU_GETTEXT
728
729 if test "$am_cv_func_iconv" != "yes"
730 then
731   AC_MSG_WARN([Configuring without iconv support. See INSTALL for details])
732 else
733
734 AC_CHECK_HEADERS(iconv.h,
735         [AC_MSG_CHECKING(whether iconv.h defines iconv_t)
736          AC_EGREP_HEADER([typedef.*iconv_t],iconv.h,
737                 [AC_MSG_RESULT(yes)
738                  AC_DEFINE(HAVE_ICONV_T_DEF, 1,
739                         [Define if <iconv.h> defines iconv_t.])],
740                  AC_MSG_RESULT(no))])
741
742 dnl (1) Some implementations of iconv won't convert from UTF-8 to UTF-8.
743 dnl (2) In glibc-2.1.2 and earlier there is a bug that messes up ob and
744 dnl     obl when args 2 and 3 are 0 (fixed in glibc-2.1.3).
745 AC_CACHE_CHECK([whether this iconv is good enough], mutt_cv_iconv_good,
746         mutt_save_LIBS="$LIBS"
747         LIBS="$LIBS $LIBICONV"
748         AC_TRY_RUN([
749 #include <iconv.h>
750 int main()
751 {
752   iconv_t cd;
753 changequote(, )dnl
754   char buf[4];
755 changequote([, ])dnl
756   char *ob;
757   size_t obl;
758   ob = buf, obl = sizeof(buf);
759   return ((cd = iconv_open("UTF-8", "UTF-8")) != (iconv_t)(-1) &&
760           (iconv(cd, 0, 0, &ob, &obl) ||
761            !(ob == buf && obl == sizeof(buf)) ||
762            iconv_close(cd)));
763 }
764                 ],
765                 mutt_cv_iconv_good=yes,
766                 mutt_cv_iconv_good=no,
767                 mutt_cv_iconv_good=yes)
768         LIBS="$mutt_save_LIBS")
769 if test "$mutt_cv_iconv_good" = no; then
770   AC_MSG_ERROR(Try using libiconv instead)
771 fi
772
773 dnl This is to detect implementations such as the one in glibc-2.1,
774 dnl which always convert exactly but return the number of characters
775 dnl converted instead of the number converted inexactly.
776 AC_CACHE_CHECK([whether iconv is non-transcribing], mutt_cv_iconv_nontrans,
777         mutt_save_LIBS="$LIBS"
778         LIBS="$LIBS $LIBICONV"
779         AC_TRY_RUN([
780 #include <iconv.h>
781 #include <string.h>
782 int main()
783 {
784   iconv_t cd;
785   const char *ib;
786   char *ob;
787   size_t ibl, obl;
788   const char *s = "\304\211";
789 changequote(, )dnl
790   char t[3];
791 changequote([, ])dnl
792   ib = s, ibl = 2, ob = t, obl = 3;
793   return ((cd = iconv_open("UTF-8", "UTF-8")) == (iconv_t)(-1) ||
794           iconv(cd, &ib, &ibl, &ob, &obl));
795 }
796                 ],
797                 mutt_cv_iconv_nontrans=no,
798                 mutt_cv_iconv_nontrans=yes,
799                 mutt_cv_iconv_nontrans=no)
800         LIBS="$mutt_save_LIBS")
801 if test "$mutt_cv_iconv_nontrans" = yes; then
802   AC_DEFINE(ICONV_NONTRANS, 1)
803 else
804   AC_DEFINE(ICONV_NONTRANS, 0)
805 fi
806
807 CPPFLAGS="$CPPFLAGS -I\$(top_srcdir)/intl"
808
809 if test "$BUILD_INCLUDED_LIBINTL" = "yes"; then
810   AC_DEFINE(HAVE_BIND_TEXTDOMAIN_CODESET,1,
811           [ Define if your gettext has bind_textdomain_codeset. ])
812 else
813   AC_CHECK_FUNCS(bind_textdomain_codeset)
814 fi
815
816 fi # libiconv
817
818 dnl -- locales --
819
820 AC_CHECK_HEADERS(wchar.h)
821
822 AC_CACHE_CHECK([for wchar_t], mutt_cv_wchar_t,
823         AC_TRY_COMPILE([
824 #include <stddef.h>
825 #include <stdlib.h>
826 #ifdef HAVE_WCHAR_H
827 #include <wchar.h>
828 #endif
829                 ],
830                 [ wchar_t wc; return 0; ],
831                 mutt_cv_wchar_t=yes,
832                 mutt_cv_wchar_t=no))
833
834 if test "$mutt_cv_wchar_t" = no; then
835         AC_DEFINE(wchar_t,int,[ Define to 'int' if system headers don't define. ])
836 fi
837
838 AC_CACHE_CHECK([for wint_t], mutt_cv_wint_t,
839         AC_TRY_COMPILE([
840 #include <stddef.h>
841 #include <stdlib.h>
842 #ifdef HAVE_WCHAR_H
843 #include <wchar.h>
844 #endif
845                 ],
846                 [ wint_t wc; return 0; ],
847                 mutt_cv_wint_t=yes,
848                 mutt_cv_wint_t=no))
849
850 if test "$mutt_cv_wint_t" = no; then
851         AC_DEFINE(wint_t,int,[ Define to 'int' if system headers don't define. ])
852 fi
853
854 AC_CHECK_HEADERS(wctype.h)
855 AC_CHECK_FUNCS(iswalnum iswalpha  iswcntrl iswdigit)
856 AC_CHECK_FUNCS(iswgraph iswlower iswprint iswpunct iswspace iswupper)
857 AC_CHECK_FUNCS(iswxdigit towupper towlower)
858
859 AC_CACHE_CHECK([for mbstate_t], mutt_cv_mbstate_t,
860         AC_TRY_COMPILE([
861 #include <stddef.h>
862 #include <stdlib.h>
863 #ifdef HAVE_WCHAR_H
864 #include <wchar.h>
865 #endif
866                 ],
867                 [ mbstate_t s; return 0; ],
868                 mutt_cv_mbstate_t=yes,
869                 mutt_cv_mbstate_t=no))
870
871 if test "$mutt_cv_mbstate_t" = no; then
872         AC_DEFINE(mbstate_t,int,[ Define to 'int' if system headers don't define. ])
873 fi
874
875 wc_funcs=maybe
876 AC_ARG_WITH(wc-funcs, AC_HELP_STRING([--without-wc-funcs], [Do not use the system's wchar_t functions]),
877         wc_funcs=$withval)
878
879 if test "$wc_funcs" != yes -a "$wc_funcs" != no; then
880         AC_CACHE_CHECK([for wchar_t functions], mutt_cv_wc_funcs,
881                 mutt_cv_wc_funcs=no
882                 AC_TRY_LINK([
883 #define _XOPEN_SOURCE 1
884 #include <stddef.h>
885 #include <stdlib.h>
886 #ifdef HAVE_WCTYPE_H
887 #include <wctype.h>
888 #endif
889 #ifdef HAVE_WCHAR_H
890 #include <wchar.h>
891 #endif],
892                         [mbrtowc(0, 0, 0, 0); wctomb(0, 0); wcwidth(0);
893         iswprint(0); iswspace(0); towlower(0); towupper(0); iswalnum(0)],
894                         mutt_cv_wc_funcs=yes))
895         wc_funcs=$mutt_cv_wc_funcs
896 fi
897
898 if test $wc_funcs = yes; then
899         AC_DEFINE(HAVE_WC_FUNCS,1,[ Define if you are using the system's wchar_t functions. ])
900 fi
901
902 AC_CACHE_CHECK([for nl_langinfo and CODESET], mutt_cv_langinfo_codeset,
903   [AC_TRY_LINK([#include <langinfo.h>],
904     [char* cs = nl_langinfo(CODESET);],
905     mutt_cv_langinfo_codeset=yes,
906     mutt_cv_langinfo_codeset=no)])
907 if test $mutt_cv_langinfo_codeset = yes; then
908   AC_DEFINE(HAVE_LANGINFO_CODESET,1,[ Define if you have <langinfo.h> and nl_langinfo(CODESET). ])
909 fi
910
911 AC_CACHE_CHECK([for nl_langinfo and YESEXPR], mutt_cv_langinfo_yesexpr,
912   [AC_TRY_LINK([#include <langinfo.h>],
913     [char* cs = nl_langinfo(YESEXPR);],
914     mutt_cv_langinfo_yesexpr=yes,
915     mutt_cv_langinfo_yesexpr=no)])
916 if test $mutt_cv_langinfo_yesexpr = yes; then
917   AC_DEFINE(HAVE_LANGINFO_YESEXPR,1,[ Define if you have <langinfo.h> and nl_langinfo(YESEXPR). ])
918 fi
919
920 dnl -- libesmtp --
921 MUTT_AM_LIBESMTP
922 if test x$use_libesmtp = xyes; then
923     CFLAGS="$CFLAGS $mutt_libesmtp_cflags"
924     MUTTLIBS="$MUTTLIBS $mutt_libesmtp_libs"
925     MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS mutt_libesmtp.o"
926
927     AC_DEFINE(USE_LIBESMTP,
928               1,
929               [Define to enable the use of libesmtp])
930 fi
931 dnl -- end libesmtp --
932
933 dnl -- sgml tools --
934
935 dnl Documentation tools
936 have_openjade="no"
937 AC_PATH_PROG([OSPCAT], [ospcat], [none])
938 if test "$OSPCAT" != "none"
939 then
940   AC_MSG_CHECKING([for openjade docbook stylesheets])
941   dslosfile=`ospcat --public-id="-//Norman Walsh//DOCUMENT DocBook Print Stylesheet//EN"`
942   DSLROOT=`echo $dslosfile | sed -n -e "s/.*SOIBASE='\(@<:@^'@:>@*\)\/catalog'.*/\1/p"`
943   # ospcat may spit out an absolute path without an SOIBASE
944   if test -z "$DSLROOT"
945   then
946     DSLROOT=`echo $dslosfile | sed -e 's|<OSFILE>\(.*\)/print/docbook.dsl|\1|'`
947   fi
948   if test -f $DSLROOT/print/docbook.dsl
949   then
950     AC_MSG_RESULT([in $DSLROOT])
951     have_openjade="yes"
952   else
953     AC_MSG_RESULT([not found: PDF documentation will not be built.])
954   fi
955 fi
956 AC_SUBST(DSLROOT)
957
958 AC_MSG_CHECKING([for lynx])
959 AC_PATH_PROG([HTML2TXT_CMD], [lynx], [none])
960 if test x"$HTML2TXT_CMD" = x"none"
961 then
962   AC_MSG_CHECKING([for w3m])
963   AC_PATH_PROG([HTML2TXT_CMD], [w3m], [none])
964 fi
965 if test x"$HTML2TXT_CMD" = x"none"
966 then
967   AC_MSG_CHECKING([for elinks])
968   AC_PATH_PROG([HTML2TXT_CMD], [elinks], [none])
969 fi
970 case "$HTML2TXT_CMD" in
971   *elinks*)
972     HTML2TXT_CMD="$HTML2TXT_CMD -dump -no-numbering -no-references \$^ > \$@"
973     ;;
974   *lynx*)
975     HTML2TXT_CMD="$HTML2TXT_CMD -dump -nolist -with_backspaces \$^ > \$@"
976     ;;
977   *w3m*)
978     HTML2TXT_CMD="$HTML2TXT_CMD -dump \$^ > \$@"
979     ;;
980   *)
981     HTML2TXT_CMD="true"
982     ;;
983 esac
984 AC_SUBST(HTML2TXT_CMD)
985
986 AC_MSG_CHECKING([for tidy])
987 AC_PATH_PROG([HTMLCLEAN_CMD], [tidy], [none])
988
989 if test x"$HTMLCLEAN_CMD" != x"none"
990 then
991   HTMLCLEAN_CMD="$HTMLCLEAN_CMD -q -i -m -asxml -utf8 "
992 else
993   HTMLCLEAN_CMD="echo "
994 fi
995 AC_SUBST(HTMLCLEAN_CMD)
996
997 AC_OUTPUT(Makefile intl/Makefile m4/Makefile
998         po/Makefile.in doc/Makefile contrib/Makefile
999         muttbug.sh
1000         lib-lib/Makefile
1001         lib-mime/Makefile
1002         lib-crypt/Makefile
1003         lib-hash/Makefile
1004         lib/Makefile
1005         imap/Makefile
1006         pop/Makefile
1007         nntp/Makefile
1008         Muttngrc.head
1009         doc/instdoc.sh)