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