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