fix idn support properly
[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 AC_ARG_WITH(gss, AC_HELP_STRING([--with-gss], [Compile in GSSAPI authentication for IMAP]),[
336     if test x$with_gss != xno; then
337         PKG_CHECK_MODULES(GSSAPI,libgssapi,[
338             CPPFLAGS="$CPPFLAGS $GSSAPI_CFLAGS"
339             MUTTLIBS="$MUTTLIBS $GSSAPI_LIBS"
340             AC_DEFINE(USE_GSS,1,[ Define if you have GSSAPI libraries available ])
341             AC_CHECK_HEADERS(xom.h)
342         ],[
343            AC_MSG_ERROR([could not find libgssapi])
344         ])
345     fi
346 ])
347
348 AC_ARG_WITH(ssl, AC_HELP_STRING([--with-ssl[=PFX]], [Compile in SSL support for POP/IMAP]),
349 [   if test "$with_ssl" != "no"; then
350         if test "$with_ssl" != "yes"; then
351             LDFLAGS="$LDFLAGS -L$withval/lib"
352             CPPFLAGS="$CPPFLAGS -I$withval/include"
353         fi
354         saved_LIBS="$LIBS"
355
356         AC_CHECK_LIB(crypto, X509_new,, AC_MSG_ERROR([Unable to find SSL library]))
357         AC_CHECK_LIB(ssl, SSL_new,, AC_MSG_ERROR([Unable to find SSL library]), -lcrypto)
358
359         AC_CHECK_FUNCS(RAND_status RAND_egd)
360
361         AC_DEFINE(USE_SSL,1,[ Define if you want support for SSL. ])
362         LIBS="$saved_LIBS"
363         MUTTLIBS="$MUTTLIBS -lssl -lcrypto"
364         need_ssl=yes
365     fi
366 ])
367
368 AC_ARG_WITH([gnutls], AC_HELP_STRING([--with-gnutls], [Enable SSL support using gnutls]),
369             [gnutls_prefix="$withval"], [gnutls_prefix="no"])
370 if test "$gnutls_prefix" != "no"; then
371     if test x"$need_ssl" = x"yes"; then
372         AC_MSG_ERROR([Only either OpenSSL or GNUTLS may be used])
373     fi
374     AM_PATH_LIBGNUTLS(,[
375         CPPFLAGS="$CPPFLAGS $LIBGNUTLS_CFLAGS"
376         MUTTLIBS="$MUTTLIBS $LIBGNUTLS_LIBS"
377         AC_DEFINE(USE_GNUTLS, 1, [Define if you want support for SSL via the gnutls library.])
378         need_ssl=yes],
379         [AC_MSG_ERROR([could not find libgnutls])
380     ])
381 fi
382 AM_CONDITIONAL(USE_SSL, test x$need_ssl = xyes)
383 AC_SUBST(MUTT_SSL_OBJECTS)
384
385 AC_ARG_WITH(sasl2, AC_HELP_STRING([--with-sasl2[=PFX]],
386             [Use Cyrus SASL library version 2 for POP/IMAP authentication]),[
387     if test "$with_sasl2" != "no"; then
388         if test "$with_sasl2" != "yes"; then
389             CPPFLAGS="$CPPFLAGS -I$with_sasl2/include"
390             LDFLAGS="$LDFLAGS -L$with_sasl2/lib"
391         fi
392
393         saved_LIBS="$LIBS"
394
395         AC_CHECK_LIB(sasl2, sasl_client_init,,AC_MSG_ERROR([could not find libsasl2]))
396
397         MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS mutt_sasl.o"
398         MUTTLIBS="$MUTTLIBS -lsasl2"
399         LIBS="$saved_LIBS"
400         AC_DEFINE(USE_SASL,1,
401                   [Define if want to use version 2 of the Cyrus SASL library.])
402         need_sasl=yes
403     fi
404 ])
405 AM_CONDITIONAL(USE_SASL, test x$need_sasl = xyes)
406
407 AC_ARG_WITH(idn, AC_HELP_STRING([--with-idn], [Use GNU libidn for domain names]),[
408     if test x$with_idn != xno ; then
409         PKG_CHECK_MODULES(IDN,libidn,[
410             if $PKG_CONFIG --atleast-version=0.6; then
411                 AC_MSG_ERROR([libidn is too old, want 0.6 at least])
412             fi
413             CPPFLAGS="$CPPFLAGS $IDN_CFLAGS"
414             LDFLAGS="$LDFLAGS $IDN_LIBS"
415             AC_DEFINE(HAVE_LIBIDN, 1, [IDN Support])
416         ],[AC_MSG_ERROR([could not find libidn])])
417     fi
418 ])
419
420 dnl -- end socket --
421
422 AC_ARG_ENABLE(flock, AC_HELP_STRING([--enable-flock], [Use flock() to lock files]),
423         [if test $enableval = yes; then
424                 AC_DEFINE(USE_FLOCK,1, [ Define to use flock() to lock mailboxes. ])
425         fi])
426
427 mutt_cv_fcntl=yes
428 AC_ARG_ENABLE(fcntl, AC_HELP_STRING([--disable-fcntl], [Do NOT use fcntl() to lock files]),
429         [if test $enableval = no; then mutt_cv_fcntl=no; fi])
430
431 if test $mutt_cv_fcntl = yes; then
432         AC_DEFINE(USE_FCNTL,1, [ Define to use fcntl() to lock folders. ])
433 fi
434
435 AC_MSG_CHECKING(whether struct dirent defines d_ino)
436 ac_cv_dirent_d_ino=no
437 AC_TRY_LINK([#include <dirent.h>],[struct dirent dp; (void)dp.d_ino],[ac_cv_dirent_d_ino=yes])
438 if test x$ac_cv_dirent_d_ino = xyes ; then
439   AC_DEFINE(HAVE_DIRENT_D_INO,1,
440             [Define to 1 if your system has the dirent::d_ino member])
441 fi
442 AC_MSG_RESULT($ac_cv_dirent_d_ino)
443
444 dnl -- start cache --
445 AC_ARG_ENABLE(hcache, AC_HELP_STRING([--enable-hcache], [Enable header caching]),
446 [if test x$enableval = xyes; then
447     AC_DEFINE(USE_HCACHE, 1, [Enable header caching])
448
449     OLDCPPFLAGS="$CPPFLAGS"
450     OLDLIBS="$LIBS"
451
452     need_md5="yes"
453
454     ac_prefer_qdbm=yes
455     AC_ARG_WITH(qdbm, AC_HELP_STRING([--without-qdbm], [Don't use qdbm even if it is available]),
456         ac_prefer_qdbm=$withval)
457     if test x$ac_prefer_qdbm != xno; then
458         PKG_CHECK_MODULES(QDBM,qdbm,[ac_qdbm_here=yes],[ac_qdbm_here=no])
459     fi
460
461     ac_prefer_gdbm=yes
462     AC_ARG_WITH(gdbm, AC_HELP_STRING([--without-gdbm], [Don't use gdbm even if it is available]),
463         ac_prefer_gdbm=$withval)
464     if test x$ac_prefer_gdbm != xno -a x$ac_qdbm_here != xyes; then
465         ac_cv_gdbmopen=no
466         GDBM_DIRS="${prefix} /usr/local /usr"
467         AC_MSG_CHECKING([for gdbm_open])
468         for d in $GDBM_DIRS; do
469           if test x$ac_cv_gdbmopen = xno && test -d "$d/include" && test -d "$d/lib"; then
470             GDBM_INC="-I$d/include"
471             GDBM_LIB="-L$d/lib"
472             CPPFLAGS="$OLDCPPFLAGS $GDBM_INC"
473             LIBS="$OLDLIBS $GDBM_LIB -lgdbm"
474             AC_TRY_LINK([#include <gdbm.h>],[gdbm_open(0,0,0,0,0);],[ac_cv_gdbmopen=yes])
475           fi
476         done
477         if test x$ac_cv_gdbmopen = xyes; then
478           AC_MSG_RESULT(yes)
479         else
480           AC_MSG_RESULT(no)
481         fi
482     fi
483
484     ac_bdb_prefix=yes
485     AC_ARG_WITH(bdb, AC_HELP_STRING([--with-bdb[=DIR]], [Use BerkeleyDB4 if gdbm is not available ]),
486         ac_bdb_prefix=$withval)
487     if test x$ac_bdb_prefix != xno -a x$ac_cv_gdbmopen != xyes -a x$ac_qdbm_here != xyes; then
488         test x$ac_bdb_prefix = xyes && ac_bdb_prefix="${prefix} /opt/csw/bdb4 /opt /usr/local /usr"
489         for d in $ac_bdb_prefix; do
490             bdbpfx="$bdbpfx $d"
491             for v in BerkeleyDB.4.3 BerkeleyDB.4.2 BerkeleyDB.4.1; do
492                 bdbpfx="$bdbpfx $d/$v"
493             done
494         done
495         BDB_VERSIONS="db-4 db4 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db ''"
496         AC_MSG_CHECKING([for BerkeleyDB > 4.0])
497         for d in $bdbpfx; do
498             BDB_INCLUDE_DIR=""
499             BDB_LIB_DIR=""
500             for v in / $BDB_VERSIONS; do
501                 if test -r "$d/include/$v/db.h"; then
502                     BDB_INCLUDE_DIR="$d/include/$v"
503                     if test -d "$d/lib/$v"; then
504                         BDB_LIB_DIR="$d/lib/$v"
505                         for l in `echo $BDB_VERSIONS`; do
506                             CPPFLAGS="-I$BDB_INCLUDE_DIR $OLDCPPFLAGS"
507                             LIBS="$OLDLIBS -L$BDB_LIB_DIR -l$l"
508                             AC_TRY_LINK([
509                                 #include <stdlib.h>
510                                 #include <db.h>
511                             ],[
512                                 DB *db = NULL;
513                                 db->open(db,NULL,NULL,NULL,0,0,0);
514                             ],[
515                                 ac_cv_dbcreate=yes
516                                 BDB_LIB="$l"
517                                 break
518                             ])
519                         done
520                         test x$ac_cv_dbcreate = xyes && break
521                     fi
522                 fi
523             done
524             test x$BDB_LIB != x && break
525         done
526         if test x$ac_cv_dbcreate = xyes; then
527             AC_MSG_RESULT(yes)
528         else
529             AC_MSG_RESULT(no)
530         fi
531     fi
532
533     if test x$ac_qdbm_here = xyes; then
534         CPPFLAGS="$OLDCPPFLAGS $QDBM_CFLAGS"
535         LIBS="$OLDLIBS $QDBM_LIBS"
536         AC_DEFINE(HAVE_QDBM, 1, [QDBM Support])
537     elif test x$ac_cv_gdbmopen = xyes; then
538         CPPFLAGS="$OLDCPPFLAGS $GDBM_INC"
539         LIBS="$OLDLIBS $GDBM_LIB -lgdbm";
540         AC_DEFINE(HAVE_GDBM, 1, [GDBM Support])
541     elif test x$ac_cv_dbcreate = xyes; then
542         CPPFLAGS="-I$BDB_INCLUDE_DIR $OLDCPPFLAGS"
543         LIBS="$OLDLIBS -L$BDB_LIB_DIR -l$BDB_LIB"
544         AC_DEFINE(HAVE_DB4, 1, [Sleepycat DB4 Support])
545     else
546         AC_MSG_ERROR([You need one of: QDBM, GDBM or Sleepycat DB4 for --enable-hcache])
547     fi
548 fi])
549 dnl -- end cache --
550
551 AC_SUBST(MUTTLIBS)
552 AC_SUBST(MUTT_LIB_OBJECTS)
553 AC_SUBST(LIBNNTP)
554 AC_SUBST(LIBNNTPDEPS)
555
556 dnl -- iconv/gettext --
557
558 AC_ARG_ENABLE(iconv, AC_HELP_STRING([--disable-iconv], [Disable iconv support]),
559         [if test x$enableval = xno ; then
560                 am_cv_func_iconv=no
561         fi
562 ])
563
564 AM_GNU_GETTEXT
565
566 if test "$am_cv_func_iconv" != "yes"; then
567     AC_MSG_WARN([Configuring without iconv support. See INSTALL for details])
568 else
569
570     AC_CHECK_HEADERS(iconv.h,
571         [AC_MSG_CHECKING(whether iconv.h defines iconv_t)
572          AC_EGREP_HEADER([typedef.*iconv_t],iconv.h,
573                 [AC_MSG_RESULT(yes)
574                  AC_DEFINE(HAVE_ICONV_T_DEF, 1,
575                         [Define if <iconv.h> defines iconv_t.])],
576                  AC_MSG_RESULT(no))])
577
578     dnl (1) Some implementations of iconv won't convert from UTF-8 to UTF-8.
579     dnl (2) In glibc-2.1.2 and earlier there is a bug that messes up ob and
580     dnl     obl when args 2 and 3 are 0 (fixed in glibc-2.1.3).
581     AC_CACHE_CHECK([whether this iconv is good enough], mutt_cv_iconv_good,
582                    mutt_save_LIBS="$LIBS"
583                    LIBS="$LIBS $LIBICONV"
584                    AC_TRY_RUN([
585 #include <iconv.h>
586 int main()
587 {
588   iconv_t cd;
589 changequote(, )dnl
590   char buf[4];
591 changequote([, ])dnl
592   char *ob;
593   size_t obl;
594   ob = buf, obl = sizeof(buf);
595   return ((cd = iconv_open("UTF-8", "UTF-8")) != (iconv_t)(-1) &&
596           (iconv(cd, 0, 0, &ob, &obl) ||
597            !(ob == buf && obl == sizeof(buf)) ||
598            iconv_close(cd)));
599 }
600                    ],
601                    mutt_cv_iconv_good=yes,
602                    mutt_cv_iconv_good=no,
603                    mutt_cv_iconv_good=yes)
604                    LIBS="$mutt_save_LIBS")
605     if test "$mutt_cv_iconv_good" = no; then
606         AC_MSG_ERROR(Try using libiconv instead)
607     fi
608
609 fi # libiconv
610
611 dnl -- locales --
612
613 AC_CHECK_HEADERS(locale.h wchar.h wctype.h)
614 AC_CHECK_FUNCS(iswalnum iswalpha  iswcntrl iswdigit)
615 AC_CHECK_FUNCS(iswgraph iswlower iswprint iswpunct iswspace iswupper)
616 AC_CHECK_FUNCS(iswxdigit towupper towlower)
617 AC_TYPE_MBSTATE_T
618
619 AC_CACHE_CHECK([for nl_langinfo and CODESET], mutt_cv_langinfo_codeset,
620                [AC_TRY_LINK([#include <langinfo.h>],
621                             [char* cs = nl_langinfo(CODESET);],
622                             mutt_cv_langinfo_codeset=yes,
623                             mutt_cv_langinfo_codeset=no)])
624 if test $mutt_cv_langinfo_codeset = yes; then
625     AC_DEFINE(HAVE_LANGINFO_CODESET,1,
626               [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
627 fi
628
629 AC_CACHE_CHECK([for nl_langinfo and YESEXPR], mutt_cv_langinfo_yesexpr,
630                [AC_TRY_LINK([#include <langinfo.h>],
631                             [char* cs = nl_langinfo(YESEXPR);],
632                             mutt_cv_langinfo_yesexpr=yes,
633                             mutt_cv_langinfo_yesexpr=no)])
634 if test $mutt_cv_langinfo_yesexpr = yes; then
635     AC_DEFINE(HAVE_LANGINFO_YESEXPR,1,
636               [Define if you have <langinfo.h> and nl_langinfo(YESEXPR).])
637 fi
638
639 dnl -- libesmtp --
640 MUTT_AM_LIBESMTP
641 if test x$use_libesmtp = xyes; then
642     CFLAGS="$CFLAGS $mutt_libesmtp_cflags"
643     dnl HACK MUTTLIBS="$MUTTLIBS $mutt_libesmtp_libs"
644     MUTTLIBS="$MUTTLIBS -lesmtp"
645     MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS mutt_libesmtp.o"
646     AC_DEFINE(USE_LIBESMTP, 1, [Define to enable the use of libesmtp])
647 fi
648 dnl -- end libesmtp --
649
650 dnl -- sgml tools --
651
652 dnl Documentation tools
653 have_openjade="no"
654 AC_PATH_PROG([OSPCAT], [ospcat], [none])
655 if test "x$OSPCAT" != "xnone"; then
656     AC_MSG_CHECKING([for openjade docbook stylesheets])
657     dslosfile=`ospcat --public-id="-//Norman Walsh//DOCUMENT DocBook Print Stylesheet//EN"`
658     DSLROOT=`echo $dslosfile | sed -n -e "s/.*SOIBASE='\(@<:@^'@:>@*\)\/catalog'.*/\1/p"`
659     # ospcat may spit out an absolute path without an SOIBASE
660     if test -z "$DSLROOT"; then
661         DSLROOT=`echo $dslosfile | sed -e 's|<OSFILE>\(.*\)/print/docbook.dsl|\1|'`
662     fi
663     if test -f $DSLROOT/print/docbook.dsl; then
664         AC_MSG_RESULT([in $DSLROOT])
665         have_openjade="yes"
666     else
667         AC_MSG_RESULT([not found: PDF documentation will not be built.])
668     fi
669 fi
670 AC_SUBST(DSLROOT)
671
672 AC_MSG_CHECKING([for lynx])
673 AC_PATH_PROG([HTML2TXT_CMD], [lynx], [none])
674 if test x"$HTML2TXT_CMD" = x"none"; then
675     AC_MSG_CHECKING([for w3m])
676     AC_PATH_PROG([HTML2TXT_CMD], [w3m], [none])
677 fi
678 if test x"$HTML2TXT_CMD" = x"none"; then
679     AC_MSG_CHECKING([for elinks])
680     AC_PATH_PROG([HTML2TXT_CMD], [elinks], [none])
681 fi
682 case "$HTML2TXT_CMD" in
683   *elinks*)
684     HTML2TXT_CMD="$HTML2TXT_CMD -dump -no-numbering -no-references \$^ > \$@"
685     ;;
686   *lynx*)
687     HTML2TXT_CMD="$HTML2TXT_CMD -dump -nolist -with_backspaces \$^ > \$@"
688     ;;
689   *w3m*)
690     HTML2TXT_CMD="$HTML2TXT_CMD -dump \$^ > \$@"
691     ;;
692   *)
693     HTML2TXT_CMD="true"
694     ;;
695 esac
696 AC_SUBST(HTML2TXT_CMD)
697
698 AC_MSG_CHECKING([for tidy])
699 AC_PATH_PROG([HTMLCLEAN_CMD], [tidy], [none])
700
701 if test x"$HTMLCLEAN_CMD" != x"none"; then
702     HTMLCLEAN_CMD="$HTMLCLEAN_CMD -q -i -m -asxml -utf8 "
703 else
704     HTMLCLEAN_CMD="echo "
705 fi
706 AC_SUBST(HTMLCLEAN_CMD)
707
708 AC_ARG_ENABLE(doc,
709   [  --enable-doc            build documentation (needs doxygen and LaTeX)])
710 # Build documentation?
711 DOXYGEN="no"
712 LATEX="no"
713 if test "${enable_doc}" != "no"; then
714   AC_PATH_PROG(DOXYGEN, doxygen, no)
715   if test "${DOXYGEN}" != "no"; then
716     # Build LaTeX documentation?
717     AC_PATH_PROG(LATEX, pdflatex, no)
718     AC_PATH_PROG(DVIPS, dvips, no)
719     if test "${DVIPS}" = "no"; then
720       LATEX="no"
721     fi
722     AC_MSG_CHECKING(for a4wide.sty)
723     if test -f /usr/share/texmf/tex/latex/misc/a4wide.sty; then
724       AC_MSG_RESULT(yes)
725     elif test -f /usr/share/texmf-tetex/tex/latex/a4wide/a4wide.sty; then
726       AC_MSG_RESULT(yes)
727     else
728       LATEX="no"
729       AC_MSG_RESULT(no)
730     fi
731   fi
732 fi
733 AM_CONDITIONAL(BUILD_DOCUMENTATION, test "${DOXYGEN}" != "no")
734 AM_CONDITIONAL(USE_LATEX, test "${LATEX}" != "no")
735
736 AC_OUTPUT(Makefile
737           intl/Makefile
738           m4/Makefile
739           po/Makefile.in
740           apidoc/Makefile apidoc/doxygen.cfg
741           lib-lib/Makefile
742           lib-lua/Makefile
743           lib-mime/Makefile
744           lib-hash/Makefile
745           lib-mx/Makefile
746           lib-sys/Makefile
747           lib-ui/Makefile
748           imap/Makefile
749           pop/Makefile
750           nntp/Makefile
751 )