02747bc00dc0372f2ea9e6316dd8904b61df8e2d
[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     MUTTLIBS="$MUTTLIBS $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                 MUTTLIBS="$MUTTLIBS -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                 MUTTLIBS="$MUTTLIBS -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                 MUTTLIBS="$MUTTLIBS -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                 MUTTLIBS="-L${mutt_cv_curses}/lib $MUTTLIBS"
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         LIBS="$MUTTLIBS"
176         CF_CHECK_FUNCDECLS([#include <${cf_cv_ncurses_header-curses.h}>],
177                            [start_color typeahead bkgdset curs_set meta use_default_colors resizeterm])
178         if test "$ac_cv_func_decl_start_color" != yes; then
179             AC_MSG_ERROR([Your curses library does not supports color.])
180         fi
181         LIBS=""
182     ])
183
184 AC_CHECK_HEADERS(stdarg.h sys/ioctl.h ioctl.h sysexits.h)
185 AC_CHECK_HEADERS(sys/time.h sys/resource.h)
186 AC_CHECK_HEADERS(unix.h)
187
188 AC_CHECK_FUNCS(setrlimit getsid isctype)
189
190 AC_TYPE_SIGNAL
191
192 AC_MSG_CHECKING(for sig_atomic_t in signal.h)
193 AC_EGREP_HEADER(sig_atomic_t,signal.h,
194     [   ac_cv_type_sig_atomic_t=yes;
195         AC_EGREP_HEADER(volatile.*sig_atomic_t,
196                         signal.h,
197                         [is_sig_atomic_t_volatile=yes; AC_MSG_RESULT([yes, volatile])],
198                         [is_sig_atomic_t_volatile=no;  AC_MSG_RESULT([yes, non volatile])])
199     ],
200     [   AC_MSG_RESULT(no)
201         AC_CHECK_TYPE(sig_atomic_t, int)
202         is_sig_atomic_t_volatile=no
203     ])
204 if test $is_sig_atomic_t_volatile = 'yes'
205 then
206     AC_DEFINE(SIG_ATOMIC_VOLATILE_T, sig_atomic_t)
207 else
208     AC_DEFINE(SIG_ATOMIC_VOLATILE_T, [volatile sig_atomic_t])
209 fi
210
211 AC_DECL_SYS_SIGLIST
212 AC_TYPE_PID_T
213
214 AC_CHECK_FUNC(getopt)
215 if test $ac_cv_func_getopt = yes; then
216     AC_CHECK_HEADERS(getopt.h)
217 fi
218
219 AC_CHECK_FUNC(regcomp)
220 if test $ac_cv_func_regcomp = yes; then
221    AC_CHECK_HEADERS(regex.h)
222 fi
223
224 AC_ARG_WITH(homespool,
225             AC_HELP_STRING([--with-homespool[=FILE]],
226                            [File in user's directory where new mail is spooled]),
227                            with_homespool=${withval})
228 if test x$with_homespool != x; then
229     if test $with_homespool = yes; then
230             with_homespool=mailbox
231     fi
232     AC_DEFINE_UNQUOTED(MAILPATH,"$with_homespool",[ Where new mail is spooled. ])
233     AC_DEFINE(HOMESPOOL,1,
234     [   Is mail spooled to the user's home directory?  If defined,
235         MAILPATH should be set to the filename of the spool mailbox
236         relative the the home directory.
237         use: configure --with-homespool=FILE
238     ])
239     mutt_cv_setgid=no
240 else
241     AC_ARG_WITH(mailpath, AC_HELP_STRING([--with-mailpath=DIR], [Directory where spool mailboxes are located]),
242         [mutt_cv_mailpath=$withval],
243         [ AC_CACHE_CHECK(where new mail is stored, mutt_cv_mailpath,
244             [mutt_cv_mailpath=no
245             if test -d /var/mail; then
246                 mutt_cv_mailpath=/var/mail
247             elif test -d /var/spool/mail; then
248                 mutt_cv_mailpath=/var/spool/mail
249             elif test -d /usr/spool/mail; then
250                 mutt_cv_mailpath=/usr/spool/mail
251             elif test -d /usr/mail; then
252                 mutt_cv_mailpath=/usr/mail
253             fi])
254         ])
255     if test "$mutt_cv_mailpath" = no; then
256         AC_MSG_ERROR("Could not determine where new mail is stored.")
257     fi
258     AC_DEFINE_UNQUOTED(MAILPATH,"$mutt_cv_mailpath",[ Where new mail is spooled. ])
259
260     AC_CACHE_CHECK(if $mutt_cv_mailpath is world writable, mutt_cv_worldwrite, [AC_TRY_RUN([#include <sys/types.h>
261 #include <sys/stat.h>
262
263 int main (int argc, char **argv)
264 {
265         struct stat s;
266
267         stat ("$mutt_cv_mailpath", &s);
268         if (s.st_mode & S_IWOTH) exit (0);
269         exit (1);
270 }], mutt_cv_worldwrite=yes, mutt_cv_worldwrite=no, mutt_cv_worldwrite=no)])
271
272         mutt_cv_setgid=no
273         if test $mutt_cv_worldwrite != yes; then
274                 AC_CACHE_CHECK(if $mutt_cv_mailpath is group writable, mutt_cv_groupwrite, [AC_TRY_RUN([#include <sys/types.h>
275 #include <sys/stat.h>
276
277 int main (int argc, char **argv)
278 {
279         struct stat s;
280
281         stat ("$mutt_cv_mailpath", &s);
282         if (s.st_mode & S_IWGRP) exit (0);
283         exit (1);
284 }], mutt_cv_groupwrite=yes, mutt_cv_groupwrite=no, mutt_cv_groupwrite=no)])
285
286         if test $mutt_cv_groupwrite = yes; then
287             AC_DEFINE(USE_SETGID,1,[ Define if mutt should run setgid "mail". ])
288             mutt_cv_setgid=yes
289         fi
290     fi
291 fi
292
293 AC_MSG_CHECKING(where to put the documentation)
294 AC_ARG_WITH(docdir, AC_HELP_STRING([--with-docdir=PATH], [Specify where to put the documentation]),
295         [mutt_cv_docdir=$withval],
296         [mutt_cv_docdir="${prefix}/doc/madmutt"])
297 AC_MSG_RESULT($mutt_cv_docdir)
298
299 docdir=$mutt_cv_docdir
300 AC_SUBST(docdir)
301
302 if test x$mutt_cv_setgid = xyes; then
303     DOTLOCK_GROUP='mail'
304     DOTLOCK_PERMISSION=2755
305 else
306     DOTLOCK_GROUP=''
307     DOTLOCK_PERMISSION=755
308 fi
309 AC_SUBST(DOTLOCK_GROUP)
310 AC_SUBST(DOTLOCK_PERMISSION)
311
312 dnl -- socket dependencies --
313
314 AC_ARG_ENABLE(nntp, AC_HELP_STRING([--enable-nntp],[Enable NNTP support]),[
315     if test x$enableval = xyes ; then
316         AC_DEFINE(USE_NNTP,1,[ Compiling with newsreading support with NNTP ])
317         LIBNNTP="-Lnntp -lnntp"
318         LIBNNTPDEPS="\$(top_srcdir)/nntp/nntp.h nntp/libnntp.a"
319         need_nntp="yes"
320     fi
321 ])
322 AM_CONDITIONAL(BUILD_NNTP, test x$need_nntp = xyes)
323
324 AC_MSG_CHECKING([for socklen_t])
325 AC_EGREP_HEADER(socklen_t, sys/socket.h, AC_MSG_RESULT([yes]),
326         AC_MSG_RESULT([no])
327         AC_DEFINE(socklen_t,int, [ Define to 'int' if <sys/socket.h> doesn't have it. ]))
328 AC_CHECK_FUNC(gethostent,,AC_CHECK_LIB(nsl, gethostent))
329 AC_CHECK_FUNC(setsockopt,,AC_CHECK_LIB(socket, setsockopt))
330 AC_CHECK_FUNC(getaddrinfo,,[AC_MSG_ERROR([cannot find getaddrinfo])])
331
332 dnl -- imap dependencies --
333
334 AM_PATH_LIBGNUTLS(,[
335     CPPFLAGS="$CPPFLAGS $LIBGNUTLS_CFLAGS"
336     MUTTLIBS="$MUTTLIBS $LIBGNUTLS_LIBS"],[AC_MSG_ERROR([could not find libgnutls])
337 ])
338
339 AC_CHECK_LIB(sasl2, sasl_client_init,,AC_MSG_ERROR([could not find libsasl2]))
340 MUTTLIBS="$MUTTLIBS $LIBS"
341 LIBS=""
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             MUTTLIBS="$MUTTLIBS $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     OLDCPPFLAGS="$CPPFLAGS"
385     need_md5="yes"
386
387     ac_prefer_qdbm=yes
388     AC_ARG_WITH(qdbm, AC_HELP_STRING([--without-qdbm], [Don't use qdbm even if it is available]),
389         ac_prefer_qdbm=$withval)
390     if test x$ac_prefer_qdbm != xno; then
391         PKG_CHECK_MODULES(QDBM,qdbm,[ac_qdbm_here=yes],[ac_qdbm_here=no])
392     fi
393
394     ac_prefer_gdbm=yes
395     AC_ARG_WITH(gdbm, AC_HELP_STRING([--without-gdbm], [Don't use gdbm even if it is available]),
396         ac_prefer_gdbm=$withval)
397     if test x$ac_prefer_gdbm != xno -a x$ac_qdbm_here != xyes; then
398         ac_cv_gdbmopen=no
399         GDBM_DIRS="${prefix} /usr/local /usr"
400         AC_MSG_CHECKING([for gdbm_open])
401         for d in $GDBM_DIRS; do
402           if test x$ac_cv_gdbmopen = xno && test -d "$d/include" && test -d "$d/lib"; then
403             GDBM_INC="-I$d/include"
404             GDBM_LIB="-L$d/lib"
405             CPPFLAGS="$OLDCPPFLAGS $GDBM_INC"
406             LIBS="$MUTTLIBS $GDBM_LIB -lgdbm"
407             AC_TRY_LINK([#include <gdbm.h>],[gdbm_open(0,0,0,0,0);],[ac_cv_gdbmopen=yes])
408           fi
409         done
410         if test x$ac_cv_gdbmopen = xyes; then
411           AC_MSG_RESULT(yes)
412         else
413           AC_MSG_RESULT(no)
414         fi
415     fi
416
417     ac_bdb_prefix=yes
418     AC_ARG_WITH(bdb, AC_HELP_STRING([--with-bdb[=DIR]], [Use BerkeleyDB4 if gdbm is not available ]),
419         ac_bdb_prefix=$withval)
420     if test x$ac_bdb_prefix != xno -a x$ac_cv_gdbmopen != xyes -a x$ac_qdbm_here != xyes; then
421         test x$ac_bdb_prefix = xyes && ac_bdb_prefix="${prefix} /opt/csw/bdb4 /opt /usr/local /usr"
422         for d in $ac_bdb_prefix; do
423             bdbpfx="$bdbpfx $d"
424             for v in BerkeleyDB.4.3 BerkeleyDB.4.2 BerkeleyDB.4.1; do
425                 bdbpfx="$bdbpfx $d/$v"
426             done
427         done
428         BDB_VERSIONS="db-4 db4 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db ''"
429         AC_MSG_CHECKING([for BerkeleyDB > 4.0])
430         for d in $bdbpfx; do
431             BDB_INCLUDE_DIR=""
432             BDB_LIB_DIR=""
433             for v in / $BDB_VERSIONS; do
434                 if test -r "$d/include/$v/db.h"; then
435                     BDB_INCLUDE_DIR="$d/include/$v"
436                     if test -d "$d/lib/$v"; then
437                         BDB_LIB_DIR="$d/lib/$v"
438                         for l in `echo $BDB_VERSIONS`; do
439                             CPPFLAGS="-I$BDB_INCLUDE_DIR $OLDCPPFLAGS"
440                             LIBS="$MUTTLIBS -L$BDB_LIB_DIR -l$l"
441                             AC_TRY_LINK([
442                                 #include <stdlib.h>
443                                 #include <db.h>
444                             ],[
445                                 DB *db = NULL;
446                                 db->open(db,NULL,NULL,NULL,0,0,0);
447                             ],[
448                                 ac_cv_dbcreate=yes
449                                 BDB_LIB="$l"
450                                 break
451                             ])
452                         done
453                         test x$ac_cv_dbcreate = xyes && break
454                     fi
455                 fi
456             done
457             test x$BDB_LIB != x && break
458         done
459         if test x$ac_cv_dbcreate = xyes; then
460             AC_MSG_RESULT(yes)
461         else
462             AC_MSG_RESULT(no)
463         fi
464     fi
465
466     if test x$ac_qdbm_here = xyes; then
467         CPPFLAGS="$OLDCPPFLAGS $QDBM_CFLAGS"
468         MUTTLIBS="$MUTTLIBS $QDBM_LIBS"
469         AC_DEFINE(HAVE_QDBM, 1, [QDBM Support])
470     elif test x$ac_cv_gdbmopen = xyes; then
471         CPPFLAGS="$OLDCPPFLAGS $GDBM_INC"
472         MUTTLIBS="$MUTTLIBS $GDBM_LIB -lgdbm";
473         AC_DEFINE(HAVE_GDBM, 1, [GDBM Support])
474     elif test x$ac_cv_dbcreate = xyes; then
475         CPPFLAGS="-I$BDB_INCLUDE_DIR $OLDCPPFLAGS"
476         MUTTLIBS="$MUTTLIBS -L$BDB_LIB_DIR -l$BDB_LIB"
477         AC_DEFINE(HAVE_DB4, 1, [Sleepycat DB4 Support])
478     else
479         AC_MSG_ERROR([You need one of: QDBM, GDBM or Sleepycat DB4 for --enable-hcache])
480     fi
481     LIBS=""
482 fi])
483 dnl -- end cache --
484
485 AC_SUBST(MUTTLIBS)
486 AC_SUBST(LIBNNTP)
487 AC_SUBST(LIBNNTPDEPS)
488
489 dnl -- iconv/gettext --
490
491 AC_ARG_ENABLE(iconv, AC_HELP_STRING([--disable-iconv], [Disable iconv support]),
492         [if test x$enableval = xno ; then
493                 am_cv_func_iconv=no
494         fi
495 ])
496
497 AM_GNU_GETTEXT
498
499 if test "$am_cv_func_iconv" != "yes"; then
500     AC_MSG_WARN([Configuring without iconv support. See INSTALL for details])
501 else
502
503     AC_CHECK_HEADERS(iconv.h,
504         [AC_MSG_CHECKING(whether iconv.h defines iconv_t)
505          AC_EGREP_HEADER([typedef.*iconv_t],iconv.h,
506                 [AC_MSG_RESULT(yes)
507                  AC_DEFINE(HAVE_ICONV_T_DEF, 1,
508                         [Define if <iconv.h> defines iconv_t.])],
509                  AC_MSG_RESULT(no))])
510
511     dnl (1) Some implementations of iconv won't convert from UTF-8 to UTF-8.
512     dnl (2) In glibc-2.1.2 and earlier there is a bug that messes up ob and
513     dnl     obl when args 2 and 3 are 0 (fixed in glibc-2.1.3).
514     AC_CACHE_CHECK([whether this iconv is good enough], mutt_cv_iconv_good,
515                    LIBS="$LIBICONV"
516                    AC_TRY_RUN([
517 #include <iconv.h>
518 int main()
519 {
520   iconv_t cd;
521 changequote(, )dnl
522   char buf[4];
523 changequote([, ])dnl
524   char *ob;
525   size_t obl;
526   ob = buf, obl = sizeof(buf);
527   return ((cd = iconv_open("UTF-8", "UTF-8")) != (iconv_t)(-1) &&
528           (iconv(cd, 0, 0, &ob, &obl) ||
529            !(ob == buf && obl == sizeof(buf)) ||
530            iconv_close(cd)));
531 }
532                    ],
533                    mutt_cv_iconv_good=yes,
534                    mutt_cv_iconv_good=no,
535                    mutt_cv_iconv_good=yes)
536                    LIBS="")
537     if test "$mutt_cv_iconv_good" = no; then
538         AC_MSG_ERROR(Try using libiconv instead)
539     fi
540
541 fi # libiconv
542
543 dnl -- locales --
544
545 AC_CHECK_HEADERS(locale.h wchar.h wctype.h)
546 AC_CHECK_FUNCS(iswalnum iswalpha  iswcntrl iswdigit)
547 AC_CHECK_FUNCS(iswgraph iswlower iswprint iswpunct iswspace iswupper)
548 AC_CHECK_FUNCS(iswxdigit towupper towlower)
549 AC_TYPE_MBSTATE_T
550
551 AC_CACHE_CHECK([for nl_langinfo and CODESET], mutt_cv_langinfo_codeset,
552                [AC_TRY_LINK([#include <langinfo.h>],
553                             [char* cs = nl_langinfo(CODESET);],
554                             mutt_cv_langinfo_codeset=yes,
555                             mutt_cv_langinfo_codeset=no)])
556 if test $mutt_cv_langinfo_codeset = yes; then
557     AC_DEFINE(HAVE_LANGINFO_CODESET,1,
558               [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
559 fi
560
561 AC_CACHE_CHECK([for nl_langinfo and YESEXPR], mutt_cv_langinfo_yesexpr,
562                [AC_TRY_LINK([#include <langinfo.h>],
563                             [char* cs = nl_langinfo(YESEXPR);],
564                             mutt_cv_langinfo_yesexpr=yes,
565                             mutt_cv_langinfo_yesexpr=no)])
566 if test $mutt_cv_langinfo_yesexpr = yes; then
567     AC_DEFINE(HAVE_LANGINFO_YESEXPR,1,
568               [Define if you have <langinfo.h> and nl_langinfo(YESEXPR).])
569 fi
570
571 dnl -- libesmtp --
572 MUTT_AM_LIBESMTP
573 if test x$use_libesmtp = xyes; then
574     CFLAGS="$CFLAGS $mutt_libesmtp_cflags"
575     dnl HACK MUTTLIBS="$MUTTLIBS $mutt_libesmtp_libs"
576     MUTTLIBS="$MUTTLIBS -lesmtp"
577     AC_DEFINE(USE_LIBESMTP, 1, [Define to enable the use of libesmtp])
578 fi
579 dnl -- end libesmtp --
580
581 dnl -- sgml tools --
582
583 dnl Documentation tools
584 have_openjade="no"
585 AC_PATH_PROG([OSPCAT], [ospcat], [none])
586 if test "x$OSPCAT" != "xnone"; then
587     AC_MSG_CHECKING([for openjade docbook stylesheets])
588     dslosfile=`ospcat --public-id="-//Norman Walsh//DOCUMENT DocBook Print Stylesheet//EN"`
589     DSLROOT=`echo $dslosfile | sed -n -e "s/.*SOIBASE='\(@<:@^'@:>@*\)\/catalog'.*/\1/p"`
590     # ospcat may spit out an absolute path without an SOIBASE
591     if test -z "$DSLROOT"; then
592         DSLROOT=`echo $dslosfile | sed -e 's|<OSFILE>\(.*\)/print/docbook.dsl|\1|'`
593     fi
594     if test -f $DSLROOT/print/docbook.dsl; then
595         AC_MSG_RESULT([in $DSLROOT])
596         have_openjade="yes"
597     else
598         AC_MSG_RESULT([not found: PDF documentation will not be built.])
599     fi
600 fi
601 AC_SUBST(DSLROOT)
602
603 AC_MSG_CHECKING([for lynx])
604 AC_PATH_PROG([HTML2TXT_CMD], [lynx], [none])
605 if test x"$HTML2TXT_CMD" = x"none"; then
606     AC_MSG_CHECKING([for w3m])
607     AC_PATH_PROG([HTML2TXT_CMD], [w3m], [none])
608 fi
609 if test x"$HTML2TXT_CMD" = x"none"; then
610     AC_MSG_CHECKING([for elinks])
611     AC_PATH_PROG([HTML2TXT_CMD], [elinks], [none])
612 fi
613 case "$HTML2TXT_CMD" in
614   *elinks*)
615     HTML2TXT_CMD="$HTML2TXT_CMD -dump -no-numbering -no-references \$^ > \$@"
616     ;;
617   *lynx*)
618     HTML2TXT_CMD="$HTML2TXT_CMD -dump -nolist -with_backspaces \$^ > \$@"
619     ;;
620   *w3m*)
621     HTML2TXT_CMD="$HTML2TXT_CMD -dump \$^ > \$@"
622     ;;
623   *)
624     HTML2TXT_CMD="true"
625     ;;
626 esac
627 AC_SUBST(HTML2TXT_CMD)
628
629 AC_MSG_CHECKING([for tidy])
630 AC_PATH_PROG([HTMLCLEAN_CMD], [tidy], [none])
631
632 if test x"$HTMLCLEAN_CMD" != x"none"; then
633     HTMLCLEAN_CMD="$HTMLCLEAN_CMD -q -i -m -asxml -utf8 "
634 else
635     HTMLCLEAN_CMD="echo "
636 fi
637 AC_SUBST(HTMLCLEAN_CMD)
638
639 AC_ARG_ENABLE(doc,
640   [  --enable-doc            build documentation (needs doxygen and LaTeX)])
641 # Build documentation?
642 DOXYGEN="no"
643 LATEX="no"
644 if test "${enable_doc}" != "no"; then
645   AC_PATH_PROG(DOXYGEN, doxygen, no)
646   if test "${DOXYGEN}" != "no"; then
647     # Build LaTeX documentation?
648     AC_PATH_PROG(LATEX, pdflatex, no)
649     AC_PATH_PROG(DVIPS, dvips, no)
650     if test "${DVIPS}" = "no"; then
651       LATEX="no"
652     fi
653     AC_MSG_CHECKING(for a4wide.sty)
654     if test -f /usr/share/texmf/tex/latex/misc/a4wide.sty; then
655       AC_MSG_RESULT(yes)
656     elif test -f /usr/share/texmf-tetex/tex/latex/a4wide/a4wide.sty; then
657       AC_MSG_RESULT(yes)
658     else
659       LATEX="no"
660       AC_MSG_RESULT(no)
661     fi
662   fi
663 fi
664 AM_CONDITIONAL(BUILD_DOCUMENTATION, test "${DOXYGEN}" != "no")
665 AM_CONDITIONAL(USE_LATEX, test "${LATEX}" != "no")
666
667 AC_OUTPUT(Makefile
668           intl/Makefile
669           m4/Makefile
670           po/Makefile.in
671           apidoc/Makefile apidoc/doxygen.cfg
672           lib-lib/Makefile
673           lib-lua/Makefile
674           lib-mime/Makefile
675           lib-hash/Makefile
676           lib-mx/Makefile
677           lib-sys/Makefile
678           lib-ui/Makefile
679           imap/Makefile
680           pop/Makefile
681           nntp/Makefile
682 )