1dnl Process this file with autoconf to produce a configure script.
2
3dnl !!! WHEN ADDING NEW CONFIGURE TESTS, PLEASE ADD CODE TO MAIN.C !!!
4dnl !!! TO DUMP THEIR RESULTS WHEN MUTT -V IS CALLED            !!!
5
6AC_PREREQ([2.54])
7AC_INIT([mutt.h])
8AM_CONFIG_HEADER([config.h])
9
10mutt_cv_version=`cat $srcdir/VERSION`
11AM_INIT_AUTOMAKE(mutt, $mutt_cv_version)
12AC_SUBST([CONFIG_STATUS_DEPENDENCIES], ['$(top_srcdir)/VERSION'])
13
14AC_GNU_SOURCE
15
16ALL_LINGUAS="de eu 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 ga"
17
18AC_CANONICAL_HOST
19
20AC_MSG_CHECKING([for prefix])
21if test x$prefix = xNONE; then
22  mutt_cv_prefix=$ac_default_prefix
23else
24  mutt_cv_prefix=$prefix
25fi
26AC_MSG_RESULT($mutt_cv_prefix)
27
28AC_PROG_CC
29AC_ISC_POSIX
30AC_PROG_CPP
31AC_PROG_MAKE_SET
32AC_PROG_INSTALL
33AC_PROG_RANLIB
34AC_CHECK_TOOL(AR, ar, ar)
35
36AC_C_INLINE
37AC_C_CONST
38AC_C_BIGENDIAN
39
40AC_SYS_LARGEFILE
41AC_FUNC_FSEEKO
42AC_CHECK_SIZEOF(off_t)
43
44AC_PATH_PROG(DBX, dbx, no)
45AC_PATH_PROG(GDB, gdb, no)
46AC_PATH_PROG(SDB, sdb, no)
47
48if test $GDB != no ; then
49        DEBUGGER=$GDB
50elif test $DBX != no ; then
51        DEBUGGER=$DBX
52elif test $SDB != no ; then
53        DEBUGGER=$SDB
54else
55        DEBUGGER=no
56fi
57
58AC_SUBST([DEBUGGER])
59
60AH_TEMPLATE([sig_atomic_t],
61            [/* Define to `int' if <signal.h> doesn't define.])
62AH_TEMPLATE([HAVE_START_COLOR],
63            [Define if you have start_color, as a function or macro.])
64AH_TEMPLATE([HAVE_TYPEAHEAD],
65            [Define if you have typeahead, as a function or macro.])
66AH_TEMPLATE([HAVE_BKGDSET],
67            [Define if you have bkgdset, as a function or macro.])
68AH_TEMPLATE([HAVE_CURS_SET],
69            [Define if you have curs_set, as a function or macro.])
70AH_TEMPLATE([HAVE_META],
71            [Define if you have meta, as a function or macro.])
72AH_TEMPLATE([HAVE_USE_DEFAULT_COLORS],
73            [Define if you have use_default_colors, as a function or macro.])
74AH_TEMPLATE([HAVE_RESIZETERM],
75            [Define if you have resizeterm, as a function or macro.])
76AH_TEMPLATE([SIG_ATOMIC_VOLATILE_T],
77            [Some systems declare sig_atomic_t as volatile, some others -- no.
78             This define will have value `sig_atomic_t' or
79             `volatile sig_atomic_t' accordingly.])
80AH_TEMPLATE([ICONV_NONTRANS],
81            [Define as 1 if iconv() only converts exactly and we should treat
82             all return values other than (size_t)(-1) as equivalent.])
83
84AH_BOTTOM([/* fseeko portability defines */
85#ifdef HAVE_FSEEKO
86# define LOFF_T off_t
87# if HAVE_C99_INTTYPES && HAVE_INTTYPES_H
88#  if SIZEOF_OFF_T == 8
89#   define OFF_T_FMT "%" PRId64
90#  else
91#   define OFF_T_FMT "%" PRId32
92#  endif
93# else
94#  if (SIZEOF_OFF_T == 8) && (SIZEOF_LONG == 4)
95#   define OFF_T_FMT "%lld"
96#  else
97#   define OFF_T_FMT "%ld"
98#  endif
99# endif
100#else
101# define LOFF_T long
102# define fseeko fseek
103# define ftello ftell
104# define OFF_T_FMT "%ld"
105#endif
106])
107MUTT_C99_INTTYPES
108AC_TYPE_LONG_LONG_INT
109
110ac_aux_path_sendmail=/usr/sbin:/usr/lib
111AC_PATH_PROG(SENDMAIL, sendmail, /usr/sbin/sendmail, $PATH:$ac_aux_path_sendmail)
112AC_DEFINE_UNQUOTED(SENDMAIL,"$ac_cv_path_SENDMAIL", [Where to find sendmail on your system.])
113
114OPS='$(srcdir)/OPS'
115
116AC_MSG_CHECKING([whether to build with GPGME support])
117AC_ARG_ENABLE(gpgme, AC_HELP_STRING([--enable-gpgme], [Enable GPGME support]),
118[       if test x$enableval = xyes; then
119		enable_gpgme=yes
120	fi
121])
122
123if test x"$enable_gpgme" = xyes; then
124   AC_MSG_RESULT(yes)
125   AM_PATH_GPGME(1.0.0, AC_DEFINE(CRYPT_BACKEND_GPGME, 1,
126		 [Defined, if GPGME support is enabled]),
127		 [gpgme_found=no])
128   if test x"$gpgme_found" = xno; then
129      AC_MSG_ERROR([*** GPGME not found ***])
130   else
131      AM_PATH_GPGME(1.1.1, AC_DEFINE(HAVE_GPGME_PKA_TRUST, 1,
132				  [Define if GPGME supports PKA]))
133      #needed to get GPGME_LIBS and al correctly
134      AM_PATH_GPGME(1.0.0, AC_DEFINE(CRYPT_BACKEND_GPGME, 1,
135                    [Define if you use GPGME to support OpenPGP]))
136      MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS crypt-gpgme.o crypt-mod-pgp-gpgme.o crypt-mod-smime-gpgme.o"
137   fi
138else
139   AC_MSG_RESULT([no])
140fi
141
142AC_ARG_ENABLE(pgp, AC_HELP_STRING([--disable-pgp], [Disable PGP support]),
143[       if test x$enableval = xno ; then
144                have_pgp=no
145        fi
146])
147
148if test x$have_pgp != xno ; then
149        AC_DEFINE(CRYPT_BACKEND_CLASSIC_PGP,1, [Define if you want classic PGP support.])
150        PGPAUX_TARGET="pgpring\$(EXEEXT) pgpewrap\$(EXEEXT)"
151        MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS pgp.o pgpinvoke.o pgpkey.o pgplib.o gnupgparse.o pgpmicalg.o pgppacket.o crypt-mod-pgp-classic.o"
152fi
153
154AC_ARG_ENABLE(smime, AC_HELP_STRING([--disable-smime], [Disable SMIME support]),
155[	if test x$enableval = xno ; then
156		have_smime=no
157	fi
158])
159
160if test x$have_smime != xno ; then
161	AC_DEFINE(CRYPT_BACKEND_CLASSIC_SMIME, 1, [Define if you want clasic S/MIME support.])
162	MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS smime.o crypt-mod-smime-classic.o"
163	SMIMEAUX_TARGET="smime_keys"
164fi
165
166AC_ARG_WITH(mixmaster, AC_HELP_STRING([--with-mixmaster@<:@=PATH@:>@], [Include Mixmaster support]),
167  [if test "$withval" != no
168   then
169     if test -x "$withval"
170     then
171       MIXMASTER="$withval"
172     else
173       MIXMASTER="mixmaster"
174     fi
175     OPS="$OPS \$(srcdir)/OPS.MIX"
176     MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS remailer.o"
177     AC_DEFINE_UNQUOTED(MIXMASTER,"$MIXMASTER", [Where to find mixmaster on your system.])
178   fi])
179
180# We now require all OPS
181OPS="$OPS \$(srcdir)/OPS.PGP \$(srcdir)/OPS.SMIME \$(srcdir)/OPS.CRYPT "
182AC_SUBST([OPS])
183
184AC_SUBST(PGPAUX_TARGET)
185AC_SUBST(SMIMEAUX_TARGET)
186
187AC_PATH_PROG(ISPELL, ispell, no)
188if test $ISPELL != no; then
189        AC_DEFINE_UNQUOTED(ISPELL,"$ISPELL",[ Where to find ispell on your system. ])
190fi
191
192AC_ARG_WITH(slang, AC_HELP_STRING([--with-slang@<:@=DIR@:>@], [Use S-Lang instead of ncurses]),
193        [AC_CACHE_CHECK([if this is a BSD system], mutt_cv_bsdish,
194                [AC_TRY_RUN([#include <sys/param.h>
195#include <stdlib.h>
196
197main ()
198{
199#ifdef BSD
200        exit (0);
201#else
202        exit (1);
203#endif
204}],
205                        mutt_cv_bsdish=yes,
206                        mutt_cv_bsdish=no,
207                        mutt_cv_bsdish=no)])
208
209        AC_MSG_CHECKING(for S-Lang)
210        if test $withval = yes; then
211                if test -d $srcdir/../slang; then
212                        mutt_cv_slang=$srcdir/../slang/src
213                        CPPFLAGS="$CPPFLAGS -I${mutt_cv_slang}"
214                        LDFLAGS="$LDFLAGS -L${mutt_cv_slang}/objs"
215                else
216                        if test -d $mutt_cv_prefix/include/slang; then
217                                CPPFLAGS="$CPPFLAGS -I$mutt_cv_prefix/include/slang"
218                        elif test -d /usr/include/slang; then
219                                CPPFLAGS="$CPPFLAGS -I/usr/include/slang"
220                        fi
221                        mutt_cv_slang=yes
222                fi
223        else
224                dnl ---Check to see if $withval is a source directory
225                if test -f $withval/src/slang.h; then
226                        mutt_cv_slang=$withval/src
227                        CPPFLAGS="$CPPFLAGS -I${mutt_cv_slang}"
228                        LDFLAGS="$LDFLAGS -L${mutt_cv_slang}/objs"
229                else
230                        dnl ---Must be installed somewhere
231                        mutt_cv_slang=$withval
232                        if test -d $withval/include/slang; then
233                                CPPFLAGS="$CPPFLAGS -I${withval}/include/slang"
234                        elif test -d $withval/include; then
235                                CPPFLAGS="$CPPFLAGS -I${withval}/include"
236                        fi
237                        LDFLAGS="$LDFLAGS -L${withval}/lib"
238                fi
239        fi
240        AC_MSG_RESULT($mutt_cv_slang)
241        if test $mutt_cv_bsdish = yes; then
242                AC_CHECK_LIB(termlib, main)
243        fi
244        AC_DEFINE(USE_SLANG_CURSES,1,
245                [ Define if you compile with SLang instead of curses/ncurses. ])
246        AC_DEFINE(HAVE_COLOR,1,[ Define if your curses library supports color. ])
247        MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS resize.o"
248
249        dnl --- now that we've found it, check the link
250
251        AC_CHECK_LIB(slang, SLtt_get_terminfo,
252                [MUTTLIBS="$MUTTLIBS -lslang -lm"],
253                [AC_MSG_ERROR(unable to compile.  check config.log)], -lm)
254
255        ],
256
257        [mutt_cv_curses=/usr
258        AC_ARG_WITH(curses, AC_HELP_STRING([--with-curses=DIR], [Where ncurses is installed]),
259                [if test $withval != yes; then
260                        mutt_cv_curses=$withval
261                fi
262                if test x$mutt_cv_curses != x/usr; then
263                        LDFLAGS="$LDFLAGS -L${mutt_cv_curses}/lib"
264                        CPPFLAGS="$CPPFLAGS -I${mutt_cv_curses}/include"
265                fi])
266
267	AC_CHECK_FUNC(initscr,,[
268	cf_ncurses="ncurses"
269	for lib in ncurses ncursesw
270	do
271		AC_CHECK_LIB($lib, waddnwstr, [cf_ncurses="$lib"; break])
272	done
273        AC_CHECK_LIB($cf_ncurses, initscr,
274                [MUTTLIBS="$MUTTLIBS -l$cf_ncurses"
275
276                if test "$cf_ncurses" = ncursesw; then
277			AC_CHECK_HEADERS(ncursesw/ncurses.h,[cf_cv_ncurses_header="ncursesw/ncurses.h"])
278		else
279                  AC_CHECK_HEADERS(ncurses/ncurses.h,[cf_cv_ncurses_header="ncurses/ncurses.h"],
280                    [AC_CHECK_HEADERS(ncurses.h,[cf_cv_ncurses_header="ncurses.h"])])
281		fi],
282
283                [CF_CURSES_LIBS])
284		])
285
286        old_LIBS="$LIBS"
287        LIBS="$LIBS $MUTTLIBS"
288        CF_CHECK_FUNCDECLS([#include <${cf_cv_ncurses_header-curses.h}>],
289                           [start_color typeahead bkgdset curs_set meta use_default_colors resizeterm])
290        if test "$ac_cv_func_decl_start_color" = yes; then
291                AC_DEFINE(HAVE_COLOR,1,[ Define if your curses library supports color. ])
292        fi
293        if test "$ac_cv_func_decl_resizeterm" = yes; then
294                MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS resize.o"
295        fi
296        LIBS="$old_LIBS"
297        ])
298
299AC_HEADER_STDC
300
301AC_CHECK_HEADERS(stdarg.h sys/ioctl.h ioctl.h sysexits.h)
302AC_CHECK_HEADERS(sys/time.h sys/resource.h)
303AC_CHECK_HEADERS(unix.h)
304
305AC_CHECK_FUNCS(setrlimit getsid)
306
307AC_TYPE_SIGNAL
308
309AC_MSG_CHECKING(for sig_atomic_t in signal.h)
310AC_EGREP_HEADER(sig_atomic_t,signal.h,
311  [
312    ac_cv_type_sig_atomic_t=yes;
313    AC_EGREP_HEADER(volatile.*sig_atomic_t,
314                    signal.h,
315                    [
316                        is_sig_atomic_t_volatile=yes;
317                        AC_MSG_RESULT([yes, volatile])
318                    ],
319                    [
320                        is_sig_atomic_t_volatile=no;
321                        AC_MSG_RESULT([yes, non volatile])
322                    ])
323  ],
324  [
325    AC_MSG_RESULT(no)
326    AC_CHECK_TYPE(sig_atomic_t, int)
327    is_sig_atomic_t_volatile=no
328  ])
329if test $is_sig_atomic_t_volatile = 'yes'
330then
331    AC_DEFINE(SIG_ATOMIC_VOLATILE_T, sig_atomic_t)
332else
333    AC_DEFINE(SIG_ATOMIC_VOLATILE_T, [volatile sig_atomic_t])
334fi
335
336AC_DECL_SYS_SIGLIST
337
338AC_TYPE_PID_T
339AC_CHECK_TYPE(ssize_t, int)
340
341AC_CHECK_FUNCS(fgetpos memmove setegid srand48 strerror)
342
343AC_REPLACE_FUNCS([setenv strcasecmp strdup strsep strtok_r wcscasecmp])
344AC_REPLACE_FUNCS([strcasestr mkdtemp])
345
346AC_CHECK_FUNC(getopt)
347if test $ac_cv_func_getopt = yes; then
348        AC_CHECK_HEADERS(getopt.h)
349fi
350
351SNPRINTFOBJS=""
352AC_CHECK_FUNC(snprintf, [mutt_cv_func_snprintf=yes], [mutt_cv_func_snprintf=no])
353AC_CHECK_FUNC(vsnprintf, [mutt_cv_func_vsnprintf=yes], [mutt_cv_func_vsnprintf=no])
354if test $mutt_cv_func_snprintf = yes; then
355AC_CACHE_CHECK([whether your system's snprintf is C99 compliant],
356        [mutt_cv_c99_snprintf],
357        AC_TRY_RUN([
358#include <stdio.h>
359int main()
360{
361changequote(, )dnl
362  char buf[8];
363  int len = snprintf(buf, 4, "1234567");
364  return (len != 7 || buf[3] != '\0');
365changequote([, ])dnl
366}
367        ], mutt_cv_c99_snprintf=yes, mutt_cv_c99_snprintf=no, mutt_cv_c99_snprintf=no))
368else
369        mutt_cv_c99_snprintf=no
370fi
371if test $mutt_cv_func_vsnprintf = yes; then
372AC_CACHE_CHECK([whether your system's vsnprintf is C99 compliant],
373        [mutt_cv_c99_vsnprintf],
374        AC_TRY_RUN([
375#include <stdarg.h>
376#include <stdio.h>
377int foo(const char *fmt, ...)
378{
379changequote(, )dnl
380  char buf[8];
381  int len;
382  va_list ap;
383  va_start(ap, fmt);
384  len = vsnprintf(buf, 4, fmt, ap);
385  va_end(ap);
386  return (len != 7 || buf[3] != '\0');
387changequote([, ])dnl
388}
389
390int main()
391{
392  return foo("%s", "1234567");
393}
394        ], mutt_cv_c99_vsnprintf=yes, mutt_cv_c99_vsnprintf=no, mutt_cv_c99_vsnprintf=no))
395else
396        mutt_cv_c99_vsnprintf=no
397fi
398if test $mutt_cv_c99_snprintf = yes; then
399        AC_DEFINE(HAVE_SNPRINTF, 1, [ Define to 1 if you have a C99 compliant snprintf function. ])
400fi
401if test $mutt_cv_c99_vsnprintf = yes; then
402        AC_DEFINE(HAVE_VSNPRINTF, 1, [ Define to 1 if you have a C99 compliant vsnprintf function. ])
403fi
404if test $mutt_cv_c99_snprintf = no -o $mutt_cv_c99_vsnprintf = no; then
405        AC_LIBOBJ(snprintf)
406fi
407
408XIPH_FUNC_VA_COPY
409
410dnl SCO uses chsize() instead of ftruncate()
411AC_CHECK_FUNCS(ftruncate, , [AC_CHECK_LIB(x, chsize)])
412
413dnl SCO has strftime() in libintl
414AC_CHECK_FUNCS(strftime, , [AC_CHECK_LIB(intl, strftime)])
415
416dnl AIX may not have fchdir()
417AC_CHECK_FUNCS(fchdir, , [mutt_cv_fchdir=no])
418
419AC_ARG_WITH(regex, AC_HELP_STRING([--with-regex], [Use the GNU regex library]),
420        [mutt_cv_regex=yes],
421        [AC_CHECK_FUNCS(regcomp, mutt_cv_regex=no, mutt_cv_regex=yes)])
422
423if test $mutt_cv_regex = no ; then
424AC_CACHE_CHECK([whether your system's regexp library is completely broken],
425        [mutt_cv_regex_broken],
426        AC_TRY_RUN([
427#include <unistd.h>
428#include <regex.h>
429main() { regex_t blah ; regmatch_t p; p.rm_eo = p.rm_eo; return regcomp(&blah, "foo.*bar", REG_NOSUB) || regexec (&blah, "foobar", 0, NULL, 0); }],
430        mutt_cv_regex_broken=no, mutt_cv_regex_broken=yes, mutt_cv_regex_broken=yes))
431        if test $mutt_cv_regex_broken = yes ; then
432                echo "Using the included GNU regex instead." >&AC_FD_MSG
433                mutt_cv_regex=yes
434        fi
435fi
436
437if test $mutt_cv_regex = yes; then
438        AC_DEFINE(USE_GNU_REGEX,1,[ Define if you want to use the included regex.c. ])
439        AC_LIBOBJ(regex)
440fi
441
442
443AC_ARG_WITH(homespool,
444  AC_HELP_STRING([--with-homespool@<:@=FILE@:>@], [File in user's directory where new mail is spooled]), with_homespool=${withval})
445if test x$with_homespool != x; then
446        if test $with_homespool = yes; then
447                with_homespool=mailbox
448        fi
449        AC_DEFINE_UNQUOTED(MAILPATH,"$with_homespool",[ Where new mail is spooled. ])
450        AC_DEFINE(HOMESPOOL,1,
451          [Is mail spooled to the user's home directory?  If defined,
452           MAILPATH should be set to the filename of the spool mailbox
453           relative the the home directory.
454           use: configure --with-homespool=FILE])
455        AC_DEFINE(USE_DOTLOCK,1,[ Define to use dotlocking for mailboxes. ])
456        mutt_cv_setgid=no
457else
458        AC_ARG_WITH(mailpath, AC_HELP_STRING([--with-mailpath=DIR], [Directory where spool mailboxes are located]),
459                [mutt_cv_mailpath=$withval],
460                [ AC_CACHE_CHECK(where new mail is stored, mutt_cv_mailpath,
461                        [mutt_cv_mailpath=no
462                        if test -d /var/mail; then
463                                mutt_cv_mailpath=/var/mail
464                        elif test -d /var/spool/mail; then
465                                mutt_cv_mailpath=/var/spool/mail
466                        elif test -d /usr/spool/mail; then
467                                mutt_cv_mailpath=/usr/spool/mail
468                        elif test -d /usr/mail; then
469                                mutt_cv_mailpath=/usr/mail
470                        fi])
471                ])
472        if test "$mutt_cv_mailpath" = no; then
473                AC_MSG_ERROR("Could not determine where new mail is stored.")
474        fi
475        AC_DEFINE_UNQUOTED(MAILPATH,"$mutt_cv_mailpath",[ Where new mail is spooled. ])
476
477        AC_CACHE_CHECK(if $mutt_cv_mailpath is world writable, mutt_cv_worldwrite, [AC_TRY_RUN([#include <sys/types.h>
478#include <sys/stat.h>
479#include <stdlib.h>
480
481int main (int argc, char **argv)
482{
483        struct stat s;
484
485        stat ("$mutt_cv_mailpath", &s);
486        if (s.st_mode & S_IWOTH) exit (0);
487        exit (1);
488}], mutt_cv_worldwrite=yes, mutt_cv_worldwrite=no, mutt_cv_worldwrite=no)])
489
490        mutt_cv_setgid=no
491        if test $mutt_cv_worldwrite = yes; then
492                AC_DEFINE(USE_DOTLOCK,1,[ Define to use dotlocking for mailboxes. ])
493        else
494
495                AC_CACHE_CHECK(if $mutt_cv_mailpath is group writable, mutt_cv_groupwrite, [AC_TRY_RUN([#include <sys/types.h>
496#include <sys/stat.h>
497#include <stdlib.h>
498
499int main (int argc, char **argv)
500{
501        struct stat s;
502
503        stat ("$mutt_cv_mailpath", &s);
504        if (s.st_mode & S_IWGRP) exit (0);
505        exit (1);
506}], mutt_cv_groupwrite=yes, mutt_cv_groupwrite=no, mutt_cv_groupwrite=no)])
507
508                if test $mutt_cv_groupwrite = yes; then
509                        AC_DEFINE(USE_DOTLOCK,1,[ Define to use dotlocking for mailboxes. ])
510                        AC_DEFINE(USE_SETGID,1,[ Define if mutt should run setgid "mail". ])
511                        mutt_cv_setgid=yes
512                fi
513        fi
514fi
515
516AC_ARG_ENABLE(external_dotlock, AC_HELP_STRING([--enable-external-dotlock], [Force use of an external dotlock program]),
517        [mutt_cv_external_dotlock="$enableval"])
518
519if test "x$mutt_cv_setgid" = "xyes" || test "x$mutt_cv_fchdir" = "xno" \
520        || test "x$mutt_cv_external_dotlock" = "xyes"
521then
522        AC_DEFINE(DL_STANDALONE,1,[ Define if you want to use an external dotlocking program. ])
523        DOTLOCK_TARGET="mutt_dotlock\$(EXEEXT)"
524else
525        MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS dotlock.o"
526fi
527
528AC_SUBST(DOTLOCK_TARGET)
529
530dnl autoconf <2.60 compatibility
531if test -z "$datarootdir"; then
532  datarootdir='${prefix}/share'
533fi
534AC_SUBST([datarootdir])
535
536AC_MSG_CHECKING(where to put the documentation)
537AC_ARG_WITH(docdir, AC_HELP_STRING([--with-docdir=PATH], [Specify where to put the documentation]),
538        [mutt_cv_docdir=$withval],
539        [mutt_cv_docdir='${datarootdir}/doc/mutt'])
540AC_MSG_RESULT($mutt_cv_docdir)
541if test -z "$docdir" -o -n "$with_docdir"
542then
543  docdir=$mutt_cv_docdir
544fi
545AC_SUBST(docdir)
546
547if test x$mutt_cv_setgid = xyes; then
548        DOTLOCK_GROUP='mail'
549        DOTLOCK_PERMISSION=2755
550else
551        DOTLOCK_GROUP=''
552        DOTLOCK_PERMISSION=755
553fi
554AC_SUBST(DOTLOCK_GROUP)
555AC_SUBST(DOTLOCK_PERMISSION)
556
557AC_ARG_WITH(domain, AC_HELP_STRING([--with-domain=DOMAIN], [Specify your DNS domain name]),
558        [if test $withval != yes; then
559            if test $withval != no; then
560                AC_DEFINE_UNQUOTED(DOMAIN,"$withval",[ Define your domain name. ])
561            fi
562        fi])
563
564need_socket="no"
565
566dnl -- socket dependencies --
567
568AC_ARG_ENABLE(pop,  AC_HELP_STRING([--enable-pop], [Enable POP3 support]),
569[       if test x$enableval = xyes ; then
570                AC_DEFINE(USE_POP,1,[ Define if you want support for the POP3 protocol. ])
571                MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS pop.o pop_lib.o pop_auth.o"
572                need_pop="yes"
573                need_socket="yes"
574                need_md5="yes"
575        fi
576])
577
578AC_ARG_ENABLE(imap, AC_HELP_STRING([--enable-imap], [Enable IMAP support]),
579[       if test x$enableval = xyes ; then
580                AC_DEFINE(USE_IMAP,1,[ Define if you want support for the IMAP protocol. ])
581                LIBIMAP="-Limap -limap"
582                LIBIMAPDEPS="\$(top_srcdir)/imap/imap.h imap/libimap.a"
583                need_imap="yes"
584                need_socket="yes"
585                need_md5="yes"
586        fi
587])
588AM_CONDITIONAL(BUILD_IMAP, test x$need_imap = xyes)
589
590AC_ARG_ENABLE(smtp, AC_HELP_STRING([--enable-smtp], [include internal SMTP relay support]),
591	[if test $enableval = yes; then
592		AC_DEFINE(USE_SMTP, 1, [Include internal SMTP relay support])
593            	MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS smtp.o"
594		need_socket="yes"
595	fi])
596
597if test x"$need_imap" = xyes -o x"$need_pop" = xyes ; then
598  MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS bcache.o"
599fi
600
601dnl -- end socket dependencies --
602
603if test "$need_socket" = "yes"
604then
605        AC_CHECK_HEADERS([sys/select.h])
606        AC_MSG_CHECKING([for socklen_t])
607        AC_EGREP_HEADER(socklen_t, sys/socket.h, AC_MSG_RESULT([yes]),
608                AC_MSG_RESULT([no])
609                AC_DEFINE(socklen_t,int,
610                        [ Define to 'int' if <sys/socket.h> doesn't have it. ]))
611        AC_CHECK_FUNC(gethostent, , AC_CHECK_LIB(nsl, gethostent))
612        AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt))
613        AC_CHECK_FUNCS(getaddrinfo)
614        AC_DEFINE(USE_SOCKET,1,
615                [ Include code for socket support. Set automatically if you enable POP3 or IMAP ])
616        MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS account.o mutt_socket.o mutt_tunnel.o"
617fi
618
619dnl -- imap dependencies --
620
621AC_ARG_WITH(gss, AC_HELP_STRING([--with-gss@<:@=PFX@:>@], [Compile in GSSAPI authentication for IMAP]),
622    gss_prefix="$withval", gss_prefix="no")
623if test "$gss_prefix" != "no"
624then
625  if test "$need_imap" = "yes"
626  then
627    MUTT_AM_PATH_GSSAPI(gss_prefix)
628    AC_MSG_CHECKING(GSSAPI implementation)
629    AC_MSG_RESULT($GSSAPI_IMPL)
630    if test "$GSSAPI_IMPL" = "none"
631    then
632      AC_CACHE_SAVE
633      AC_MSG_RESULT([GSSAPI libraries not found])
634    fi
635    if test "$GSSAPI_IMPL" = "Heimdal"
636    then
637      AC_DEFINE(HAVE_HEIMDAL,1,[ Define if your GSSAPI implementation is Heimdal ])
638    fi
639    CPPFLAGS="$CPPFLAGS $GSSAPI_CFLAGS"
640    MUTTLIBS="$MUTTLIBS $GSSAPI_LIBS"
641    AC_DEFINE(USE_GSS,1,[ Define if you have GSSAPI libraries available ])
642    need_gss="yes"
643  else
644    AC_MSG_WARN([GSS was requested but IMAP is not enabled])
645  fi
646fi
647AM_CONDITIONAL(USE_GSS, test x$need_gss = xyes)
648
649dnl -- end imap dependencies --
650
651AC_ARG_WITH(ssl, AC_HELP_STRING([--with-ssl@<:@=PFX@:>@], [Enable TLS support using OpenSSL]),
652[       if test "$with_ssl" != "no"
653        then
654          if test "$need_socket" != "yes"; then
655           AC_MSG_WARN([SSL support is only useful with POP, IMAP or SMTP support])
656	  else
657            if test "$with_ssl" != "yes"
658            then
659             LDFLAGS="$LDFLAGS -L$withval/lib"
660             CPPFLAGS="$CPPFLAGS -I$withval/include"
661            fi
662            saved_LIBS="$LIBS"
663
664            crypto_libs=""
665            AC_CHECK_LIB(z, deflate, [crypto_libs=-lz])
666            AC_CHECK_LIB(crypto, X509_new,
667              [crypto_libs="-lcrypto $crypto_libs"],, [$crypto_libs])
668            AC_CHECK_LIB(ssl, SSL_new,,
669              AC_MSG_ERROR([Unable to find SSL library]), [$crypto_libs])
670
671            LIBS="$LIBS $crypto_libs"
672            AC_CHECK_FUNCS(RAND_status RAND_egd)
673
674            AC_DEFINE(USE_SSL,1,[ Define if you want support for SSL. ])
675            AC_DEFINE(USE_SSL_OPENSSL,1,[ Define if you want support for SSL via OpenSSL. ])
676            LIBS="$saved_LIBS"
677            MUTTLIBS="$MUTTLIBS -lssl $crypto_libs"
678            MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS mutt_ssl.o"
679            need_ssl=yes
680          fi
681        fi
682])
683
684AC_ARG_WITH([gnutls], AC_HELP_STRING([--with-gnutls@<:@=PFX@:>@], [enable TLS support using gnutls]),
685    [gnutls_prefix="$withval"], [gnutls_prefix="no"])
686if test "$gnutls_prefix" != "no" && test x"$need_ssl" != xyes
687then
688  if test "$need_socket" != "yes"
689  then
690    AC_MSG_WARN([SSL support is only useful with POP, IMAP or SMTP support])
691  else
692    if test "$gnutls_prefix" != "yes"
693    then
694      LDFLAGS="$LDFLAGS -L$gnutls_prefix/lib"
695      CPPFLAGS="$CPPFLAGS -I$gnutls_prefix/include"
696    fi
697    saved_LIBS="$LIBS"
698
699    AC_CHECK_LIB(gnutls, gnutls_check_version,
700      [dnl GNUTLS found
701      AC_CHECK_DECLS([GNUTLS_VERIFY_DISABLE_TIME_CHECKS], [], [],
702                    [[#include <gnutls/x509.h>]])
703
704      LIBS="$saved_LIBS"
705      MUTTLIBS="$MUTTLIBS -lgnutls"
706
707      AC_DEFINE(USE_SSL, 1, [ Define if you want support for SSL. ])
708      AC_DEFINE(USE_SSL_GNUTLS, 1, [ Define if you want support for SSL via GNUTLS. ])
709
710      MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS mutt_ssl_gnutls.o"
711      need_ssl=yes],
712      [AC_MSG_ERROR([could not find libgnutls])])
713  fi
714fi
715
716AM_CONDITIONAL(USE_SSL, test x$need_ssl = xyes)
717
718AC_ARG_WITH(sasl, AC_HELP_STRING([--with-sasl@<:@=PFX@:>@], [Use SASL network security library]),
719        [
720        if test "$with_sasl" != "no"
721        then
722          if test "$need_socket" != "yes"
723          then
724            AC_MSG_ERROR([SASL support is only useful with POP or IMAP support])
725          fi
726
727          if test "$with_sasl" != "yes"
728          then
729            CPPFLAGS="$CPPFLAGS -I$with_sasl/include"
730            LDFLAGS="$LDFLAGS -L$with_sasl/lib"
731          fi
732
733          saved_LIBS="$LIBS"
734          LIBS=
735
736          # OpenSolaris provides a SASL2 interface in libsasl
737          sasl_libs="sasl2 sasl"
738          AC_SEARCH_LIBS(sasl_encode64, [$sasl_libs],,
739                  AC_MSG_ERROR([could not find sasl lib]),)
740
741          MUTTLIBS="$MUTTLIBS $LIBS"
742          MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS mutt_sasl.o"
743          LIBS="$saved_LIBS"
744
745          AC_DEFINE(USE_SASL,1,
746                  [ Define if want to use the SASL library for POP/IMAP authentication. ])
747          need_sasl=yes
748        fi
749        ])
750AM_CONDITIONAL(USE_SASL, test x$need_sasl = xyes)
751
752dnl -- end socket --
753
754AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging support]),
755        [ if test x$enableval = xyes ; then
756                AC_DEFINE(DEBUG,1,[ Define to enable debugging info. ])
757          fi
758         ])
759
760AC_ARG_ENABLE(flock, AC_HELP_STRING([--enable-flock], [Use flock() to lock files]),
761        [if test $enableval = yes; then
762                AC_DEFINE(USE_FLOCK,1, [ Define to use flock() to lock mailboxes. ])
763        fi])
764
765mutt_cv_fcntl=yes
766AC_ARG_ENABLE(fcntl, AC_HELP_STRING([--disable-fcntl], [Do NOT use fcntl() to lock files]),
767        [if test $enableval = no; then mutt_cv_fcntl=no; fi])
768
769if test $mutt_cv_fcntl = yes; then
770        AC_DEFINE(USE_FCNTL,1, [ Define to use fcntl() to lock folders. ])
771fi
772
773AC_MSG_CHECKING(whether struct dirent defines d_ino)
774ac_cv_dirent_d_ino=no
775AC_TRY_LINK([#include <dirent.h>],[struct dirent dp; (void)dp.d_ino],[ac_cv_dirent_d_ino=yes])
776if test x$ac_cv_dirent_d_ino = xyes ; then
777  AC_DEFINE(HAVE_DIRENT_D_INO,1,
778            [Define to 1 if your system has the dirent::d_ino member])
779fi
780AC_MSG_RESULT($ac_cv_dirent_d_ino)
781
782mutt_cv_warnings=yes
783AC_ARG_ENABLE(warnings, AC_HELP_STRING([--disable-warnings], [Turn off compiler warnings (not recommended)]),
784[if test $enableval = no; then
785        mutt_cv_warnings=no
786fi])
787
788if test x$GCC = xyes && test $mutt_cv_warnings = yes; then
789  CFLAGS="-Wall -pedantic -Wno-long-long $CFLAGS"
790fi
791
792AC_ARG_ENABLE(nfs-fix, AC_HELP_STRING([--enable-nfs-fix], [Work around an NFS with broken attributes caching]),
793        [if test x$enableval = xyes; then
794                AC_DEFINE(NFS_ATTRIBUTE_HACK,1,
795                  [Define if you have problems with mutt not detecting
796                   new/old mailboxes over NFS.  Some NFS implementations
797                   incorrectly cache the attributes of small files.])
798        fi])
799
800AC_ARG_ENABLE(mailtool, AC_HELP_STRING([--enable-mailtool], [Enable Sun mailtool attachments support]),
801        [if test x$enableval = xyes; then
802                AC_DEFINE(SUN_ATTACHMENT,1,[ Define to enable Sun mailtool attachments support. ])
803        fi])
804
805AC_ARG_ENABLE(locales-fix, AC_HELP_STRING([--enable-locales-fix], [The result of isprint() is unreliable]),
806        [if test x$enableval = xyes; then
807                AC_DEFINE(LOCALES_HACK,1,[ Define if the result of isprint() is unreliable. ])
808        fi])
809
810AC_ARG_WITH(exec-shell, AC_HELP_STRING([--with-exec-shell=SHELL], [Specify alternate shell (ONLY if /bin/sh is broken)]),
811        [if test $withval != yes; then
812                AC_DEFINE_UNQUOTED(EXECSHELL, "$withval",
813                 [program to use for shell commands])
814         else
815                AC_DEFINE_UNQUOTED(EXECSHELL, "/bin/sh")
816        fi],
817        [AC_DEFINE_UNQUOTED(EXECSHELL, "/bin/sh")])
818
819AC_ARG_ENABLE(exact-address, AC_HELP_STRING([--enable-exact-address], [Enable regeneration of email addresses]),
820        [if test $enableval = yes; then
821                AC_DEFINE(EXACT_ADDRESS,1,
822                  [Enable exact regeneration of email addresses as parsed?
823                   NOTE: this requires significant more memory when defined.])
824
825        fi])
826
827dnl -- start cache --
828db_found=no
829db_requested=auto
830AC_ARG_ENABLE(hcache, AC_HELP_STRING([--enable-hcache],
831  [Enable header caching]))
832AC_ARG_WITH(tokyocabinet, AC_HELP_STRING([--without-tokyocabinet],
833  [Don't use tokyocabinet even if it is available]))
834AC_ARG_WITH(qdbm, AC_HELP_STRING([--without-qdbm],
835  [Don't use qdbm even if it is available]))
836AC_ARG_WITH(gdbm, AC_HELP_STRING([--without-gdbm],
837  [Don't use gdbm even if it is available]))
838AC_ARG_WITH(bdb, AC_HELP_STRING([--with-bdb@<:@=DIR@:>@],
839  [Use BerkeleyDB4 if gdbm is not available]))
840
841db_found=no
842if test x$enable_hcache = xyes
843then
844    AC_DEFINE(USE_HCACHE, 1, [Enable header caching])
845    MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS hcache.o"
846
847    OLDCPPFLAGS="$CPPFLAGS"
848    OLDLDFLAGS="$LDFLAGS"
849    OLDLIBS="$LIBS"
850
851    need_md5="yes"
852
853    if test -n "$with_tokyocabinet" && test "$with_tokyocabinet" != "no"
854    then
855      db_requested=tc
856    fi
857    if test -n "$with_qdbm" && test "$with_qdbm" != "no"
858    then
859      if test "$db_requested" != "auto"
860      then
861        AC_MSG_ERROR([more than one header cache engine requested.])
862      else
863        db_requested=qdbm
864      fi
865    fi
866    if test -n "$with_gdbm" && test "$with_gdbm" != "no"
867    then
868      if test "$db_requested" != "auto"
869      then
870        AC_MSG_ERROR([more than one header cache engine requested.])
871      else
872        db_requested=gdbm
873      fi
874    fi
875    if test -n "$with_bdb" && test "$with_bdb" != "no"
876    then
877      if test "$db_requested" != "auto"
878      then
879        AC_MSG_ERROR([more than one header cache engine requested.])
880      else
881        db_requested=bdb
882      fi
883    fi
884
885    dnl -- Tokyo Cabinet --
886    if test "$with_tokyocabinet" != "no" \
887	    && test "$db_requested" = auto -o "$db_requested" = tc
888    then
889      if test -n "$with_tokyocabinet" && test "$with_tokyocabinet" != "yes"
890      then
891        CPPFLAGS="$CPPFLAGS -I$with_tokyocabinet/include"
892        LDFLAGS="$LDFLAGS -L$with_tokyocabinet/lib"
893      fi
894
895      AC_CHECK_HEADER(tcbdb.h,
896      AC_CHECK_LIB(tokyocabinet, tcbdbopen,
897        [MUTTLIBS="$MUTTLIBS -ltokyocabinet"
898         AC_DEFINE(HAVE_TC, 1, [Tokyo Cabinet Support])
899         db_found=tc],
900        [CPPFLAGS="$OLDCPPFLAGS"
901         LDFLAGS="$OLDLDFLAGS"]))
902      if test "$db_requested" != auto && test "$db_found" != "$db_requested"
903      then
904        AC_MSG_ERROR([Tokyo Cabinet could not be used. Check config.log for details.])
905      fi
906    fi
907
908    dnl -- QDBM --
909    if test "$with_qdbm" != "no" && test $db_found = no \
910	    && test "$db_requested" = auto -o "$db_requested" = qdbm
911    then
912      if test -n "$with_qdbm" && test "$with_qdbm" != "yes"
913      then
914        if test -d $with_qdbm/include/qdbm; then
915          CPPFLAGS="$CPPFLAGS -I$with_qdbm/include/qdbm"
916	else
917          CPPFLAGS="$CPPFLAGS -I$with_qdbm/include"
918	fi
919        LDFLAGS="$LDFLAGS -L$with_qdbm/lib"
920      else
921         if test -d /usr/include/qdbm; then
922           CPPFLAGS="$CPPFLAGS -I/usr/include/qdbm"
923	 fi
924      fi
925
926      saved_LIBS="$LIBS"
927      AC_CHECK_HEADERS(villa.h)
928      AC_CHECK_LIB(qdbm, vlopen,
929        [MUTTLIBS="$MUTTLIBS -lqdbm"
930         AC_DEFINE(HAVE_QDBM, 1, [QDBM Support])
931         db_found=qdbm],
932        [CPPFLAGS="$OLDCPPFLAGS"
933         LDFLAGS="$OLDLDFLAGS"])
934      LIBS="$saved_LIBS"
935      if test "$db_requested" != auto && test "$db_found" != "$db_requested"
936      then
937        AC_MSG_ERROR([QDBM could not be used. Check config.log for details.])
938      fi
939    fi
940
941    dnl -- GDBM --
942    if test x$with_gdbm != xno && test $db_found = no \
943	    && test "$db_requested" = auto -o "$db_requested" = gdbm
944    then
945        if test "$with_gdbm" != "yes"
946        then
947          CPPFLAGS="$CPPFLAGS -I$with_gdbm/include"
948          LDFLAGS="$LDFLAGS -L$with_gdbm/lib"
949        fi
950        saved_LIBS="$LIBS"
951        LIBS="$LIBS -lgdbm"
952        AC_CACHE_CHECK(for gdbm_open, ac_cv_gdbmopen,[
953            ac_cv_gdbmopen=no
954            AC_TRY_LINK([#include <gdbm.h>],[gdbm_open(0,0,0,0,0);],[ac_cv_gdbmopen=yes])
955        ])
956        LIBS="$saved_LIBS"
957        if test "$ac_cv_gdbmopen" = yes
958        then
959          AC_DEFINE(HAVE_GDBM, 1, [GDBM Support])
960          MUTTLIBS="$MUTTLIBS -lgdbm"
961          db_found=gdbm
962        fi
963        if test "$db_requested" != auto && test "$db_found" != "$db_requested"
964        then
965          AC_MSG_ERROR([GDBM could not be used. Check config.log for details.])
966        fi
967    fi
968
969    dnl -- BDB --
970    ac_bdb_prefix="$with_bdb"
971    if test x$ac_bdb_prefix != xno && test $db_found = no
972    then
973        if test x$ac_bdb_prefix = xyes || test x$ac_bdb_prefix = x
974        then
975          ac_bdb_prefix="$mutt_cv_prefix /opt/csw/bdb4 /opt /usr/local /usr"
976        fi
977        for d in $ac_bdb_prefix; do
978            bdbpfx="$bdbpfx $d"
979            for v in BerkeleyDB.4.3 BerkeleyDB.4.2 BerkeleyDB.4.1; do
980                bdbpfx="$bdbpfx $d/$v"
981            done
982        done
983        BDB_VERSIONS="db-4 db4 db-4.6 db4.6 db46 db-4.5 db4.5 db45 db-4.4 db4.4 db44 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db ''"
984        AC_MSG_CHECKING([for BerkeleyDB > 4.0])
985        for d in $bdbpfx; do
986            BDB_INCLUDE_DIR=""
987            BDB_LIB_DIR=""
988            for v in / $BDB_VERSIONS; do
989                if test -r "$d/include/$v/db.h"; then
990                    BDB_INCLUDE_DIR="$d/include/$v"
991                    for bdblibdir in "$d/lib/$v" "$d/lib"; do
992                        test -d "$bdblibdir" || continue
993                        BDB_LIB_DIR="$bdblibdir"
994                        for l in `echo $BDB_VERSIONS`; do
995                            CPPFLAGS="$OLDCPPFLAGS -I$BDB_INCLUDE_DIR"
996                            LIBS="$OLDLIBS -L$BDB_LIB_DIR -l$l"
997                            AC_TRY_LINK([
998                                #include <stdlib.h>
999                                #include <db.h>
1000                            ],[
1001                                DB *db = NULL;
1002                                db->open(db,NULL,NULL,NULL,0,0,0);
1003                            ],[
1004                                ac_cv_dbcreate=yes
1005                                BDB_LIB="$l"
1006                                break
1007                            ])
1008                        done
1009                        test x$ac_cv_dbcreate = xyes && break 2
1010                    done
1011                fi
1012            done
1013            test x$BDB_LIB != x && break
1014        done
1015        if test x$ac_cv_dbcreate = xyes
1016        then
1017            AC_MSG_RESULT(yes)
1018            CPPFLAGS="$OLDCPPFLAGS -I$BDB_INCLUDE_DIR"
1019            LIBS="$OLDLIBS -L$BDB_LIB_DIR -l$BDB_LIB"
1020            AC_DEFINE(HAVE_DB4, 1, [Berkeley DB4 Support])
1021            db_found=bdb
1022        else
1023            AC_MSG_RESULT(no)
1024        fi
1025    fi
1026
1027    if test $db_found = no
1028    then
1029        AC_MSG_ERROR([You need Tokyo Cabinet, QDBM, GDBM or Berkeley DB4 for hcache])
1030    fi
1031fi
1032dnl -- end cache --
1033
1034AM_CONDITIONAL(BUILD_HCACHE, test x$db_found != xno)
1035
1036if test "$need_md5" = "yes"
1037then
1038  MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS md5.o"
1039fi
1040
1041if test x$db_found != xno ; then
1042  MUTT_MD5="mutt_md5$EXEEXT"
1043fi
1044AC_SUBST(MUTT_MD5)
1045
1046AC_SUBST(MUTTLIBS)
1047AC_SUBST(MUTT_LIB_OBJECTS)
1048AC_SUBST(LIBIMAP)
1049AC_SUBST(LIBIMAPDEPS)
1050
1051dnl -- iconv/gettext --
1052
1053AC_ARG_ENABLE(iconv, AC_HELP_STRING([--disable-iconv], [Disable iconv support]),
1054        [if test x$enableval = xno ; then
1055                am_cv_func_iconv=no
1056        fi
1057])
1058
1059MUTT_AM_GNU_GETTEXT
1060
1061if test "$am_cv_func_iconv" != "yes"
1062then
1063  AC_MSG_WARN([Configuring without iconv support. See INSTALL for details])
1064else
1065
1066AC_CHECK_HEADERS(iconv.h,
1067        [AC_MSG_CHECKING(whether iconv.h defines iconv_t)
1068         AC_EGREP_HEADER([typedef.*iconv_t],iconv.h,
1069                [AC_MSG_RESULT(yes)
1070                 AC_DEFINE(HAVE_ICONV_T_DEF, 1,
1071                        [Define if <iconv.h> defines iconv_t.])],
1072                 AC_MSG_RESULT(no))])
1073
1074dnl (1) Some implementations of iconv won't convert from UTF-8 to UTF-8.
1075dnl (2) In glibc-2.1.2 and earlier there is a bug that messes up ob and
1076dnl     obl when args 2 and 3 are 0 (fixed in glibc-2.1.3).
1077AC_CACHE_CHECK([whether this iconv is good enough], mutt_cv_iconv_good,
1078        mutt_save_LIBS="$LIBS"
1079        LIBS="$LIBS $LIBICONV"
1080        AC_TRY_RUN([
1081#include <iconv.h>
1082int main()
1083{
1084  iconv_t cd;
1085changequote(, )dnl
1086  char buf[4];
1087changequote([, ])dnl
1088  char *ob;
1089  size_t obl;
1090  ob = buf, obl = sizeof(buf);
1091  return ((cd = iconv_open("UTF-8", "UTF-8")) != (iconv_t)(-1) &&
1092          (iconv(cd, 0, 0, &ob, &obl) ||
1093           !(ob == buf && obl == sizeof(buf)) ||
1094           iconv_close(cd)));
1095}
1096                ],
1097                mutt_cv_iconv_good=yes,
1098                mutt_cv_iconv_good=no,
1099                mutt_cv_iconv_good=yes)
1100        LIBS="$mutt_save_LIBS")
1101if test "$mutt_cv_iconv_good" = no; then
1102  AC_MSG_ERROR(Try using libiconv instead)
1103fi
1104
1105dnl This is to detect implementations such as the one in glibc-2.1,
1106dnl which always convert exactly but return the number of characters
1107dnl converted instead of the number converted inexactly.
1108AC_CACHE_CHECK([whether iconv is non-transcribing], mutt_cv_iconv_nontrans,
1109        mutt_save_LIBS="$LIBS"
1110        LIBS="$LIBS $LIBICONV"
1111        AC_TRY_RUN([
1112#include <iconv.h>
1113#include <string.h>
1114int main()
1115{
1116  iconv_t cd;
1117  const char *ib;
1118  char *ob;
1119  size_t ibl, obl;
1120  const char *s = "\304\211";
1121changequote(, )dnl
1122  char t[3];
1123changequote([, ])dnl
1124  ib = s, ibl = 2, ob = t, obl = 3;
1125  return ((cd = iconv_open("UTF-8", "UTF-8")) == (iconv_t)(-1) ||
1126          iconv(cd, &ib, &ibl, &ob, &obl));
1127}
1128                ],
1129                mutt_cv_iconv_nontrans=no,
1130                mutt_cv_iconv_nontrans=yes,
1131                mutt_cv_iconv_nontrans=no)
1132        LIBS="$mutt_save_LIBS")
1133if test "$mutt_cv_iconv_nontrans" = yes; then
1134  AC_DEFINE(ICONV_NONTRANS, 1)
1135else
1136  AC_DEFINE(ICONV_NONTRANS, 0)
1137fi
1138
1139CPPFLAGS="$CPPFLAGS -I\$(top_srcdir)/intl"
1140
1141if test "$BUILD_INCLUDED_LIBINTL" = "yes"; then
1142  AC_DEFINE(HAVE_BIND_TEXTDOMAIN_CODESET,1,
1143          [ Define if your gettext has bind_textdomain_codeset. ])
1144else
1145  mutt_save_LIBS="$LIBS"
1146  LIBS="$LIBS $INTLLIBS"
1147  AC_CHECK_FUNCS(bind_textdomain_codeset)
1148  LIBS="$mutt_save_LIBS"
1149fi
1150
1151fi # libiconv
1152
1153dnl -- IDN depends on iconv
1154
1155AC_ARG_WITH(idn, AC_HELP_STRING([--with-idn=@<:@PFX@:>@], [Use GNU libidn for domain names]),
1156		 [
1157		  if test "$with_idn" != "no" ; then
1158		  	if test "$with_idn" != "yes" ; then
1159			   CPPFLAGS="$CPPFLAGS -I$with_idn/include"
1160			   LDFLAGS="$LDFLAGS -L$with_idn/lib"
1161			fi
1162		  fi
1163		 ]
1164)
1165
1166if test "x$with_idn" != "xno"; then
1167  if test "$am_cv_func_iconv" != "yes"
1168  then
1169    if test "x$with_idn" != "x"
1170    then
1171      AC_MSG_ERROR([IDN requested but iconv is disabled or unavailable])
1172    fi
1173  else
1174    AC_SEARCH_LIBS([stringprep_check_version], [idn], [
1175      AC_DEFINE([HAVE_LIBIDN], 1, [Define to 1 if you have the `idn' library])
1176      MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS mutt_idna.o"
1177    ])
1178    AC_CHECK_FUNCS(idna_to_unicode_utf8_from_utf8 idna_to_unicode_8z8z)
1179    AC_CHECK_FUNCS(idna_to_ascii_from_utf8 idna_to_ascii_8z)
1180    AC_CHECK_FUNCS(idna_to_ascii_lz idna_to_ascii_from_locale)
1181  fi
1182fi
1183
1184dnl -- locales --
1185
1186AC_ARG_ENABLE(cjk-ambiguous-width, AC_HELP_STRING([--enable-cjk-ambiguous-width], [ Enable East Asian Ambiguous characters support (using own wcwidth)]),
1187        [ if test "x$enableval" = "xyes" ; then
1188               cjk_width=yes
1189          fi
1190       ])
1191if test "x$cjk_width" = "xyes" ; then
1192       AC_DEFINE(ENABLE_CJK_WIDTH,1,[ Define if you want to support East Asian Ambiguous class. ])
1193       MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS wcwidth.o"
1194fi
1195
1196AC_CHECK_HEADERS(wchar.h)
1197
1198AC_CACHE_CHECK([for wchar_t], mutt_cv_wchar_t,
1199        AC_TRY_COMPILE([
1200#include <stddef.h>
1201#include <stdlib.h>
1202#ifdef HAVE_WCHAR_H
1203#include <wchar.h>
1204#endif
1205                ],
1206                [ wchar_t wc; return 0; ],
1207                mutt_cv_wchar_t=yes,
1208                mutt_cv_wchar_t=no))
1209
1210if test "$mutt_cv_wchar_t" = no; then
1211        AC_DEFINE(wchar_t,int,[ Define to 'int' if system headers don't define. ])
1212fi
1213
1214AC_CACHE_CHECK([for wint_t], mutt_cv_wint_t,
1215        AC_TRY_COMPILE([
1216#include <stddef.h>
1217#include <stdlib.h>
1218#ifdef HAVE_WCHAR_H
1219#include <wchar.h>
1220#endif
1221                ],
1222                [ wint_t wc; return 0; ],
1223                mutt_cv_wint_t=yes,
1224                mutt_cv_wint_t=no))
1225
1226if test "$mutt_cv_wint_t" = no; then
1227        AC_DEFINE(wint_t,int,[ Define to 'int' if system headers don't define. ])
1228fi
1229
1230AC_CHECK_HEADERS(wctype.h)
1231AC_CHECK_FUNCS(iswalnum iswalpha iswblank iswcntrl iswdigit)
1232AC_CHECK_FUNCS(iswgraph iswlower iswprint iswpunct iswspace iswupper)
1233AC_CHECK_FUNCS(iswxdigit towupper towlower)
1234
1235AC_CACHE_CHECK([for mbstate_t], mutt_cv_mbstate_t,
1236        AC_TRY_COMPILE([
1237#include <stddef.h>
1238#include <stdlib.h>
1239#ifdef HAVE_WCHAR_H
1240#include <wchar.h>
1241#endif
1242                ],
1243                [ mbstate_t s; return 0; ],
1244                mutt_cv_mbstate_t=yes,
1245                mutt_cv_mbstate_t=no))
1246
1247if test "$mutt_cv_mbstate_t" = no; then
1248        AC_DEFINE(mbstate_t,int,[ Define to 'int' if system headers don't define. ])
1249fi
1250
1251wc_funcs=maybe
1252AC_ARG_WITH(wc-funcs, AC_HELP_STRING([--without-wc-funcs], [Do not use the system's wchar_t functions]),
1253        wc_funcs=$withval)
1254
1255if test "$wc_funcs" != yes && test "$wc_funcs" != no; then
1256        AC_CACHE_CHECK([for wchar_t functions], mutt_cv_wc_funcs,
1257                mutt_cv_wc_funcs=no
1258                AC_TRY_LINK([
1259#define _XOPEN_SOURCE 600
1260#include <stddef.h>
1261#include <stdlib.h>
1262#ifdef HAVE_WCHAR_H
1263#include <wchar.h>
1264#endif
1265#ifdef HAVE_WCTYPE_H
1266#include <wctype.h>
1267#endif],
1268                        [mbrtowc(0, 0, 0, 0); wctomb(0, 0); wcwidth(0);
1269        iswprint(0); iswspace(0); towlower(0); towupper(0); iswalnum(0)],
1270                        mutt_cv_wc_funcs=yes))
1271        wc_funcs=$mutt_cv_wc_funcs
1272fi
1273
1274if test $wc_funcs = yes; then
1275        AC_DEFINE(HAVE_WC_FUNCS,1,[ Define if you are using the system's wchar_t functions. ])
1276else
1277        MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS utf8.o"
1278        if test "x$cjk_width" != "xyes"; then
1279                MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS wcwidth.o"
1280        fi
1281fi
1282
1283AC_CACHE_CHECK([for nl_langinfo and CODESET], mutt_cv_langinfo_codeset,
1284  [AC_TRY_LINK([#include <langinfo.h>],
1285    [char* cs = nl_langinfo(CODESET);],
1286    mutt_cv_langinfo_codeset=yes,
1287    mutt_cv_langinfo_codeset=no)])
1288if test $mutt_cv_langinfo_codeset = yes; then
1289  AC_DEFINE(HAVE_LANGINFO_CODESET,1,[ Define if you have <langinfo.h> and nl_langinfo(CODESET). ])
1290fi
1291
1292AC_CACHE_CHECK([for nl_langinfo and YESEXPR], mutt_cv_langinfo_yesexpr,
1293  [AC_TRY_LINK([#include <langinfo.h>],
1294    [char* cs = nl_langinfo(YESEXPR);],
1295    mutt_cv_langinfo_yesexpr=yes,
1296    mutt_cv_langinfo_yesexpr=no)])
1297if test $mutt_cv_langinfo_yesexpr = yes; then
1298  AC_DEFINE(HAVE_LANGINFO_YESEXPR,1,[ Define if you have <langinfo.h> and nl_langinfo(YESEXPR). ])
1299fi
1300
1301dnl Documentation tools
1302have_openjade="no"
1303AC_PATH_PROG([OSPCAT], [ospcat], [none])
1304if test "$OSPCAT" != "none"
1305then
1306  AC_MSG_CHECKING([for openjade docbook stylesheets])
1307  dslosfile=`ospcat --public-id="-//Norman Walsh//DOCUMENT DocBook Print Stylesheet//EN"`
1308  DSLROOT=`echo $dslosfile | sed -n -e "s/.*SOIBASE='\(@<:@^'@:>@*\)\/catalog'.*/\1/p"`
1309  # ospcat may spit out an absolute path without an SOIBASE
1310  if test -z "$DSLROOT"
1311  then
1312    DSLROOT=`echo $dslosfile | sed -e 's|<OSFILE>\(.*\)/print/docbook.dsl|\1|'`
1313  fi
1314  if test -f $DSLROOT/print/docbook.dsl
1315  then
1316    AC_MSG_RESULT([in $DSLROOT])
1317    have_openjade="yes"
1318  else
1319    AC_MSG_RESULT([not found: PDF documentation will not be built.])
1320  fi
1321fi
1322AC_SUBST(DSLROOT)
1323
1324AC_ARG_ENABLE(full_doc,
1325	      AC_HELP_STRING([--disable-full-doc], [Omit disabled variables]),
1326[       if test x$enableval = xno ; then
1327                full_doc=no
1328        fi
1329])
1330if test x$full_doc != xno ; then
1331  AC_DEFINE(MAKEDOC_FULL,1, [Define if you want complete documentation.])
1332fi
1333
1334AC_OUTPUT(Makefile contrib/Makefile doc/Makefile imap/Makefile
1335        intl/Makefile m4/Makefile po/Makefile.in
1336        hcachever.sh muttbug.sh doc/instdoc.sh)
1337