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