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