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