rework some things with sasl.
[apps/madmutt.git] / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2
3 dnl !!! WHEN ADDING NEW CONFIGURE TESTS, PLEASE ADD CODE TO MAIN.C !!!
4 dnl !!! TO DUMP THEIR RESULTS WHEN MUTT -V IS CALLED            !!!
5
6 AC_PREREQ([2.50])
7 AC_INIT([mutt.h])
8 AM_CONFIG_HEADER(config.h)
9 AM_INIT_AUTOMAKE(madmutt, devel)
10
11 AC_GNU_SOURCE
12
13 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"
14
15 AC_CANONICAL_HOST
16
17 AC_PROG_CPP
18 AC_PROG_CC_C99
19 AC_ISC_POSIX
20 AC_HEADER_STDC
21
22 PKG_PROG_PKG_CONFIG
23 AC_PROG_MAKE_SET
24 AC_PROG_INSTALL
25 AC_PROG_RANLIB
26 AC_PROG_GPERF
27 AC_PATH_PROG(GPERF, gperf, AC_MSG_ERROR([Could not find gperf]))
28 AC_CHECK_TOOL(AR, ar, ar)
29
30 AC_SYS_LARGEFILE
31 AC_FUNC_FSEEKO
32 AC_CHECK_SIZEOF(off_t)
33
34 AH_TEMPLATE([sig_atomic_t],
35             [Define to 'int' if <signal.h> doesn't define.])
36 AH_TEMPLATE([HAVE_START_COLOR],
37             [Define if you have start_color, as a function or macro.])
38 AH_TEMPLATE([HAVE_TYPEAHEAD],
39             [Define if you have typeahead, as a function or macro.])
40 AH_TEMPLATE([HAVE_BKGDSET],
41             [Define if you have bkgdset, as a function or macro.])
42 AH_TEMPLATE([HAVE_CURS_SET],
43             [Define if you have curs_set, as a function or macro.])
44 AH_TEMPLATE([HAVE_META],
45             [Define if you have meta, as a function or macro.])
46 AH_TEMPLATE([HAVE_USE_DEFAULT_COLORS],
47             [Define if you have use_default_colors, as a function or macro.])
48 AH_TEMPLATE([HAVE_RESIZETERM],
49             [Define if you have resizeterm, as a function or macro.])
50 AH_TEMPLATE([SIG_ATOMIC_VOLATILE_T],
51             [Some systems declare sig_atomic_t as volatile, some others -- no.
52              This define will have value `sig_atomic_t' or
53              `volatile sig_atomic_t' accordingly.])
54
55 dnl ---------------- sendmail ----------------
56
57 ac_aux_path_sendmail=/usr/sbin:/usr/lib
58 AC_PATH_PROG(SENDMAIL, sendmail, /usr/sbin/sendmail, $PATH:$ac_aux_path_sendmail)
59 AC_DEFINE_UNQUOTED(SENDMAIL,"$ac_cv_path_SENDMAIL",[ Where to find sendmail on your system. ])
60
61 dnl ---------------- lua5.1 ----------------
62 PKG_CHECK_MODULES(LUA,lua5.1,[
63     CPPFLAGS="$CPPFLAGS $LUA_CFLAGS"
64     MUTTLIBS="$MUTTLIBS $LUA_LIBS"
65 ],[AC_MSG_ERROR([could not find lua5.1])])
66
67 dnl ---------------- gpgme ----------------
68
69 AC_ARG_ENABLE(gpgme, AC_HELP_STRING([--enable-gpgme], [Enable GPGME support]),[
70     if test x$enableval = xyes; then
71         AM_PATH_GPGME(,,[AC_MSG_ERROR(GPGME not found)])
72         MUTTLIBS="$MUTTLIBS $GPGME_LIBS"
73         AC_DEFINE(CRYPT_BACKEND_GPGME, 1, [Defined, if GPGME support is enabled])
74     else
75         AC_MSG_ERROR([could not find gpgme])
76     fi
77 ])
78
79 AC_PATH_PROG(MIXMASTER, mixmaster, mixmaster)
80 AC_DEFINE_UNQUOTED(MIXMASTER,"$MIXMASTER",[Where to find mixmaster on your system.])
81
82 AC_ARG_WITH(slang, AC_HELP_STRING([--with-slang[=DIR]], [Use S-Lang instead of ncurses]),
83     [AC_CACHE_CHECK([if this is a BSD system], mutt_cv_bsdish,
84         [AC_TRY_RUN([#include <sys/param.h>
85
86 main ()
87 {
88 #ifdef BSD
89         exit (0);
90 #else
91         exit (1);
92 #endif
93 }],
94         mutt_cv_bsdish=yes,
95         mutt_cv_bsdish=no,
96         mutt_cv_bsdish=no)])
97
98         AC_MSG_CHECKING(for S-Lang)
99         if test $withval = yes; then
100             if test -d $srcdir/../slang; then
101                 mutt_cv_slang=$srcdir/../slang/src
102                 CFLAGS="$CFLAGS -I${mutt_cv_slang}"
103                 MUTTLIBS="$MUTTLIBS -L${mutt_cv_slang}/objs"
104             else
105                 if test -d ${prefix}/include/slang; then
106                     CFLAGS="$CFLAGS -I${prefix}/include/slang"
107                 elif test -d /usr/include/slang; then
108                     CFLAGS="$CFLAGS -I/usr/include/slang"
109                 fi
110                 mutt_cv_slang=yes
111             fi
112         else
113             dnl ---Check to see if $withval is a source directory
114             if test -f $withval/src/slang.h; then
115                 mutt_cv_slang=$withval/src
116                 CFLAGS="$CFLAGS -I${mutt_cv_slang}"
117                 MUTTLIBS="$MUTTLIBS -L${mutt_cv_slang}/objs"
118             else
119                 dnl ---Must be installed somewhere
120                 mutt_cv_slang=$withval
121                 if test -d $withval/include/slang; then
122                         CFLAGS="$CFLAGS -I${withval}/include/slang"
123                 elif test -d $withval/include; then
124                         CFLAGS="$CFLAGS -I${withval}/include"
125                 fi
126                 MUTTLIBS="$MUTTLIBS -L${withval}/lib"
127             fi
128         fi
129         AC_MSG_RESULT($mutt_cv_slang)
130         if test $mutt_cv_bsdish = yes; then
131             AC_CHECK_LIB(termlib, main)
132         fi
133         AC_DEFINE(USE_SLANG_CURSES,1, [ Define if you compile with SLang instead of curses/ncurses. ])
134
135         dnl --- now that we've found it, check the link
136
137         AC_CHECK_LIB(slang, SLtt_get_terminfo,
138             [MUTTLIBS="$MUTTLIBS -lslang -lm"],
139             [AC_MSG_ERROR(unable to compile.  check config.log)], -lm)
140     ],
141     [   mutt_cv_curses=/usr
142         AC_ARG_WITH(curses, AC_HELP_STRING([--with-curses=DIR], [Where ncurses is installed]), [
143             if test $withval != yes; then
144                 mutt_cv_curses=$withval
145             fi
146             if test x$mutt_cv_curses != x/usr; then
147                 MUTTLIBS="-L${mutt_cv_curses}/lib $MUTTLIBS"
148                 CPPFLAGS="$CPPFLAGS -I${mutt_cv_curses}/include"
149             fi
150         ])
151
152         AC_CHECK_FUNC(initscr,,[
153         cf_ncurses="ncurses"
154         for lib in ncursesw ncurses; do
155             AC_CHECK_LIB($lib, waddnwstr, [cf_ncurses="$lib"; break])
156         done
157         AC_CHECK_LIB($cf_ncurses, initscr,
158             [   MUTTLIBS="$MUTTLIBS -l$cf_ncurses"
159                 if test x$mutt_cv_curses = x/usr -a -d /usr/include/ncurses; then
160                     CPPFLAGS="$CPPFLAGS -I/usr/include/ncurses"
161                 fi
162
163                 if test "$cf_ncurses" = ncursesw; then
164                     AC_CHECK_HEADERS(ncurses/ncurses.h,[cf_cv_ncurses_header="ncurses/ncurses.h"])
165                     AC_CHECK_HEADERS(ncursesw/ncurses.h,[cf_cv_ncurses_header="ncursesw/ncurses.h"])
166                 else
167                     AC_CHECK_HEADERS(ncurses.h,[cf_cv_ncurses_header="ncurses.h"])
168                 fi
169             ],
170             [CF_CURSES_LIBS])
171         ])
172
173         LIBS="$MUTTLIBS"
174         CF_CHECK_FUNCDECLS([#include <${cf_cv_ncurses_header-curses.h}>],
175                            [start_color typeahead bkgdset curs_set meta use_default_colors resizeterm])
176         if test "$ac_cv_func_decl_start_color" != yes; then
177             AC_MSG_ERROR([Your curses library does not supports color.])
178         fi
179         LIBS=""
180     ])
181
182 AC_CHECK_HEADERS(stdarg.h sys/ioctl.h ioctl.h sysexits.h)
183 AC_CHECK_HEADERS(sys/time.h sys/resource.h)
184 AC_CHECK_HEADERS(unix.h)
185
186 AC_CHECK_FUNCS(setrlimit getsid isctype)
187
188 AC_TYPE_SIGNAL
189
190 AC_MSG_CHECKING(for sig_atomic_t in signal.h)
191 AC_EGREP_HEADER(sig_atomic_t,signal.h,
192     [   ac_cv_type_sig_atomic_t=yes;
193         AC_EGREP_HEADER(volatile.*sig_atomic_t,
194                         signal.h,
195                         [is_sig_atomic_t_volatile=yes; AC_MSG_RESULT([yes, volatile])],
196                         [is_sig_atomic_t_volatile=no;  AC_MSG_RESULT([yes, non volatile])])
197     ],
198     [   AC_MSG_RESULT(no)
199         AC_CHECK_TYPE(sig_atomic_t, int)
200         is_sig_atomic_t_volatile=no
201     ])
202 if test $is_sig_atomic_t_volatile = 'yes'
203 then
204     AC_DEFINE(SIG_ATOMIC_VOLATILE_T, sig_atomic_t)
205 else
206     AC_DEFINE(SIG_ATOMIC_VOLATILE_T, [volatile sig_atomic_t])
207 fi
208
209 AC_DECL_SYS_SIGLIST
210 AC_TYPE_PID_T
211
212 AC_CHECK_FUNC(getopt)
213 if test $ac_cv_func_getopt = yes; then
214     AC_CHECK_HEADERS(getopt.h)
215 fi
216
217 AC_CHECK_FUNC(regcomp)
218 if test $ac_cv_func_regcomp = yes; then
219    AC_CHECK_HEADERS(regex.h)
220 fi
221
222 AC_ARG_WITH(homespool,
223             AC_HELP_STRING([--with-homespool[=FILE]],
224                            [File in user's directory where new mail is spooled]),
225                            with_homespool=${withval})
226 if test x$with_homespool != x; then
227     if test $with_homespool = yes; then
228             with_homespool=mailbox
229     fi
230     AC_DEFINE_UNQUOTED(MAILPATH,"$with_homespool",[ Where new mail is spooled. ])
231     AC_DEFINE(HOMESPOOL,1,
232     [   Is mail spooled to the user's home directory?  If defined,
233         MAILPATH should be set to the filename of the spool mailbox
234         relative the the home directory.
235         use: configure --with-homespool=FILE
236     ])
237     mutt_cv_setgid=no
238 else
239     AC_ARG_WITH(mailpath, AC_HELP_STRING([--with-mailpath=DIR], [Directory where spool mailboxes are located]),
240         [mutt_cv_mailpath=$withval],
241         [ AC_CACHE_CHECK(where new mail is stored, mutt_cv_mailpath,
242             [mutt_cv_mailpath=no
243             if test -d /var/mail; then
244                 mutt_cv_mailpath=/var/mail
245             elif test -d /var/spool/mail; then
246                 mutt_cv_mailpath=/var/spool/mail
247             elif test -d /usr/spool/mail; then
248                 mutt_cv_mailpath=/usr/spool/mail
249             elif test -d /usr/mail; then
250                 mutt_cv_mailpath=/usr/mail
251             fi])
252         ])
253     if test "$mutt_cv_mailpath" = no; then
254         AC_MSG_ERROR("Could not determine where new mail is stored.")
255     fi
256     AC_DEFINE_UNQUOTED(MAILPATH,"$mutt_cv_mailpath",[ Where new mail is spooled. ])
257
258     AC_CACHE_CHECK(if $mutt_cv_mailpath is world writable, mutt_cv_worldwrite, [AC_TRY_RUN([#include <sys/types.h>
259 #include <sys/stat.h>
260
261 int main (int argc, char **argv)
262 {
263         struct stat s;
264
265         stat ("$mutt_cv_mailpath", &s);
266         if (s.st_mode & S_IWOTH) exit (0);
267         exit (1);
268 }], mutt_cv_worldwrite=yes, mutt_cv_worldwrite=no, mutt_cv_worldwrite=no)])
269
270         mutt_cv_setgid=no
271         if test $mutt_cv_worldwrite != yes; then
272                 AC_CACHE_CHECK(if $mutt_cv_mailpath is group writable, mutt_cv_groupwrite, [AC_TRY_RUN([#include <sys/types.h>
273 #include <sys/stat.h>
274
275 int main (int argc, char **argv)
276 {
277         struct stat s;
278
279         stat ("$mutt_cv_mailpath", &s);
280         if (s.st_mode & S_IWGRP) exit (0);
281         exit (1);
282 }], mutt_cv_groupwrite=yes, mutt_cv_groupwrite=no, mutt_cv_groupwrite=no)])
283
284         if test $mutt_cv_groupwrite = yes; then
285             AC_DEFINE(USE_SETGID,1,[ Define if mutt should run setgid "mail". ])
286             mutt_cv_setgid=yes
287         fi
288     fi
289 fi
290
291 AC_MSG_CHECKING(where to put the documentation)
292 AC_ARG_WITH(docdir, AC_HELP_STRING([--with-docdir=PATH], [Specify where to put the documentation]),
293         [mutt_cv_docdir=$withval],
294         [mutt_cv_docdir="${prefix}/doc/madmutt"])
295 AC_MSG_RESULT($mutt_cv_docdir)
296
297 docdir=$mutt_cv_docdir
298 AC_SUBST(docdir)
299
300 if test x$mutt_cv_setgid = xyes; then
301     DOTLOCK_GROUP='mail'
302     DOTLOCK_PERMISSION=2755
303 else
304     DOTLOCK_GROUP=''
305     DOTLOCK_PERMISSION=755
306 fi
307 AC_SUBST(DOTLOCK_GROUP)
308 AC_SUBST(DOTLOCK_PERMISSION)
309
310 dnl -- socket dependencies --
311
312 AC_ARG_ENABLE(nntp, AC_HELP_STRING([--enable-nntp],[Enable NNTP support]),[
313     if test x$enableval = xyes ; then
314         AC_DEFINE(USE_NNTP,1,[ Compiling with newsreading support with NNTP ])
315         LIBNNTP="-Lnntp -lnntp"
316         LIBNNTPDEPS="\$(top_srcdir)/nntp/nntp.h nntp/libnntp.a"
317         need_nntp="yes"
318     fi
319 ])
320 AM_CONDITIONAL(BUILD_NNTP, test x$need_nntp = xyes)
321
322 AC_MSG_CHECKING([for socklen_t])
323 AC_EGREP_HEADER(socklen_t, sys/socket.h, AC_MSG_RESULT([yes]),
324         AC_MSG_RESULT([no])
325         AC_DEFINE(socklen_t,int, [ Define to 'int' if <sys/socket.h> doesn't have it. ]))
326 AC_CHECK_FUNC(gethostent,,AC_CHECK_LIB(nsl, gethostent))
327 AC_CHECK_FUNC(setsockopt,,AC_CHECK_LIB(socket, setsockopt))
328 AC_CHECK_FUNC(getaddrinfo,,[AC_MSG_ERROR([cannot find getaddrinfo])])
329
330 dnl -- imap dependencies --
331
332 AM_PATH_LIBGNUTLS(,[
333     CPPFLAGS="$CPPFLAGS $LIBGNUTLS_CFLAGS"
334     MUTTLIBS="$MUTTLIBS $LIBGNUTLS_LIBS"],[AC_MSG_ERROR([could not find libgnutls])
335 ])
336
337 AC_CHECK_LIB(sasl2, sasl_client_init,,AC_MSG_ERROR([could not find libsasl2]))
338 MUTTLIBS="$MUTTLIBS $LIBS"
339 LIBS=""
340
341 AC_ARG_WITH(idn, AC_HELP_STRING([--with-idn], [Use GNU libidn for domain names]),[
342     if test x$with_idn != xno ; then
343         PKG_CHECK_MODULES(IDN,libidn,[
344             if $PKG_CONFIG --atleast-version=0.6; then
345                 AC_MSG_ERROR([libidn is too old, want 0.6 at least])
346             fi
347             CPPFLAGS="$CPPFLAGS $IDN_CFLAGS"
348             MUTTLIBS="$MUTTLIBS $IDN_LIBS"
349             AC_DEFINE(HAVE_LIBIDN, 1, [IDN Support])
350         ],[AC_MSG_ERROR([could not find libidn])])
351     fi
352 ])
353
354 dnl -- end socket --
355
356 AC_ARG_ENABLE(flock, AC_HELP_STRING([--enable-flock], [Use flock() to lock files]),
357         [if test $enableval = yes; then
358                 AC_DEFINE(USE_FLOCK,1, [ Define to use flock() to lock mailboxes. ])
359         fi])
360
361 mutt_cv_fcntl=yes
362 AC_ARG_ENABLE(fcntl, AC_HELP_STRING([--disable-fcntl], [Do NOT use fcntl() to lock files]),
363         [if test $enableval = no; then mutt_cv_fcntl=no; fi])
364
365 if test $mutt_cv_fcntl = yes; then
366         AC_DEFINE(USE_FCNTL,1, [ Define to use fcntl() to lock folders. ])
367 fi
368
369 AC_MSG_CHECKING(whether struct dirent defines d_ino)
370 ac_cv_dirent_d_ino=no
371 AC_TRY_LINK([#include <dirent.h>],[struct dirent dp; (void)dp.d_ino],[ac_cv_dirent_d_ino=yes])
372 if test x$ac_cv_dirent_d_ino = xyes ; then
373   AC_DEFINE(HAVE_DIRENT_D_INO,1,
374             [Define to 1 if your system has the dirent::d_ino member])
375 fi
376 AC_MSG_RESULT($ac_cv_dirent_d_ino)
377
378 dnl -- start cache --
379 AC_ARG_ENABLE(hcache, AC_HELP_STRING([--enable-hcache], [Enable header caching]),
380 [if test x$enableval = xyes; then
381     AC_DEFINE(USE_HCACHE, 1, [Enable header caching])
382     OLDCPPFLAGS="$CPPFLAGS"
383     need_md5="yes"
384
385     ac_prefer_qdbm=yes
386     AC_ARG_WITH(qdbm, AC_HELP_STRING([--without-qdbm], [Don't use qdbm even if it is available]),
387         ac_prefer_qdbm=$withval)
388     if test x$ac_prefer_qdbm != xno; then
389         PKG_CHECK_MODULES(QDBM,qdbm,[ac_qdbm_here=yes],[ac_qdbm_here=no])
390     fi
391
392     ac_prefer_gdbm=yes
393     AC_ARG_WITH(gdbm, AC_HELP_STRING([--without-gdbm], [Don't use gdbm even if it is available]),
394         ac_prefer_gdbm=$withval)
395     if test x$ac_prefer_gdbm != xno -a x$ac_qdbm_here != xyes; then
396         ac_cv_gdbmopen=no
397         GDBM_DIRS="${prefix} /usr/local /usr"
398         AC_MSG_CHECKING([for gdbm_open])
399         for d in $GDBM_DIRS; do
400           if test x$ac_cv_gdbmopen = xno && test -d "$d/include" && test -d "$d/lib"; then
401             GDBM_INC="-I$d/include"
402             GDBM_LIB="-L$d/lib"
403             CPPFLAGS="$OLDCPPFLAGS $GDBM_INC"
404             LIBS="$MUTTLIBS $GDBM_LIB -lgdbm"
405             AC_TRY_LINK([#include <gdbm.h>],[gdbm_open(0,0,0,0,0);],[ac_cv_gdbmopen=yes])
406           fi
407         done
408         if test x$ac_cv_gdbmopen = xyes; then
409           AC_MSG_RESULT(yes)
410         else
411           AC_MSG_RESULT(no)
412         fi
413     fi
414
415     ac_bdb_prefix=yes
416     AC_ARG_WITH(bdb, AC_HELP_STRING([--with-bdb[=DIR]], [Use BerkeleyDB4 if gdbm is not available ]),
417         ac_bdb_prefix=$withval)
418     if test x$ac_bdb_prefix != xno -a x$ac_cv_gdbmopen != xyes -a x$ac_qdbm_here != xyes; then
419         test x$ac_bdb_prefix = xyes && ac_bdb_prefix="${prefix} /opt/csw/bdb4 /opt /usr/local /usr"
420         for d in $ac_bdb_prefix; do
421             bdbpfx="$bdbpfx $d"
422             for v in BerkeleyDB.4.3 BerkeleyDB.4.2 BerkeleyDB.4.1; do
423                 bdbpfx="$bdbpfx $d/$v"
424             done
425         done
426         BDB_VERSIONS="db-4 db4 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db ''"
427         AC_MSG_CHECKING([for BerkeleyDB > 4.0])
428         for d in $bdbpfx; do
429             BDB_INCLUDE_DIR=""
430             BDB_LIB_DIR=""
431             for v in / $BDB_VERSIONS; do
432                 if test -r "$d/include/$v/db.h"; then
433                     BDB_INCLUDE_DIR="$d/include/$v"
434                     if test -d "$d/lib/$v"; then
435                         BDB_LIB_DIR="$d/lib/$v"
436                         for l in `echo $BDB_VERSIONS`; do
437                             CPPFLAGS="-I$BDB_INCLUDE_DIR $OLDCPPFLAGS"
438                             LIBS="$MUTTLIBS -L$BDB_LIB_DIR -l$l"
439                             AC_TRY_LINK([
440                                 #include <stdlib.h>
441                                 #include <db.h>
442                             ],[
443                                 DB *db = NULL;
444                                 db->open(db,NULL,NULL,NULL,0,0,0);
445                             ],[
446                                 ac_cv_dbcreate=yes
447                                 BDB_LIB="$l"
448                                 break
449                             ])
450                         done
451                         test x$ac_cv_dbcreate = xyes && break
452                     fi
453                 fi
454             done
455             test x$BDB_LIB != x && break
456         done
457         if test x$ac_cv_dbcreate = xyes; then
458             AC_MSG_RESULT(yes)
459         else
460             AC_MSG_RESULT(no)
461         fi
462     fi
463
464     if test x$ac_qdbm_here = xyes; then
465         CPPFLAGS="$OLDCPPFLAGS $QDBM_CFLAGS"
466         MUTTLIBS="$MUTTLIBS $QDBM_LIBS"
467         AC_DEFINE(HAVE_QDBM, 1, [QDBM Support])
468     elif test x$ac_cv_gdbmopen = xyes; then
469         CPPFLAGS="$OLDCPPFLAGS $GDBM_INC"
470         MUTTLIBS="$MUTTLIBS $GDBM_LIB -lgdbm";
471         AC_DEFINE(HAVE_GDBM, 1, [GDBM Support])
472     elif test x$ac_cv_dbcreate = xyes; then
473         CPPFLAGS="-I$BDB_INCLUDE_DIR $OLDCPPFLAGS"
474         MUTTLIBS="$MUTTLIBS -L$BDB_LIB_DIR -l$BDB_LIB"
475         AC_DEFINE(HAVE_DB4, 1, [Sleepycat DB4 Support])
476     else
477         AC_MSG_ERROR([You need one of: QDBM, GDBM or Sleepycat DB4 for --enable-hcache])
478     fi
479     LIBS=""
480 fi])
481 dnl -- end cache --
482
483 AC_SUBST(MUTTLIBS)
484 AC_SUBST(LIBNNTP)
485 AC_SUBST(LIBNNTPDEPS)
486
487 dnl -- iconv/gettext --
488
489 AC_ARG_ENABLE(iconv, AC_HELP_STRING([--disable-iconv], [Disable iconv support]),
490         [if test x$enableval = xno ; then
491                 am_cv_func_iconv=no
492         fi
493 ])
494
495 AM_GNU_GETTEXT
496
497 if test "$am_cv_func_iconv" != "yes"; then
498     AC_MSG_WARN([Configuring without iconv support. See INSTALL for details])
499 else
500
501     AC_CHECK_HEADERS(iconv.h,
502         [AC_MSG_CHECKING(whether iconv.h defines iconv_t)
503          AC_EGREP_HEADER([typedef.*iconv_t],iconv.h,
504                 [AC_MSG_RESULT(yes)
505                  AC_DEFINE(HAVE_ICONV_T_DEF, 1,
506                         [Define if <iconv.h> defines iconv_t.])],
507                  AC_MSG_RESULT(no))])
508
509     dnl (1) Some implementations of iconv won't convert from UTF-8 to UTF-8.
510     dnl (2) In glibc-2.1.2 and earlier there is a bug that messes up ob and
511     dnl     obl when args 2 and 3 are 0 (fixed in glibc-2.1.3).
512     AC_CACHE_CHECK([whether this iconv is good enough], mutt_cv_iconv_good,
513                    LIBS="$LIBICONV"
514                    AC_TRY_RUN([
515 #include <iconv.h>
516 int main()
517 {
518   iconv_t cd;
519 changequote(, )dnl
520   char buf[4];
521 changequote([, ])dnl
522   char *ob;
523   size_t obl;
524   ob = buf, obl = sizeof(buf);
525   return ((cd = iconv_open("UTF-8", "UTF-8")) != (iconv_t)(-1) &&
526           (iconv(cd, 0, 0, &ob, &obl) ||
527            !(ob == buf && obl == sizeof(buf)) ||
528            iconv_close(cd)));
529 }
530                    ],
531                    mutt_cv_iconv_good=yes,
532                    mutt_cv_iconv_good=no,
533                    mutt_cv_iconv_good=yes)
534                    LIBS="")
535     if test "$mutt_cv_iconv_good" = no; then
536         AC_MSG_ERROR(Try using libiconv instead)
537     fi
538
539 fi # libiconv
540
541 dnl -- locales --
542
543 AC_CHECK_HEADERS(locale.h wchar.h wctype.h)
544 AC_CHECK_FUNCS(iswalnum iswalpha  iswcntrl iswdigit)
545 AC_CHECK_FUNCS(iswgraph iswlower iswprint iswpunct iswspace iswupper)
546 AC_CHECK_FUNCS(iswxdigit towupper towlower)
547 AC_TYPE_MBSTATE_T
548
549 AC_CACHE_CHECK([for nl_langinfo and CODESET], mutt_cv_langinfo_codeset,
550                [AC_TRY_LINK([#include <langinfo.h>],
551                             [char* cs = nl_langinfo(CODESET);],
552                             mutt_cv_langinfo_codeset=yes,
553                             mutt_cv_langinfo_codeset=no)])
554 if test $mutt_cv_langinfo_codeset = yes; then
555     AC_DEFINE(HAVE_LANGINFO_CODESET,1,
556               [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
557 fi
558
559 AC_CACHE_CHECK([for nl_langinfo and YESEXPR], mutt_cv_langinfo_yesexpr,
560                [AC_TRY_LINK([#include <langinfo.h>],
561                             [char* cs = nl_langinfo(YESEXPR);],
562                             mutt_cv_langinfo_yesexpr=yes,
563                             mutt_cv_langinfo_yesexpr=no)])
564 if test $mutt_cv_langinfo_yesexpr = yes; then
565     AC_DEFINE(HAVE_LANGINFO_YESEXPR,1,
566               [Define if you have <langinfo.h> and nl_langinfo(YESEXPR).])
567 fi
568
569 dnl -- libesmtp --
570 MUTT_AM_LIBESMTP
571 if test x$use_libesmtp = xyes; then
572     CFLAGS="$CFLAGS $mutt_libesmtp_cflags"
573     MUTTLIBS="$MUTTLIBS -lesmtp"
574     AC_DEFINE(USE_LIBESMTP, 1, [Define to enable the use of libesmtp])
575 fi
576 dnl -- end libesmtp --
577
578 AC_ARG_ENABLE(doc, [  --enable-doc            build documentation (needs doxygen and LaTeX)])
579 # Build documentation?
580 DOXYGEN="no"
581 LATEX="no"
582 if test "${enable_doc}" != "no"; then
583     AC_PATH_PROG(DOXYGEN, doxygen, no)
584     if test "${DOXYGEN}" != "no"; then
585         # Build LaTeX documentation?
586         AC_PATH_PROG(LATEX, pdflatex, no)
587         AC_PATH_PROG(DVIPS, dvips, no)
588         if test "${DVIPS}" = "no"; then
589             LATEX="no"
590         fi
591         AC_MSG_CHECKING(for a4wide.sty)
592         if test -f /usr/share/texmf/tex/latex/misc/a4wide.sty; then
593             AC_MSG_RESULT(yes)
594         elif test -f /usr/share/texmf-tetex/tex/latex/a4wide/a4wide.sty; then
595             AC_MSG_RESULT(yes)
596         else
597             LATEX="no"
598             AC_MSG_RESULT(no)
599         fi
600     fi
601 fi
602 AM_CONDITIONAL(BUILD_DOCUMENTATION, test "${DOXYGEN}" != "no")
603 AM_CONDITIONAL(USE_LATEX, test "${LATEX}" != "no")
604
605 AC_OUTPUT(Makefile
606           intl/Makefile
607           m4/Makefile
608           po/Makefile.in
609           apidoc/Makefile apidoc/doxygen.cfg
610           lib-lib/Makefile
611           lib-lua/Makefile
612           lib-mime/Makefile
613           lib-hash/Makefile
614           lib-mx/Makefile
615           lib-sys/Makefile
616           lib-ui/Makefile
617           imap/Makefile
618           pop/Makefile
619           nntp/Makefile
620 )