git-svn-id: svn://svn.berlios.de/mutt-ng/trunk@59 e385b8ad-14ed-0310-8656-cc95a2468c6d
[apps/madmutt.git] / aclocal.m4
1 dnl aclocal.m4 generated automatically by aclocal 1.4-p4
2
3 dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7
8 dnl This program is distributed in the hope that it will be useful,
9 dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
10 dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11 dnl PARTICULAR PURPOSE.
12
13 # Like AC_CONFIG_HEADER, but automatically create stamp file.
14
15 AC_DEFUN(AM_CONFIG_HEADER,
16 [AC_PREREQ([2.12])
17 AC_CONFIG_HEADER([$1])
18 dnl When config.status generates a header, we must update the stamp-h file.
19 dnl This file resides in the same directory as the config header
20 dnl that is generated.  We must strip everything past the first ":",
21 dnl and everything past the last "/".
22 AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
23 ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
24 <<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
25 <<am_indx=1
26 for am_file in <<$1>>; do
27   case " <<$>>CONFIG_HEADERS " in
28   *" <<$>>am_file "*<<)>>
29     echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
30     ;;
31   esac
32   am_indx=`expr "<<$>>am_indx" + 1`
33 done<<>>dnl>>)
34 changequote([,]))])
35
36 # Do all the work for Automake.  This macro actually does too much --
37 # some checks are only needed if your package does certain things.
38 # But this isn't really a big deal.
39
40 # serial 1
41
42 dnl Usage:
43 dnl AM_INIT_AUTOMAKE(package,version, [no-define])
44
45 AC_DEFUN(AM_INIT_AUTOMAKE,
46 [AC_REQUIRE([AC_PROG_INSTALL])
47 PACKAGE=[$1]
48 AC_SUBST(PACKAGE)
49 VERSION=[$2]
50 AC_SUBST(VERSION)
51 dnl test to see if srcdir already configured
52 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
53   AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
54 fi
55 ifelse([$3],,
56 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
57 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
58 AC_REQUIRE([AM_SANITY_CHECK])
59 AC_REQUIRE([AC_ARG_PROGRAM])
60 dnl FIXME This is truly gross.
61 missing_dir=`cd $ac_aux_dir && pwd`
62 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
63 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
64 AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
65 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
66 AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
67 AC_REQUIRE([AC_PROG_MAKE_SET])])
68
69 #
70 # Check to make sure that the build environment is sane.
71 #
72
73 AC_DEFUN(AM_SANITY_CHECK,
74 [AC_MSG_CHECKING([whether build environment is sane])
75 # Just in case
76 sleep 1
77 echo timestamp > conftestfile
78 # Do `set' in a subshell so we don't clobber the current shell's
79 # arguments.  Must try -L first in case configure is actually a
80 # symlink; some systems play weird games with the mod time of symlinks
81 # (eg FreeBSD returns the mod time of the symlink's containing
82 # directory).
83 if (
84    set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
85    if test "[$]*" = "X"; then
86       # -L didn't work.
87       set X `ls -t $srcdir/configure conftestfile`
88    fi
89    if test "[$]*" != "X $srcdir/configure conftestfile" \
90       && test "[$]*" != "X conftestfile $srcdir/configure"; then
91
92       # If neither matched, then we have a broken ls.  This can happen
93       # if, for instance, CONFIG_SHELL is bash and it inherits a
94       # broken ls alias from the environment.  This has actually
95       # happened.  Such a system could not be considered "sane".
96       AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
97 alias in your environment])
98    fi
99
100    test "[$]2" = conftestfile
101    )
102 then
103    # Ok.
104    :
105 else
106    AC_MSG_ERROR([newly created file is older than distributed files!
107 Check your system clock])
108 fi
109 rm -f conftest*
110 AC_MSG_RESULT(yes)])
111
112 dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
113 dnl The program must properly implement --version.
114 AC_DEFUN(AM_MISSING_PROG,
115 [AC_MSG_CHECKING(for working $2)
116 # Run test in a subshell; some versions of sh will print an error if
117 # an executable is not found, even if stderr is redirected.
118 # Redirect stdin to placate older versions of autoconf.  Sigh.
119 if ($2 --version) < /dev/null > /dev/null 2>&1; then
120    $1=$2
121    AC_MSG_RESULT(found)
122 else
123    $1="$3/missing $2"
124    AC_MSG_RESULT(missing)
125 fi
126 AC_SUBST($1)])
127
128 #serial 1
129 # This test replaces the one in autoconf.
130 # Currently this macro should have the same name as the autoconf macro
131 # because gettext's gettext.m4 (distributed in the automake package)
132 # still uses it.  Otherwise, the use in gettext.m4 makes autoheader
133 # give these diagnostics:
134 #   configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
135 #   configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
136
137 undefine([AC_ISC_POSIX])
138
139 AC_DEFUN([AC_ISC_POSIX],
140   [
141     dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
142     AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
143   ]
144 )
145
146
147 # serial 1
148
149 AC_DEFUN(AM_C_PROTOTYPES,
150 [AC_REQUIRE([AM_PROG_CC_STDC])
151 AC_REQUIRE([AC_PROG_CPP])
152 AC_MSG_CHECKING([for function prototypes])
153 if test "$am_cv_prog_cc_stdc" != no; then
154   AC_MSG_RESULT(yes)
155   AC_DEFINE(PROTOTYPES,1,[Define if compiler has function prototypes])
156   U= ANSI2KNR=
157 else
158   AC_MSG_RESULT(no)
159   U=_ ANSI2KNR=./ansi2knr
160   # Ensure some checks needed by ansi2knr itself.
161   AC_HEADER_STDC
162   AC_CHECK_HEADERS(string.h)
163 fi
164 AC_SUBST(U)dnl
165 AC_SUBST(ANSI2KNR)dnl
166 ])
167
168
169 # serial 1
170
171 # @defmac AC_PROG_CC_STDC
172 # @maindex PROG_CC_STDC
173 # @ovindex CC
174 # If the C compiler in not in ANSI C mode by default, try to add an option
175 # to output variable @code{CC} to make it so.  This macro tries various
176 # options that select ANSI C on some system or another.  It considers the
177 # compiler to be in ANSI C mode if it handles function prototypes correctly.
178 #
179 # If you use this macro, you should check after calling it whether the C
180 # compiler has been set to accept ANSI C; if not, the shell variable
181 # @code{am_cv_prog_cc_stdc} is set to @samp{no}.  If you wrote your source
182 # code in ANSI C, you can make an un-ANSIfied copy of it by using the
183 # program @code{ansi2knr}, which comes with Ghostscript.
184 # @end defmac
185
186 AC_DEFUN(AM_PROG_CC_STDC,
187 [AC_REQUIRE([AC_PROG_CC])
188 AC_BEFORE([$0], [AC_C_INLINE])
189 AC_BEFORE([$0], [AC_C_CONST])
190 dnl Force this before AC_PROG_CPP.  Some cpp's, eg on HPUX, require
191 dnl a magic option to avoid problems with ANSI preprocessor commands
192 dnl like #elif.
193 dnl FIXME: can't do this because then AC_AIX won't work due to a
194 dnl circular dependency.
195 dnl AC_BEFORE([$0], [AC_PROG_CPP])
196 AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
197 AC_CACHE_VAL(am_cv_prog_cc_stdc,
198 [am_cv_prog_cc_stdc=no
199 ac_save_CC="$CC"
200 # Don't try gcc -ansi; that turns off useful extensions and
201 # breaks some systems' header files.
202 # AIX                   -qlanglvl=ansi
203 # Ultrix and OSF/1      -std1
204 # HP-UX                 -Aa -D_HPUX_SOURCE
205 # SVR4                  -Xc -D__EXTENSIONS__
206 for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
207 do
208   CC="$ac_save_CC $ac_arg"
209   AC_TRY_COMPILE(
210 [#include <stdarg.h>
211 #include <stdio.h>
212 #include <sys/types.h>
213 #include <sys/stat.h>
214 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
215 struct buf { int x; };
216 FILE * (*rcsopen) (struct buf *, struct stat *, int);
217 static char *e (p, i)
218      char **p;
219      int i;
220 {
221   return p[i];
222 }
223 static char *f (char * (*g) (char **, int), char **p, ...)
224 {
225   char *s;
226   va_list v;
227   va_start (v,p);
228   s = g (p, va_arg (v,int));
229   va_end (v);
230   return s;
231 }
232 int test (int i, double x);
233 struct s1 {int (*f) (int a);};
234 struct s2 {int (*f) (double a);};
235 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
236 int argc;
237 char **argv;
238 ], [
239 return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
240 ],
241 [am_cv_prog_cc_stdc="$ac_arg"; break])
242 done
243 CC="$ac_save_CC"
244 ])
245 if test -z "$am_cv_prog_cc_stdc"; then
246   AC_MSG_RESULT([none needed])
247 else
248   AC_MSG_RESULT($am_cv_prog_cc_stdc)
249 fi
250 case "x$am_cv_prog_cc_stdc" in
251   x|xno) ;;
252   *) CC="$CC $am_cv_prog_cc_stdc" ;;
253 esac
254 ])
255
256 dnl types.m4
257 dnl macros for type checks not covered by autoconf
258
259 dnl MUTT_C99_INTTYPES
260 dnl Brendan Cully
261 dnl
262 # MUTT_C99_INTTYPES
263 # Check for C99 integer type definitions, or define if missing
264 AC_DEFUN([MUTT_C99_INTTYPES],
265 [dnl
266 AC_CHECK_HEADERS([inttypes.h])
267 AC_CHECK_TYPE([uint32_t],
268   [AC_DEFINE(HAVE_C99_INTTYPES, 1, [Define if you have the C99 integer types])],
269   [AC_CHECK_SIZEOF(short)
270    AC_CHECK_SIZEOF(int)
271    AC_CHECK_SIZEOF(long)
272    AC_CHECK_SIZEOF(long long)])
273 AH_VERBATIM([X_HAVE_C99_INTTYPES],
274   [#ifndef HAVE_C99_INTTYPES
275 #  if SIZEOF_SHORT == 4
276 typedef unsigned short uint32_t;
277 #  elif SIZEOF_INT == 4
278 typedef unsigned int uint32_t;
279 #  elif SIZEOF_LONG == 4
280 typedef unsigned long uint32_t;
281 #  endif
282 #  if SIZEOF_INT == 8
283 typedef unsigned int uint64_t;
284 #  elif SIZEOF_LONG == 8
285 typedef unsigned long uint64_t;
286 #  elif SIZEOF_LONG_LONG == 8
287 typedef unsigned long long uint64_t;
288 #  endif
289 #endif
290   ])
291 ])
292
293 dnl ---------------------------------------------------------------------------
294 dnl Look for the curses libraries.  Older curses implementations may require
295 dnl termcap/termlib to be linked as well.
296 AC_DEFUN([CF_CURSES_LIBS],[
297 AC_CHECK_FUNC(initscr,,[
298 case $host_os in #(vi
299 freebsd*) #(vi
300         AC_CHECK_LIB(mytinfo,tgoto,[LIBS="-lmytinfo $LIBS"])
301         ;;
302 hpux10.*|hpux11.*)
303         AC_CHECK_LIB(cur_colr,initscr,[
304                 LIBS="-lcur_colr $LIBS"
305                 CFLAGS="-I/usr/include/curses_colr $CFLAGS"
306                 ac_cv_func_initscr=yes
307                 ],[
308         AC_CHECK_LIB(Hcurses,initscr,[
309                 # HP's header uses __HP_CURSES, but user claims _HP_CURSES.
310                 LIBS="-lHcurses $LIBS"
311                 CFLAGS="-D__HP_CURSES -D_HP_CURSES $CFLAGS"
312                 ac_cv_func_initscr=yes
313                 ])])
314         ;;
315 linux*) # Suse Linux does not follow /usr/lib convention
316         LIBS="$LIBS -L/lib"
317         ;;
318 esac
319
320 if test ".$With5lib" != ".no" ; then
321 if test -d /usr/5lib ; then
322         # SunOS 3.x or 4.x
323         CPPFLAGS="$CPPFLAGS -I/usr/5include"
324         LIBS="$LIBS -L/usr/5lib"
325 fi
326 fi
327
328 if test ".$ac_cv_func_initscr" != .yes ; then
329         cf_save_LIBS="$LIBS"
330         cf_term_lib=""
331         cf_curs_lib=""
332
333         # Check for library containing tgoto.  Do this before curses library
334         # because it may be needed to link the test-case for initscr.
335         AC_CHECK_FUNC(tgoto,[cf_term_lib=predefined],[
336                 for cf_term_lib in termcap termlib unknown
337                 do
338                         AC_CHECK_LIB($cf_term_lib,tgoto,[break])
339                 done
340         ])
341
342         # Check for library containing initscr
343         test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS"
344         for cf_curs_lib in cursesX curses ncurses xcurses jcurses unknown
345         do
346                 AC_CHECK_LIB($cf_curs_lib,initscr,[break])
347         done
348         test $cf_curs_lib = unknown && AC_ERROR(no curses library found)
349
350         LIBS="-l$cf_curs_lib $cf_save_LIBS"
351         if test "$cf_term_lib" = unknown ; then
352                 AC_MSG_CHECKING(if we can link with $cf_curs_lib library)
353                 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
354                         [initscr()],
355                         [cf_result=yes],
356                         [cf_result=no])
357                 AC_MSG_RESULT($cf_result)
358                 test $cf_result = no && AC_ERROR(Cannot link curses library)
359         elif test "$cf_term_lib" != predefined ; then
360                 AC_MSG_CHECKING(if we need both $cf_curs_lib and $cf_term_lib libraries)
361                 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
362                         [initscr(); tgoto((char *)0, 0, 0);],
363                         [cf_result=no],
364                         [
365                         LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
366                         AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
367                                 [initscr()],
368                                 [cf_result=yes],
369                                 [cf_result=error])
370                         ])
371                 AC_MSG_RESULT($cf_result)
372         fi
373 fi
374
375 ])])
376
377 dnl ---------------------------------------------------------------------------
378 dnl Check if a function is declared by including a set of include files.
379 dnl Invoke the corresponding actions according to whether it is found or not.
380 dnl
381 dnl Gcc (unlike other compilers) will only warn about the miscast assignment
382 dnl in the first test, but most compilers will oblige with an error in the
383 dnl second test.
384 dnl
385 dnl CF_CHECK_FUNCDECL(INCLUDES, FUNCTION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
386 AC_DEFUN([CF_CHECK_FUNCDECL],
387 [
388 AC_MSG_CHECKING([for $2 declaration])
389 AC_CACHE_VAL(ac_cv_func_decl_$2,
390 [AC_TRY_COMPILE([$1],
391 [#ifndef ${ac_func}
392 extern  int     ${ac_func}();
393 #endif],[
394 AC_TRY_COMPILE([$1],
395 [#ifndef ${ac_func}
396 int     (*p)() = ${ac_func};
397 #endif],[
398 eval "ac_cv_func_decl_$2=yes"],[
399 eval "ac_cv_func_decl_$2=no"])],[
400 eval "ac_cv_func_decl_$2=yes"])])
401 if eval "test \"`echo '$ac_cv_func_'decl_$2`\" = yes"; then
402   AC_MSG_RESULT(yes)
403   ifelse([$3], , :, [$3])
404 else
405   AC_MSG_RESULT(no)
406 ifelse([$4], , , [$4
407 ])dnl
408 fi
409 ])dnl
410 dnl ---------------------------------------------------------------------------
411 dnl Check if functions are declared by including a set of include files.
412 dnl and define DECL_XXX if not.
413 dnl
414 dnl CF_CHECK_FUNCDECLS(INCLUDES, FUNCTION... [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
415 AC_DEFUN([CF_CHECK_FUNCDECLS],
416 [for ac_func in $2
417 do
418 CF_CHECK_FUNCDECL([$1], $ac_func,
419 [
420   CF_UPPER(ac_tr_func,HAVE_$ac_func)
421   AC_DEFINE_UNQUOTED($ac_tr_func) $3],
422 [$4])dnl
423 dnl [$3],
424 dnl [
425 dnl   CF_UPPER(ac_tr_func,DECL_$ac_func)
426 dnl   AC_DEFINE_UNQUOTED($ac_tr_func) $4])dnl
427 done
428 ])dnl
429 dnl ---------------------------------------------------------------------------
430 dnl Make an uppercase version of a variable
431 dnl $1=uppercase($2)
432 AC_DEFUN([CF_UPPER],
433 [
434 changequote(,)dnl
435 $1=`echo $2 | tr '[a-z]' '[A-Z]'`
436 changequote([,])dnl
437 ])dnl
438 dnl ---------------------------------------------------------------------------
439
440 # Define a conditional.
441
442 AC_DEFUN(AM_CONDITIONAL,
443 [AC_SUBST($1_TRUE)
444 AC_SUBST($1_FALSE)
445 if $2; then
446   $1_TRUE=
447   $1_FALSE='#'
448 else
449   $1_TRUE='#'
450   $1_FALSE=
451 fi])
452
453 # gssapi.m4: Find GSSAPI libraries in either Heimdal or MIT implementations
454 # Brendan Cully <brendan@kublai.com> 20010529
455
456 dnl MUTT_AM_PATH_GSSAPI(PREFIX)
457 dnl Search for a GSSAPI implementation in the standard locations plus PREFIX,
458 dnl if it is set and not "yes".
459 dnl Defines GSSAPI_CFLAGS and GSSAPI_LIBS if found.
460 dnl Defines GSSAPI_IMPL to "Heimdal", "MIT", or "OldMIT", or "none" if not found
461 AC_DEFUN([MUTT_AM_PATH_GSSAPI],
462 [
463   GSSAPI_PREFIX=[$]$1
464   GSSAPI_IMPL="none"
465   saved_CPPFLAGS="$CPPFLAGS"
466   saved_LDFLAGS="$LDFLAGS"
467   saved_LIBS="$LIBS"
468   dnl First try krb5-config
469   if test "$GSSAPI_PREFIX" != "yes"
470   then
471     krb5_path="$GSSAPI_PREFIX/bin"
472   else
473     krb5_path="$PATH"
474   fi
475   AC_PATH_PROG(KRB5CFGPATH, krb5-config, none, $krb5_path)
476   if test "$KRB5CFGPATH" != "none"
477   then
478     GSSAPI_CFLAGS="$CPPFLAGS `$KRB5CFGPATH --cflags gssapi`"
479     GSSAPI_LIBS="$MUTTLIBS `$KRB5CFGPATH --libs gssapi`"
480     case "`$KRB5CFGPATH --version`" in
481       "Kerberos 5 "*)   GSSAPI_IMPL="MIT";;
482       ?eimdal*)         GSSAPI_IMPL="Heimdal";;
483       *)                GSSAPI_IMPL="Unknown";;
484    esac
485   else
486     dnl No krb5-config, run the old code
487     if test "$GSSAPI_PREFIX" != "yes"
488     then
489       GSSAPI_CFLAGS="-I$GSSAPI_PREFIX/include"
490       GSSAPI_LDFLAGS="-L$GSSAPI_PREFIX/lib"
491       CPPFLAGS="$CPPFLAGS $GSSAPI_CFLAGS"
492       LDFLAGS="$LDFLAGS $GSSAPI_LDFLAGS"
493     fi
494
495     dnl New MIT kerberos V support
496     AC_CHECK_LIB(gssapi_krb5, gss_init_sec_context, [
497       GSSAPI_IMPL="MIT",
498       GSSAPI_LIBS="$GSSAPI_LDFLAGS -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err"
499       ],, -lkrb5 -lk5crypto -lcom_err)
500
501     dnl Heimdal kerberos V support
502     if test "$GSSAPI_IMPL" = "none"
503     then
504       AC_CHECK_LIB(gssapi, gss_init_sec_context, [
505           GSSAPI_IMPL="Heimdal"
506           GSSAPI_LIBS="$GSSAPI_LDFLAGS -lgssapi -lkrb5 -ldes -lasn1 -lroken"
507           GSSAPI_LIBS="$GSSAPI_LIBS -lcrypt -lcom_err"
508           ],, -lkrb5 -ldes -lasn1 -lroken -lcrypt -lcom_err)
509     fi
510
511     dnl Old MIT Kerberos V
512     dnl Note: older krb5 distributions use -lcrypto instead of
513     dnl -lk5crypto, which collides with OpenSSL.  One way of dealing
514     dnl with that is to extract all objects from krb5's libcrypto
515     dnl and from openssl's libcrypto into the same directory, then
516     dnl to create a new libcrypto from these.
517     if test "$GSSAPI_IMPL" = "none"
518     then
519       AC_CHECK_LIB(gssapi_krb5, g_order_init, [
520         GSSAPI_IMPL="OldMIT",
521         GSSAPI_LIBS="$GSSAPI_LDFLAGS -lgssapi_krb5 -lkrb5 -lcrypto -lcom_err"
522         ],, -lkrb5 -lcrypto -lcom_err)
523     fi
524   fi
525
526   CPPFLAGS="$saved_CPPFLAGS"
527   LDFLAGS="$saved_LDFLAGS"
528   LIBS="$saved_LIBS"
529 ])
530
531 dnl Autoconf macros for libgnutls
532 dnl $id$
533
534 # Modified for mutt 20050210 Brendan Cully
535 # Modified for LIBGNUTLS -- nmav
536 # Configure paths for LIBGCRYPT
537 # Shamelessly stolen from the one of XDELTA by Owen Taylor
538 # Werner Koch   99-12-09
539
540 dnl MUTT_AM_PATH_GNUTLS([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
541 dnl Test for libgnutls, and define LIBGNUTLS_CFLAGS and LIBGNUTLS_LIBS
542 dnl
543 AC_DEFUN([MUTT_AM_PATH_GNUTLS],
544 [dnl
545 dnl Get the cflags and libraries from the libgnutls-config script
546 dnl
547   libgnutls_config_prefix=$1
548   min_libgnutls_version=0.1.0
549
550   if test x$libgnutls_config_prefix != x ; then
551      if test x${LIBGNUTLS_CONFIG+set} != xset ; then
552         LIBGNUTLS_CONFIG=$libgnutls_config_prefix/bin/libgnutls-config
553      fi
554   fi
555
556   AC_PATH_PROG(LIBGNUTLS_CONFIG, libgnutls-config, no)
557   AC_MSG_CHECKING(for libgnutls - version >= $min_libgnutls_version)
558   no_libgnutls=""
559   if test "$LIBGNUTLS_CONFIG" = "no" ; then
560     no_libgnutls=yes
561   else
562     LIBGNUTLS_CFLAGS=`$LIBGNUTLS_CONFIG $libgnutls_config_args --cflags`
563     LIBGNUTLS_LIBS=`$LIBGNUTLS_CONFIG $libgnutls_config_args --libs`
564     libgnutls_config_version=`$LIBGNUTLS_CONFIG $libgnutls_config_args --version`
565
566
567       ac_save_CFLAGS="$CFLAGS"
568       ac_save_LIBS="$LIBS"
569       CFLAGS="$CFLAGS $LIBGNUTLS_CFLAGS"
570       LIBS="$LIBS $LIBGNUTLS_LIBS"
571
572 dnl
573 dnl Now check if the installed libgnutls is sufficiently new. Also sanity
574 dnl checks the results of libgnutls-config to some extent
575 dnl
576       rm -f conf.libgnutlstest
577       AC_TRY_RUN([
578 #include <stdio.h>
579 #include <stdlib.h>
580 #include <string.h>
581 #include <gnutls/gnutls.h>
582
583 int
584 main ()
585 {
586     system ("touch conf.libgnutlstest");
587
588     if( strcmp( gnutls_check_version(NULL), "$libgnutls_config_version" ) )
589     {
590       printf("\n*** 'libgnutls-config --version' returned %s, but LIBGNUTLS (%s)\n",
591              "$libgnutls_config_version", gnutls_check_version(NULL) );
592       printf("*** was found! If libgnutls-config was correct, then it is best\n");
593       printf("*** to remove the old version of LIBGNUTLS. You may also be able to fix the error\n");
594       printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
595       printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
596       printf("*** required on your system.\n");
597       printf("*** If libgnutls-config was wrong, set the environment variable LIBGNUTLS_CONFIG\n");
598       printf("*** to point to the correct copy of libgnutls-config, and remove the file config.cache\n");
599       printf("*** before re-running configure\n");
600     }
601     else if ( strcmp(gnutls_check_version(NULL), LIBGNUTLS_VERSION ) )
602     {
603       printf("\n*** LIBGNUTLS header file (version %s) does not match\n", LIBGNUTLS_VERSION);
604       printf("*** library (version %s)\n", gnutls_check_version(NULL) );
605     }
606     else
607     {
608       if ( gnutls_check_version( "$min_libgnutls_version" ) )
609       {
610         return 0;
611       }
612      else
613       {
614         printf("no\n*** An old version of LIBGNUTLS (%s) was found.\n",
615                 gnutls_check_version(NULL) );
616         printf("*** You need a version of LIBGNUTLS newer than %s. The latest version of\n",
617                "$min_libgnutls_version" );
618         printf("*** LIBGNUTLS is always available from ftp://gnutls.hellug.gr/pub/gnutls.\n");
619         printf("*** \n");
620         printf("*** If you have already installed a sufficiently new version, this error\n");
621         printf("*** probably means that the wrong copy of the libgnutls-config shell script is\n");
622         printf("*** being found. The easiest way to fix this is to remove the old version\n");
623         printf("*** of LIBGNUTLS, but you can also set the LIBGNUTLS_CONFIG environment to point to the\n");
624         printf("*** correct copy of libgnutls-config. (In this case, you will have to\n");
625         printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
626         printf("*** so that the correct libraries are found at run-time))\n");
627       }
628     }
629   return 1;
630 }
631 ],, no_libgnutls=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
632        CFLAGS="$ac_save_CFLAGS"
633        LIBS="$ac_save_LIBS"
634   fi
635
636   if test "x$no_libgnutls" = x ; then
637      AC_MSG_RESULT(yes)
638      dnl some openssl compatibility code was moved in gnutls 1.2
639      AC_CHECK_HEADERS([gnutls/openssl.h])
640      ifelse([$2], , :, [$2])
641   else
642      if test -f conf.libgnutlstest ; then
643         :
644      else
645         AC_MSG_RESULT(no)
646      fi
647      if test "$LIBGNUTLS_CONFIG" = "no" ; then
648        echo "*** The libgnutls-config script installed by LIBGNUTLS could not be found"
649        echo "*** If LIBGNUTLS was installed in PREFIX, make sure PREFIX/bin is in"
650        echo "*** your path, or set the LIBGNUTLS_CONFIG environment variable to the"
651        echo "*** full path to libgnutls-config."
652      else
653        if test -f conf.libgnutlstest ; then
654         :
655        else
656           echo "*** Could not run libgnutls test program, checking why..."
657           CFLAGS="$CFLAGS $LIBGNUTLS_CFLAGS"
658           LIBS="$LIBS $LIBGNUTLS_LIBS"
659           AC_TRY_LINK([
660 #include <stdio.h>
661 #include <stdlib.h>
662 #include <string.h>
663 #include <gnutls/gnutls.h>
664 ],      [ return !!gnutls_check_version(NULL); ],
665         [ echo "*** The test program compiled, but did not run. This usually means"
666           echo "*** that the run-time linker is not finding LIBGNUTLS or finding the wrong"
667           echo "*** version of LIBGNUTLS. If it is not finding LIBGNUTLS, you'll need to set your"
668           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
669           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
670           echo "*** is required on your system"
671           echo "***"
672           echo "*** If you have an old version installed, it is best to remove it, although"
673           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
674           echo "***" ],
675         [ echo "*** The test program failed to compile or link. See the file config.log for the"
676           echo "*** exact error that occured. This usually means LIBGNUTLS was incorrectly installed"
677           echo "*** or that you have moved LIBGNUTLS since it was installed. In the latter case, you"
678           echo "*** may want to edit the libgnutls-config script: $LIBGNUTLS_CONFIG" ])
679           CFLAGS="$ac_save_CFLAGS"
680           LIBS="$ac_save_LIBS"
681        fi
682      fi
683      LIBGNUTLS_CFLAGS=""
684      LIBGNUTLS_LIBS=""
685      ifelse([$3], , :, [$3])
686   fi
687   rm -f conf.libgnutlstest
688   AC_SUBST(LIBGNUTLS_CFLAGS)
689   AC_SUBST(LIBGNUTLS_LIBS)
690 ])
691
692 dnl *-*wedit:notab*-*  Please keep this as the last line.
693
694 # Macro to add for using GNU gettext.
695 # Ulrich Drepper <drepper@cygnus.com>, 1995.
696
697 #
698 # Slightly modified by Thomas Roessler <roessler@does-not-exist.org>
699 # Updated to gettext-0.10.38 by Edmund Grimley Evans <edmundo@rano.org>
700 # Updated to gettext-0.10.40 by Andrew W. Nosenko <awn@bcs.zp.ua>
701 #
702
703 # This file can be copied and used freely without restrictions.  It can
704 # be used in projects which are not available under the GNU General Public
705 # License or the GNU Library General Public License but which still want
706 # to provide support for the GNU gettext functionality.
707 # Please note that the actual code of the GNU gettext library is covered
708 # by the GNU Library General Public License, and the rest of the GNU
709 # gettext package package is covered by the GNU General Public License.
710 # They are *not* in the public domain.
711
712 # serial 10
713
714 dnl Usage: MUTT_AM_WITH_NLS([TOOLSYMBOL], [NEEDSYMBOL], [LIBDIR]).
715 dnl If TOOLSYMBOL is specified and is 'use-libtool', then a libtool library
716 dnl    $(top_builddir)/intl/libintl.la will be created (shared and/or static,
717 dnl    depending on --{enable,disable}-{shared,static} and on the presence of
718 dnl    AM-DISABLE-SHARED). Otherwise, a static library
719 dnl    $(top_builddir)/intl/libintl.a will be created.
720 dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
721 dnl    implementations (in libc or libintl) without the ngettext() function
722 dnl    will be ignored.
723 dnl LIBDIR is used to find the intl libraries.  If empty,
724 dnl    the value `$(top_builddir)/intl/' is used.
725 dnl
726 dnl The result of the configuration is one of three cases:
727 dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
728 dnl    and used.
729 dnl    Catalog format: GNU --> install in $(datadir)
730 dnl    Catalog extension: .mo after installation, .gmo in source tree
731 dnl 2) GNU gettext has been found in the system's C library.
732 dnl    Catalog format: GNU --> install in $(datadir)
733 dnl    Catalog extension: .mo after installation, .gmo in source tree
734 dnl 3) No internationalization, always use English msgid.
735 dnl    Catalog format: none
736 dnl    Catalog extension: none
737 dnl The use of .gmo is historical (it was needed to avoid overwriting the
738 dnl GNU format catalogs when building on a platform with an X/Open gettext),
739 dnl but we keep it in order not to force irrelevant filename changes on the
740 dnl maintainers.
741 dnl
742 AC_DEFUN([MUTT_AM_WITH_NLS],
743   [AC_MSG_CHECKING([whether NLS is requested])
744     dnl Default is enabled NLS
745     AC_ARG_ENABLE(nls,
746       [  --disable-nls              Do not use Native Language Support],
747       USE_NLS=$enableval, USE_NLS=yes)
748     AC_MSG_RESULT($USE_NLS)
749     AC_SUBST(USE_NLS)
750
751     BUILD_INCLUDED_LIBINTL=no
752     USE_INCLUDED_LIBINTL=no
753     INTLLIBS=
754
755     dnl If we use NLS figure out what method
756     if test "$USE_NLS" = "yes"; then
757       AC_DEFINE(ENABLE_NLS, 1,
758         [Define to 1 if translation of program messages to the user's native language
759    is requested.])
760       AC_MSG_CHECKING([whether included gettext is requested])
761       AC_ARG_WITH(included-gettext,
762         [  --with-included-gettext    Use the GNU gettext library included here],
763         nls_cv_force_use_gnu_gettext=$withval,
764         nls_cv_force_use_gnu_gettext=no)
765       AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
766
767       nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
768       if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
769         dnl User does not insist on using GNU NLS library.  Figure out what
770         dnl to use.  If GNU gettext is available we use this.  Else we have
771         dnl to fall back to GNU NLS library.
772         CATOBJEXT=NONE
773
774         dnl Add a version number to the cache macros.
775         define(gt_cv_func_gnugettext_libc, [gt_cv_func_gnugettext]ifelse([$2], need-ngettext, 2, 1)[_libc])
776         define(gt_cv_func_gnugettext_libintl, [gt_cv_func_gnugettext]ifelse([$2], need-ngettext, 2, 1)[_libintl])
777
778         AC_CHECK_HEADER(libintl.h,
779           [AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc,
780             [AC_TRY_LINK([#include <libintl.h>
781 extern int _nl_msg_cat_cntr;],
782                [bindtextdomain ("", "");
783 return (int) gettext ("")]ifelse([$2], need-ngettext, [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr],
784                gt_cv_func_gnugettext_libc=yes,
785                gt_cv_func_gnugettext_libc=no)])
786
787            if test "$gt_cv_func_gnugettext_libc" != "yes"; then
788              AC_CACHE_CHECK([for GNU gettext in libintl],
789                gt_cv_func_gnugettext_libintl,
790                [gt_save_LIBS="$LIBS"
791                 LIBS="$LIBS -lintl $LIBICONV"
792                 AC_TRY_LINK([#include <libintl.h>
793 extern int _nl_msg_cat_cntr;],
794                   [bindtextdomain ("", "");
795 return (int) gettext ("")]ifelse([$2], need-ngettext, [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr],
796                   gt_cv_func_gnugettext_libintl=yes,
797                   gt_cv_func_gnugettext_libintl=no)
798                 LIBS="$gt_save_LIBS"])
799            fi
800
801            dnl If an already present or preinstalled GNU gettext() is found,
802            dnl use it.  But if this macro is used in GNU gettext, and GNU
803            dnl gettext is already preinstalled in libintl, we update this
804            dnl libintl.  (Cf. the install rule in intl/Makefile.in.)
805            if test "$gt_cv_func_gnugettext_libc" = "yes" \
806               || { test "$gt_cv_func_gnugettext_libintl" = "yes" \
807                    && test "$PACKAGE" != gettext; }; then
808              AC_DEFINE(HAVE_GETTEXT, 1,
809                [Define if the GNU gettext() function is already present or preinstalled.])
810
811              if test "$gt_cv_func_gnugettext_libintl" = "yes"; then
812                dnl If iconv() is in a separate libiconv library, then anyone
813                dnl linking with libintl{.a,.so} also needs to link with
814                dnl libiconv.
815                INTLLIBS="-lintl $LIBICONV"
816              fi
817
818              gt_save_LIBS="$LIBS"
819              LIBS="$LIBS $INTLLIBS"
820              AC_CHECK_FUNCS(dcgettext)
821              LIBS="$gt_save_LIBS"
822
823              dnl Search for GNU msgfmt in the PATH.
824              MUTT_AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
825                [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1], :)
826              AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
827
828              dnl Search for GNU xgettext in the PATH.
829              MUTT_AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
830                [$ac_dir/$ac_word --omit-header /dev/null >/dev/null 2>&1], :)
831
832              CATOBJEXT=.gmo
833            fi
834         ])
835
836         if test "$CATOBJEXT" = "NONE"; then
837           dnl GNU gettext is not found in the C library.
838           dnl Fall back on GNU gettext library.
839           nls_cv_use_gnu_gettext=yes
840         fi
841       fi
842
843       if test "$nls_cv_use_gnu_gettext" = "yes"; then
844         dnl Mark actions used to generate GNU NLS library.
845         INTLOBJS="\$(GETTOBJS)"
846         MUTT_AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
847           [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1], :)
848         AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
849         MUTT_AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
850           [$ac_dir/$ac_word --omit-header /dev/null >/dev/null 2>&1], :)
851         AC_SUBST(MSGFMT)
852         BUILD_INCLUDED_LIBINTL=yes
853         USE_INCLUDED_LIBINTL=yes
854         CATOBJEXT=.gmo
855         INTLLIBS="ifelse([$3],[],\$(top_builddir)/intl,[$3])/libintl.ifelse([$1], use-libtool, [l], [])a $LIBICONV"
856         LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
857       fi
858
859       dnl This could go away some day; the MUTT_PATH_PROG_WITH_TEST already does it.
860       dnl Test whether we really found GNU msgfmt.
861       if test "$GMSGFMT" != ":"; then
862         dnl If it is no GNU msgfmt we define it as : so that the
863         dnl Makefiles still can work.
864         if $GMSGFMT --statistics /dev/null >/dev/null 2>&1; then
865           : ;
866         else
867           AC_MSG_RESULT(
868             [found msgfmt program is not GNU msgfmt; ignore it])
869           GMSGFMT=":"
870         fi
871       fi
872
873       dnl This could go away some day; the MUTT_PATH_PROG_WITH_TEST already does it.
874       dnl Test whether we really found GNU xgettext.
875       if test "$XGETTEXT" != ":"; then
876         dnl If it is no GNU xgettext we define it as : so that the
877         dnl Makefiles still can work.
878         if $XGETTEXT --omit-header /dev/null >/dev/null 2>&1; then
879           : ;
880         else
881           AC_MSG_RESULT(
882             [found xgettext program is not GNU xgettext; ignore it])
883           XGETTEXT=":"
884         fi
885       fi
886
887       dnl We need to process the po/ directory.
888       POSUB=po
889     fi
890     AC_OUTPUT_COMMANDS(
891      [for ac_file in $CONFIG_FILES; do
892         # Support "outfile[:infile[:infile...]]"
893         case "$ac_file" in
894           *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
895         esac
896         # PO directories have a Makefile.in generated from Makefile.in.in.
897         case "$ac_file" in */Makefile.in)
898           # Adjust a relative srcdir.
899           ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
900           ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
901           ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
902           # In autoconf-2.13 it is called $ac_given_srcdir.
903           # In autoconf-2.50 it is called $srcdir.
904           test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
905           case "$ac_given_srcdir" in
906             .)  top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
907             /*) top_srcdir="$ac_given_srcdir" ;;
908             *)  top_srcdir="$ac_dots$ac_given_srcdir" ;;
909           esac
910           if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
911             rm -f "$ac_dir/POTFILES"
912             test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
913             sed -e "/^#/d" -e "/^[      ]*\$/d" -e "s,.*,     $top_srcdir/& \\\\," -e "\$s/\(.*\) \\\\/\1/" < "$ac_given_srcdir/$ac_dir/POTFILES.in" > "$ac_dir/POTFILES"
914             test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile"
915             sed -e "/POTFILES =/r $ac_dir/POTFILES" "$ac_dir/Makefile.in" > "$ac_dir/Makefile"
916           fi
917           ;;
918         esac
919       done])
920
921
922     dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
923     dnl to 'yes' because some of the testsuite requires it.
924     if test "$PACKAGE" = gettext; then
925       BUILD_INCLUDED_LIBINTL=yes
926     fi
927
928     dnl intl/plural.c is generated from intl/plural.y. It requires bison,
929     dnl because plural.y uses bison specific features. It requires at least
930     dnl bison-1.26 because earlier versions generate a plural.c that doesn't
931     dnl compile.
932     dnl bison is only needed for the maintainer (who touches plural.y). But in
933     dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
934     dnl the rule in general Makefile. Now, some people carelessly touch the
935     dnl files or have a broken "make" program, hence the plural.c rule will
936     dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
937     dnl present or too old.
938     AC_CHECK_PROGS([INTLBISON], [bison])
939     if test -z "$INTLBISON"; then
940       ac_verc_fail=yes
941     else
942       dnl Found it, now check the version.
943       AC_MSG_CHECKING([version of bison])
944 changequote(<<,>>)dnl
945       ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
946       case $ac_prog_version in
947         '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
948         1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
949 changequote([,])dnl
950            ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
951         *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
952       esac
953       AC_MSG_RESULT([$ac_prog_version])
954     fi
955     if test $ac_verc_fail = yes; then
956       INTLBISON=:
957     fi
958
959     dnl These rules are solely for the distribution goal.  While doing this
960     dnl we only have to keep exactly one list of the available catalogs
961     dnl in configure.in.
962     for lang in $ALL_LINGUAS; do
963       GMOFILES="$GMOFILES $lang.gmo"
964       POFILES="$POFILES $lang.po"
965     done
966
967     dnl Make all variables we use known to autoconf.
968     AC_SUBST(BUILD_INCLUDED_LIBINTL)
969     AC_SUBST(USE_INCLUDED_LIBINTL)
970     AC_SUBST(CATALOGS)
971     AC_SUBST(CATOBJEXT)
972     AC_SUBST(GMOFILES)
973     AC_SUBST(INTLLIBS)
974     AC_SUBST(INTLOBJS)
975     AC_SUBST(POFILES)
976     AC_SUBST(POSUB)
977
978     dnl For backward compatibility. Some configure.ins may be using this.
979     nls_cv_header_intl=
980     nls_cv_header_libgt=
981
982     dnl For backward compatibility. Some Makefiles may be using this.
983     DATADIRNAME=share
984     AC_SUBST(DATADIRNAME)
985
986     dnl For backward compatibility. Some Makefiles may be using this.
987     INSTOBJEXT=.mo
988     AC_SUBST(INSTOBJEXT)
989
990     dnl For backward compatibility. Some Makefiles may be using this.
991     GENCAT=gencat
992     AC_SUBST(GENCAT)
993   ])
994
995 dnl Usage: Just like MUTT_AM_WITH_NLS, which see.
996 AC_DEFUN([MUTT_AM_GNU_GETTEXT],
997   [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
998    AC_REQUIRE([AC_PROG_CC])dnl
999    AC_REQUIRE([AC_CANONICAL_HOST])dnl
1000    AC_REQUIRE([AC_PROG_RANLIB])dnl
1001    AC_REQUIRE([AC_ISC_POSIX])dnl
1002    AC_REQUIRE([AC_HEADER_STDC])dnl
1003    AC_REQUIRE([AC_C_CONST])dnl
1004    AC_REQUIRE([AC_C_INLINE])dnl
1005    AC_REQUIRE([AC_TYPE_OFF_T])dnl
1006    AC_REQUIRE([AC_TYPE_SIZE_T])dnl
1007    AC_REQUIRE([AC_FUNC_ALLOCA])dnl
1008    AC_REQUIRE([AC_FUNC_MMAP])dnl
1009    AC_REQUIRE([MUTT_jm_GLIBC21])dnl
1010
1011    AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
1012 stdlib.h string.h unistd.h sys/param.h])
1013    AC_CHECK_FUNCS([feof_unlocked fgets_unlocked getcwd getegid geteuid \
1014 getgid getuid mempcpy munmap putenv setenv setlocale stpcpy strchr strcasecmp \
1015 strdup strtoul tsearch __argz_count __argz_stringify __argz_next])
1016
1017    MUTT_AM_ICONV
1018    MUTT_AM_LANGINFO_CODESET
1019    MUTT_AM_LC_MESSAGES
1020    MUTT_AM_WITH_NLS([$1],[$2],[$3])
1021
1022    if test "x$CATOBJEXT" != "x"; then
1023      if test "x$ALL_LINGUAS" = "x"; then
1024        LINGUAS=
1025      else
1026        AC_MSG_CHECKING(for catalogs to be installed)
1027        NEW_LINGUAS=
1028        for presentlang in $ALL_LINGUAS; do
1029          useit=no
1030          for desiredlang in ${LINGUAS-$ALL_LINGUAS}; do
1031            # Use the presentlang catalog if desiredlang is
1032            #   a. equal to presentlang, or
1033            #   b. a variant of presentlang (because in this case,
1034            #      presentlang can be used as a fallback for messages
1035            #      which are not translated in the desiredlang catalog).
1036            case "$desiredlang" in
1037              "$presentlang"*) useit=yes;;
1038            esac
1039          done
1040          if test $useit = yes; then
1041            NEW_LINGUAS="$NEW_LINGUAS $presentlang"
1042          fi
1043        done
1044        LINGUAS=$NEW_LINGUAS
1045        AC_MSG_RESULT($LINGUAS)
1046      fi
1047
1048      dnl Construct list of names of catalog files to be constructed.
1049      if test -n "$LINGUAS"; then
1050        for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
1051      fi
1052    fi
1053
1054    dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
1055    dnl find the mkinstalldirs script in another subdir but $(top_srcdir).
1056    dnl Try to locate is.
1057    MKINSTALLDIRS=
1058    if test -n "$ac_aux_dir"; then
1059      MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
1060    fi
1061    if test -z "$MKINSTALLDIRS"; then
1062      MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
1063    fi
1064    AC_SUBST(MKINSTALLDIRS)
1065
1066    dnl Enable libtool support if the surrounding package wishes it.
1067    INTL_LIBTOOL_SUFFIX_PREFIX=ifelse([$1], use-libtool, [l], [])
1068    AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX)
1069   ])
1070
1071 # Search path for a program which passes the given test.
1072 # Ulrich Drepper <drepper@cygnus.com>, 1996.
1073 #
1074 # This file can be copied and used freely without restrictions.  It can
1075 # be used in projects which are not available under the GNU General Public
1076 # License or the GNU Library General Public License but which still want
1077 # to provide support for the GNU gettext functionality.
1078 # Please note that the actual code of the GNU gettext library is covered
1079 # by the GNU Library General Public License, and the rest of the GNU
1080 # gettext package package is covered by the GNU General Public License.
1081 # They are *not* in the public domain.
1082
1083 # serial 2
1084
1085 dnl MUTT_AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
1086 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
1087 AC_DEFUN([MUTT_AM_PATH_PROG_WITH_TEST],
1088 [# Extract the first word of "$2", so it can be a program name with args.
1089 set dummy $2; ac_word=[$]2
1090 AC_MSG_CHECKING([for $ac_word])
1091 AC_CACHE_VAL(ac_cv_path_$1,
1092 [case "[$]$1" in
1093   /*)
1094   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
1095   ;;
1096   *)
1097   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
1098   for ac_dir in ifelse([$5], , $PATH, [$5]); do
1099     test -z "$ac_dir" && ac_dir=.
1100     if test -f $ac_dir/$ac_word; then
1101       if [$3]; then
1102         ac_cv_path_$1="$ac_dir/$ac_word"
1103         break
1104       fi
1105     fi
1106   done
1107   IFS="$ac_save_ifs"
1108 dnl If no 4th arg is given, leave the cache variable unset,
1109 dnl so AC_PATH_PROGS will keep looking.
1110 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
1111 ])dnl
1112   ;;
1113 esac])dnl
1114 $1="$ac_cv_path_$1"
1115 if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
1116   AC_MSG_RESULT([$]$1)
1117 else
1118   AC_MSG_RESULT(no)
1119 fi
1120 AC_SUBST($1)dnl
1121 ])
1122
1123 #serial 2
1124
1125 # Test for the GNU C Library, version 2.1 or newer.
1126 # From Bruno Haible.
1127
1128 AC_DEFUN([jm_GLIBC21],
1129   [
1130     AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer,
1131       ac_cv_gnu_library_2_1,
1132       [AC_EGREP_CPP([Lucky GNU user],
1133         [
1134 #include <features.h>
1135 #ifdef __GNU_LIBRARY__
1136  #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
1137   Lucky GNU user
1138  #endif
1139 #endif
1140         ],
1141         ac_cv_gnu_library_2_1=yes,
1142         ac_cv_gnu_library_2_1=no)
1143       ]
1144     )
1145     AC_SUBST(GLIBC21)
1146     GLIBC21="$ac_cv_gnu_library_2_1"
1147   ]
1148 )
1149
1150 #serial AM2
1151
1152 dnl From Bruno Haible.
1153
1154 AC_DEFUN([MUTT_AM_ICONV],
1155 [
1156   dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
1157   dnl those with the standalone portable GNU libiconv installed).
1158
1159   AC_ARG_WITH([libiconv-prefix],
1160 [  --with-libiconv-prefix=DIR Search for libiconv in DIR/include and DIR/lib], [
1161     for dir in `echo "$withval" | tr : ' '`; do
1162       if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
1163       if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
1164     done
1165    ])
1166
1167   AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
1168     am_cv_func_iconv="no, consider installing GNU libiconv"
1169     am_cv_lib_iconv=no
1170     AC_TRY_LINK([#include <stdlib.h>
1171 #include <iconv.h>],
1172       [iconv_t cd = iconv_open("","");
1173        iconv(cd,NULL,NULL,NULL,NULL);
1174        iconv_close(cd);],
1175       am_cv_func_iconv=yes)
1176     if test "$am_cv_func_iconv" != yes; then
1177       am_save_LIBS="$LIBS"
1178       LIBS="$LIBS -liconv"
1179       AC_TRY_LINK([#include <stdlib.h>
1180 #include <iconv.h>],
1181         [iconv_t cd = iconv_open("","");
1182          iconv(cd,NULL,NULL,NULL,NULL);
1183          iconv_close(cd);],
1184         am_cv_lib_iconv=yes
1185         am_cv_func_iconv=yes)
1186       LIBS="$am_save_LIBS"
1187     fi
1188   ])
1189   if test "$am_cv_func_iconv" = yes; then
1190     AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
1191     AC_MSG_CHECKING([for iconv declaration])
1192     AC_CACHE_VAL(am_cv_proto_iconv, [
1193       AC_TRY_COMPILE([
1194 #include <stdlib.h>
1195 #include <iconv.h>
1196 extern
1197 #ifdef __cplusplus
1198 "C"
1199 #endif
1200 #if defined(__STDC__) || defined(__cplusplus)
1201 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
1202 #else
1203 size_t iconv();
1204 #endif
1205 ], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
1206       am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
1207     am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
1208     AC_MSG_RESULT([$]{ac_t:-
1209          }[$]am_cv_proto_iconv)
1210     AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
1211       [Define as const if the declaration of iconv() needs const.])
1212   fi
1213   LIBICONV=
1214   if test "$am_cv_lib_iconv" = yes; then
1215     LIBICONV="-liconv"
1216   fi
1217   AC_SUBST(LIBICONV)
1218 ])
1219
1220 #serial AM1
1221
1222 dnl From Bruno Haible.
1223
1224 AC_DEFUN([MUTT_AM_LANGINFO_CODESET],
1225 [
1226   AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
1227     [AC_TRY_LINK([#include <langinfo.h>],
1228       [char* cs = nl_langinfo(CODESET);],
1229       am_cv_langinfo_codeset=yes,
1230       am_cv_langinfo_codeset=no)
1231     ])
1232   if test $am_cv_langinfo_codeset = yes; then
1233     AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
1234       [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
1235   fi
1236 ])
1237
1238 # Check whether LC_MESSAGES is available in <locale.h>.
1239 # Ulrich Drepper <drepper@cygnus.com>, 1995.
1240 #
1241 # This file can be copied and used freely without restrictions.  It can
1242 # be used in projects which are not available under the GNU General Public
1243 # License or the GNU Library General Public License but which still want
1244 # to provide support for the GNU gettext functionality.
1245 # Please note that the actual code of the GNU gettext library is covered
1246 # by the GNU Library General Public License, and the rest of the GNU
1247 # gettext package package is covered by the GNU General Public License.
1248 # They are *not* in the public domain.
1249
1250 # serial 2
1251
1252 AC_DEFUN([MUTT_AM_LC_MESSAGES],
1253   [if test $ac_cv_header_locale_h = yes; then
1254     AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
1255       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
1256        am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
1257     if test $am_cv_val_LC_MESSAGES = yes; then
1258       AC_DEFINE(HAVE_LC_MESSAGES, 1,
1259         [Define if your <locale.h> file defines LC_MESSAGES.])
1260     fi
1261   fi])
1262
1263 #serial 2
1264
1265 # Test for the GNU C Library, version 2.1 or newer.
1266 # From Bruno Haible.
1267
1268 AC_DEFUN([MUTT_jm_GLIBC21],
1269   [
1270     AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer,
1271       ac_cv_gnu_library_2_1,
1272       [AC_EGREP_CPP([Lucky GNU user],
1273         [
1274 #include <features.h>
1275 #ifdef __GNU_LIBRARY__
1276  #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
1277   Lucky GNU user
1278  #endif
1279 #endif
1280         ],
1281         ac_cv_gnu_library_2_1=yes,
1282         ac_cv_gnu_library_2_1=no)
1283       ]
1284     )
1285     AC_SUBST(GLIBC21)
1286     GLIBC21="$ac_cv_gnu_library_2_1"
1287   ]
1288 )
1289
1290 dnl vim:ft=config:
1291
1292 dnl Search for libesmtp, by Steven Engelhardt <sengelha@yahoo.com>
1293 dnl
1294 dnl libesmtp often requires linking against -lpthread or -lc_r (BSD).
1295 dnl This macro attempts to centralize this code.
1296
1297 AC_DEFUN([MUTT_AM_LIBESMTP],
1298 [
1299   AC_ARG_WITH(
1300     [libesmtp],
1301     [  --with-libesmtp=DIR      Compile in support for libesmtp for the MTA],
1302     [ if test "$with_libesmtp" != "no"
1303       then
1304         mutt_libesmtp_check_path="$PATH"
1305
1306         if test "$with_libesmtp" != "yes"
1307         then
1308           mutt_libesmtp_check_path="$tmp_path:$withval/bin"
1309         fi
1310
1311         dnl 1. Find libesmtp-config
1312         AC_PATH_PROG([mutt_libesmtp_config_path],
1313                      [libesmtp-config],
1314                      [no],
1315                      [$mutt_libesmtp_check_path])
1316
1317         if test "$mutt_libesmtp_config_path" = "no"
1318         then
1319           AC_MSG_ERROR([libesmtp-config binary not found.])
1320         fi
1321
1322         dnl 2. Get CFLAGS and LIBS from libesmtp-config
1323         mutt_libesmtp_cflags=`$mutt_libesmtp_config_path --cflags`
1324         mutt_libesmtp_libs=`$mutt_libesmtp_config_path --libs`
1325
1326         dnl 3. Verify libesmtp.h can be found with these settings
1327         temp_CFLAGS="$CFLAGS"
1328         CFLAGS="$CFLAGS $mutt_libesmtp_cflags"
1329         AC_CHECK_HEADER([libesmtp.h],
1330                         [],
1331                         AC_MSG_ERROR([Could not find libesmtp.h]))
1332         CFLAGS="$temp_CFLAGS"
1333
1334         dnl 4. Verify the libesmtp library can be linked in
1335         temp_CFLAGS="$CFLAGS"
1336         temp_LIBS="$LIBS"
1337         CFLAGS="$CFLAGS $mutt_libesmtp_cflags"
1338         LIBS="$LIBS $mutt_libesmtp_libs"
1339         AC_CHECK_LIB([esmtp],
1340                      [smtp_create_session],
1341                      [],
1342                      AC_MSG_ERROR([Could not find libesmtp]))
1343         CFLAGS="$temp_CFLAGS"
1344         LIBS="$temp_LIBS"
1345
1346         dnl 5. Export use_libesmtp variable so configure.in can
1347         dnl    act accordingly.
1348         use_libesmtp=yes
1349       fi
1350     ]
1351   )
1352 ])
1353