(file_type): New file/function. Extracted from diffutils.
[gnulib.git] / m4 / gettext.m4
1 # gettext.m4 serial 12 (gettext-0.11)
2 dnl Copyright (C) 1995-2002 Free Software Foundation, Inc.
3 dnl This file is free software, distributed under the terms of the GNU
4 dnl General Public License.  As a special exception to the GNU General
5 dnl Public License, this file may be distributed as part of a program
6 dnl that contains a configuration script generated by Autoconf, under
7 dnl the same distribution terms as the rest of that program.
8 dnl
9 dnl This file can can be used in projects which are not available under
10 dnl the GNU General Public License or the GNU Library General Public
11 dnl License but which still want to provide support for the GNU gettext
12 dnl functionality.
13 dnl Please note that the actual code of the GNU gettext library is covered
14 dnl by the GNU Library General Public License, and the rest of the GNU
15 dnl gettext package package is covered by the GNU General Public License.
16 dnl They are *not* in the public domain.
17
18 dnl Authors:
19 dnl   Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
20 dnl   Bruno Haible <haible@clisp.cons.org>, 2000-2002.
21
22 dnl Macro to add for using GNU gettext.
23
24 dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]).
25 dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The
26 dnl    default (if it is not specified or empty) is 'no-libtool'.
27 dnl    INTLSYMBOL should be 'external' for packages with no intl directory,
28 dnl    and 'no-libtool' or 'use-libtool' for packages with an intl directory.
29 dnl    If INTLSYMBOL is 'use-libtool', then a libtool library
30 dnl    $(top_builddir)/intl/libintl.la will be created (shared and/or static,
31 dnl    depending on --{enable,disable}-{shared,static} and on the presence of
32 dnl    AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library
33 dnl    $(top_builddir)/intl/libintl.a will be created.
34 dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
35 dnl    implementations (in libc or libintl) without the ngettext() function
36 dnl    will be ignored.
37 dnl INTLDIR is used to find the intl libraries.  If empty,
38 dnl    the value `$(top_builddir)/intl/' is used.
39 dnl
40 dnl The result of the configuration is one of three cases:
41 dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
42 dnl    and used.
43 dnl    Catalog format: GNU --> install in $(datadir)
44 dnl    Catalog extension: .mo after installation, .gmo in source tree
45 dnl 2) GNU gettext has been found in the system's C library.
46 dnl    Catalog format: GNU --> install in $(datadir)
47 dnl    Catalog extension: .mo after installation, .gmo in source tree
48 dnl 3) No internationalization, always use English msgid.
49 dnl    Catalog format: none
50 dnl    Catalog extension: none
51 dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur.
52 dnl The use of .gmo is historical (it was needed to avoid overwriting the
53 dnl GNU format catalogs when building on a platform with an X/Open gettext),
54 dnl but we keep it in order not to force irrelevant filename changes on the
55 dnl maintainers.
56 dnl
57 AC_DEFUN([AM_GNU_GETTEXT],
58 [
59   dnl Argument checking.
60   ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], ,
61     [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT
62 ])])])])])
63   ifelse([$2], [], , [ifelse([$2], [need-ngettext], ,
64     [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT
65 ])])])
66   define(gt_included_intl, ifelse([$1], [external], [no], [yes]))
67   define(gt_libtool_suffix_prefix, ifelse([$1], [use-libtool], [l], []))
68
69   AC_REQUIRE([AM_PO_SUBDIRS])dnl
70   ifelse(gt_included_intl, yes, [
71     AC_REQUIRE([AM_INTL_SUBDIR])dnl
72   ])
73
74   dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
75   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
76   AC_REQUIRE([AC_LIB_RPATH])
77
78   AC_MSG_CHECKING([whether NLS is requested])
79   dnl Default is enabled NLS
80   AC_ARG_ENABLE(nls,
81     [  --disable-nls           do not use Native Language Support],
82     USE_NLS=$enableval, USE_NLS=yes)
83   AC_MSG_RESULT($USE_NLS)
84   AC_SUBST(USE_NLS)
85
86   ifelse(gt_included_intl, yes, [
87     BUILD_INCLUDED_LIBINTL=no
88     USE_INCLUDED_LIBINTL=no
89   ])
90   LIBINTL=
91   LTLIBINTL=
92   POSUB=
93
94   dnl If we use NLS figure out what method
95   if test "$USE_NLS" = "yes"; then
96     gt_use_preinstalled_gnugettext=no
97     ifelse(gt_included_intl, yes, [
98       AC_MSG_CHECKING([whether included gettext is requested])
99       AC_ARG_WITH(included-gettext,
100         [  --with-included-gettext use the GNU gettext library included here],
101         nls_cv_force_use_gnu_gettext=$withval,
102         nls_cv_force_use_gnu_gettext=no)
103       AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
104
105       nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
106       if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
107     ])
108         dnl User does not insist on using GNU NLS library.  Figure out what
109         dnl to use.  If GNU gettext is available we use this.  Else we have
110         dnl to fall back to GNU NLS library.
111
112         dnl Add a version number to the cache macros.
113         define([gt_api_version], ifelse([$2], [need-ngettext], 2, 1))
114         define([gt_cv_func_gnugettext_libc], [gt_cv_func_gnugettext]gt_api_version[_libc])
115         define([gt_cv_func_gnugettext_libintl], [gt_cv_func_gnugettext]gt_api_version[_libintl])
116
117         AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc,
118          [AC_TRY_LINK([#include <libintl.h>
119 extern int _nl_msg_cat_cntr;],
120             [bindtextdomain ("", "");
121 return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr],
122             gt_cv_func_gnugettext_libc=yes,
123             gt_cv_func_gnugettext_libc=no)])
124
125         if test "$gt_cv_func_gnugettext_libc" != "yes"; then
126           dnl Sometimes libintl requires libiconv, so first search for libiconv.
127           ifelse(gt_included_intl, yes, , [
128             AM_ICONV_LINK
129           ])
130           dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL
131           dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv])
132           dnl because that would add "-liconv" to LIBINTL and LTLIBINTL
133           dnl even if libiconv doesn't exist.
134           AC_LIB_LINKFLAGS_BODY([intl])
135           AC_CACHE_CHECK([for GNU gettext in libintl],
136             gt_cv_func_gnugettext_libintl,
137            [gt_save_CPPFLAGS="$CPPFLAGS"
138             CPPFLAGS="$CPPFLAGS $INCINTL"
139             gt_save_LIBS="$LIBS"
140             LIBS="$LIBS $LIBINTL"
141             dnl Now see whether libintl exists and does not depend on libiconv.
142             AC_TRY_LINK([#include <libintl.h>
143 extern int _nl_msg_cat_cntr;],
144               [bindtextdomain ("", "");
145 return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr],
146               gt_cv_func_gnugettext_libintl=yes,
147               gt_cv_func_gnugettext_libintl=no)
148             dnl Now see whether libintl exists and depends on libiconv.
149             if test "$gt_cv_func_gnugettext_libintl" != yes && test -n "$LIBICONV"; then
150               LIBS="$LIBS $LIBICONV"
151               AC_TRY_LINK([#include <libintl.h>
152 extern int _nl_msg_cat_cntr;],
153                 [bindtextdomain ("", "");
154 return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr],
155                [LIBINTL="$LIBINTL $LIBICONV"
156                 LTLIBINTL="$LTLIBINTL $LTLIBICONV"
157                 gt_cv_func_gnugettext_libintl=yes
158                ])
159             fi
160             CPPFLAGS="$gt_save_CPPFLAGS"
161             LIBS="$gt_save_LIBS"])
162         fi
163
164         dnl If an already present or preinstalled GNU gettext() is found,
165         dnl use it.  But if this macro is used in GNU gettext, and GNU
166         dnl gettext is already preinstalled in libintl, we update this
167         dnl libintl.  (Cf. the install rule in intl/Makefile.in.)
168         if test "$gt_cv_func_gnugettext_libc" = "yes" \
169            || { test "$gt_cv_func_gnugettext_libintl" = "yes" \
170                 && test "$PACKAGE" != gettext; }; then
171           gt_use_preinstalled_gnugettext=yes
172         fi
173
174     ifelse(gt_included_intl, yes, [
175         if test "$gt_use_preinstalled_gnugettext" != "yes"; then
176           dnl GNU gettext is not found in the C library.
177           dnl Fall back on included GNU gettext library.
178           nls_cv_use_gnu_gettext=yes
179         fi
180       fi
181
182       if test "$nls_cv_use_gnu_gettext" = "yes"; then
183         dnl Mark actions used to generate GNU NLS library.
184         INTLOBJS="\$(GETTOBJS)"
185         BUILD_INCLUDED_LIBINTL=yes
186         USE_INCLUDED_LIBINTL=yes
187         LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV"
188         LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV"
189         LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
190       fi
191
192       if test "$gt_use_preinstalled_gnugettext" = "yes" \
193          || test "$nls_cv_use_gnu_gettext" = "yes"; then
194         dnl Mark actions to use GNU gettext tools.
195         CATOBJEXT=.gmo
196       fi
197     ])
198
199     if test "$gt_use_preinstalled_gnugettext" = "yes" \
200        || test "$nls_cv_use_gnu_gettext" = "yes"; then
201       AC_DEFINE(ENABLE_NLS, 1,
202         [Define to 1 if translation of program messages to the user's native language
203    is requested.])
204     else
205       USE_NLS=no
206     fi
207   fi
208
209   if test "$USE_NLS" = "yes"; then
210
211     if test "$gt_use_preinstalled_gnugettext" = "yes"; then
212       if test "$gt_cv_func_gnugettext_libintl" = "yes"; then
213         AC_MSG_CHECKING([how to link with libintl])
214         AC_MSG_RESULT([$LIBINTL])
215         AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL])
216       fi
217
218       dnl For backward compatibility. Some packages may be using this.
219       AC_DEFINE(HAVE_GETTEXT, 1,
220        [Define if the GNU gettext() function is already present or preinstalled.])
221       AC_DEFINE(HAVE_DCGETTEXT, 1,
222        [Define if the GNU dcgettext() function is already present or preinstalled.])
223     fi
224
225     dnl We need to process the po/ directory.
226     POSUB=po
227   fi
228
229   ifelse(gt_included_intl, yes, [
230     dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
231     dnl to 'yes' because some of the testsuite requires it.
232     if test "$PACKAGE" = gettext; then
233       BUILD_INCLUDED_LIBINTL=yes
234     fi
235
236     dnl Make all variables we use known to autoconf.
237     AC_SUBST(BUILD_INCLUDED_LIBINTL)
238     AC_SUBST(USE_INCLUDED_LIBINTL)
239     AC_SUBST(CATOBJEXT)
240     AC_SUBST(INTLOBJS)
241
242     dnl For backward compatibility. Some configure.ins may be using this.
243     nls_cv_header_intl=
244     nls_cv_header_libgt=
245
246     dnl For backward compatibility. Some Makefiles may be using this.
247     DATADIRNAME=share
248     AC_SUBST(DATADIRNAME)
249
250     dnl For backward compatibility. Some Makefiles may be using this.
251     INSTOBJEXT=.mo
252     AC_SUBST(INSTOBJEXT)
253
254     dnl For backward compatibility. Some Makefiles may be using this.
255     GENCAT=gencat
256     AC_SUBST(GENCAT)
257
258     dnl Enable libtool support if the surrounding package wishes it.
259     INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix
260     AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX)
261   ])
262
263   dnl For backward compatibility. Some Makefiles may be using this.
264   INTLLIBS="$LIBINTL"
265   AC_SUBST(INTLLIBS)
266
267   dnl Make all documented variables known to autoconf.
268   AC_SUBST(LIBINTL)
269   AC_SUBST(LTLIBINTL)
270   AC_SUBST(POSUB)
271 ])
272
273
274 dnl Checks for all prerequisites of the po subdirectory,
275 dnl except for USE_NLS.
276 AC_DEFUN([AM_PO_SUBDIRS],
277 [
278   AC_REQUIRE([AC_PROG_MAKE_SET])dnl
279   AC_REQUIRE([AC_PROG_INSTALL])dnl
280   AC_REQUIRE([AM_MKINSTALLDIRS])dnl
281
282   dnl Perform the following tests also if --disable-nls has been given,
283   dnl because they are needed for "make dist" to work.
284
285   dnl Search for GNU msgfmt in the PATH.
286   dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions.
287   dnl The second test excludes FreeBSD msgfmt.
288   AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
289     [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1 &&
290      (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
291     :)
292   AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
293
294   dnl Search for GNU xgettext 0.11 or newer in the PATH.
295   dnl The first test excludes Solaris xgettext and early GNU xgettext versions.
296   dnl The second test excludes FreeBSD xgettext.
297   AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
298     [$ac_dir/$ac_word --omit-header --copyright-holder= /dev/null >/dev/null 2>&1 &&
299      (if $ac_dir/$ac_word --omit-header --copyright-holder= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
300     :)
301   dnl Remove leftover from FreeBSD xgettext call.
302   rm -f messages.po
303
304   dnl Search for GNU msgmerge 0.11 or newer in the PATH.
305   AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge,
306     [$ac_dir/$ac_word --update -q /dev/null /dev/null >/dev/null 2>&1], :)
307
308   dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
309   dnl Test whether we really found GNU msgfmt.
310   if test "$GMSGFMT" != ":"; then
311     dnl If it is no GNU msgfmt we define it as : so that the
312     dnl Makefiles still can work.
313     if $GMSGFMT --statistics /dev/null >/dev/null 2>&1 &&
314        (if $GMSGFMT --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then
315       : ;
316     else
317       GMSGFMT=`echo "$GMSGFMT" | sed -e 's,^.*/,,'`
318       AC_MSG_RESULT(
319         [found $GMSGFMT program is not GNU msgfmt; ignore it])
320       GMSGFMT=":"
321     fi
322   fi
323
324   dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
325   dnl Test whether we really found GNU xgettext.
326   if test "$XGETTEXT" != ":"; then
327     dnl If it is no GNU xgettext we define it as : so that the
328     dnl Makefiles still can work.
329     if $XGETTEXT --omit-header --copyright-holder= /dev/null >/dev/null 2>&1 &&
330        (if $XGETTEXT --omit-header --copyright-holder= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then
331       : ;
332     else
333       AC_MSG_RESULT(
334         [found xgettext program is not GNU xgettext; ignore it])
335       XGETTEXT=":"
336     fi
337     dnl Remove leftover from FreeBSD xgettext call.
338     rm -f messages.po
339   fi
340
341   AC_OUTPUT_COMMANDS([
342     for ac_file in $CONFIG_FILES; do
343       # Support "outfile[:infile[:infile...]]"
344       case "$ac_file" in
345         *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
346       esac
347       # PO directories have a Makefile.in generated from Makefile.in.in.
348       case "$ac_file" in */Makefile.in)
349         # Adjust a relative srcdir.
350         ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
351         ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
352         ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
353         # In autoconf-2.13 it is called $ac_given_srcdir.
354         # In autoconf-2.50 it is called $srcdir.
355         test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
356         case "$ac_given_srcdir" in
357           .)  top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
358           /*) top_srcdir="$ac_given_srcdir" ;;
359           *)  top_srcdir="$ac_dots$ac_given_srcdir" ;;
360         esac
361         if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
362           rm -f "$ac_dir/POTFILES"
363           test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
364           cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[   ]*\$/d" -e "s,.*,     $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES"
365           # ALL_LINGUAS, POFILES, GMOFILES, UPDATEPOFILES, DUMMYPOFILES depend
366           # on $ac_dir but don't depend on user-specified configuration
367           # parameters.
368           if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then
369             # The LINGUAS file contains the set of available languages.
370             if test -n "$ALL_LINGUAS"; then
371               test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete"
372             fi
373             ALL_LINGUAS_=`sed -e "/^#/d" "$ac_given_srcdir/$ac_dir/LINGUAS"`
374             # Hide the ALL_LINGUAS assigment from automake.
375             eval 'ALL_LINGUAS''=$ALL_LINGUAS_'
376           fi
377           case "$ac_given_srcdir" in
378             .) srcdirpre= ;;
379             *) srcdirpre='$(srcdir)/' ;;
380           esac
381           POFILES=
382           GMOFILES=
383           UPDATEPOFILES=
384           DUMMYPOFILES=
385           for lang in $ALL_LINGUAS; do
386             POFILES="$POFILES $srcdirpre$lang.po"
387             GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
388             UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
389             DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
390           done
391           # CATALOGS depends on both $ac_dir and the user's LINGUAS
392           # environment variable.
393           INST_LINGUAS=
394           if test -n "$ALL_LINGUAS"; then
395             for presentlang in $ALL_LINGUAS; do
396               useit=no
397               if test "%UNSET%" != "$LINGUAS"; then
398                 desiredlanguages="$LINGUAS"
399               else
400                 desiredlanguages="$ALL_LINGUAS"
401               fi
402               for desiredlang in $desiredlanguages; do
403                 # Use the presentlang catalog if desiredlang is
404                 #   a. equal to presentlang, or
405                 #   b. a variant of presentlang (because in this case,
406                 #      presentlang can be used as a fallback for messages
407                 #      which are not translated in the desiredlang catalog).
408                 case "$desiredlang" in
409                   "$presentlang"*) useit=yes;;
410                 esac
411               done
412               if test $useit = yes; then
413                 INST_LINGUAS="$INST_LINGUAS $presentlang"
414               fi
415             done
416           fi
417           CATALOGS=
418           if test -n "$INST_LINGUAS"; then
419             for lang in $INST_LINGUAS; do
420               CATALOGS="$CATALOGS $lang.gmo"
421             done
422           fi
423           test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile"
424           sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile"
425           for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do
426             if test -f "$f"; then
427               case "$f" in
428                 *.orig | *.bak | *~) ;;
429                 *) cat "$f" >> "$ac_dir/Makefile" ;;
430               esac
431             fi
432           done
433         fi
434         ;;
435       esac
436     done],
437    [# Capture the value of obsolete $ALL_LINGUAS because we need it to compute
438     # POFILES, GMOFILES, UPDATEPOFILES, DUMMYPOFILES, CATALOGS. But hide it
439     # from automake.
440     eval 'ALL_LINGUAS''="$ALL_LINGUAS"'
441     # Capture the value of LINGUAS because we need it to compute CATALOGS.
442     LINGUAS="${LINGUAS-%UNSET%}"
443    ])
444 ])
445
446
447 dnl Checks for all prerequisites of the intl subdirectory,
448 dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS,
449 dnl            USE_INCLUDED_LIBINTL, BUILD_INCLUDED_LIBINTL.
450 AC_DEFUN([AM_INTL_SUBDIR],
451 [
452   AC_REQUIRE([AC_PROG_INSTALL])dnl
453   AC_REQUIRE([AM_MKINSTALLDIRS])dnl
454   AC_REQUIRE([AC_PROG_CC])dnl
455   AC_REQUIRE([AC_CANONICAL_HOST])dnl
456   AC_REQUIRE([AC_PROG_RANLIB])dnl
457   AC_REQUIRE([AC_ISC_POSIX])dnl
458   AC_REQUIRE([AC_HEADER_STDC])dnl
459   AC_REQUIRE([AC_C_CONST])dnl
460   AC_REQUIRE([AC_C_INLINE])dnl
461   AC_REQUIRE([AC_TYPE_OFF_T])dnl
462   AC_REQUIRE([AC_TYPE_SIZE_T])dnl
463   AC_REQUIRE([AC_FUNC_ALLOCA])dnl
464   AC_REQUIRE([AC_FUNC_MMAP])dnl
465   AC_REQUIRE([jm_GLIBC21])dnl
466
467   AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
468 stdlib.h string.h unistd.h sys/param.h])
469   AC_CHECK_FUNCS([feof_unlocked fgets_unlocked getc_unlocked getcwd getegid \
470 geteuid getgid getuid mempcpy munmap putenv setenv setlocale stpcpy \
471 strcasecmp strdup strtoul tsearch __argz_count __argz_stringify __argz_next])
472
473   AM_ICONV
474   AM_LANGINFO_CODESET
475   AM_LC_MESSAGES
476
477   dnl intl/plural.c is generated from intl/plural.y. It requires bison,
478   dnl because plural.y uses bison specific features. It requires at least
479   dnl bison-1.26 because earlier versions generate a plural.c that doesn't
480   dnl compile.
481   dnl bison is only needed for the maintainer (who touches plural.y). But in
482   dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
483   dnl the rule in general Makefile. Now, some people carelessly touch the
484   dnl files or have a broken "make" program, hence the plural.c rule will
485   dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
486   dnl present or too old.
487   AC_CHECK_PROGS([INTLBISON], [bison])
488   if test -z "$INTLBISON"; then
489     ac_verc_fail=yes
490   else
491     dnl Found it, now check the version.
492     AC_MSG_CHECKING([version of bison])
493 changequote(<<,>>)dnl
494     ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
495     case $ac_prog_version in
496       '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
497       1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
498 changequote([,])dnl
499          ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
500       *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
501     esac
502     AC_MSG_RESULT([$ac_prog_version])
503   fi
504   if test $ac_verc_fail = yes; then
505     INTLBISON=:
506   fi
507 ])
508
509
510 AC_DEFUN([AM_MKINSTALLDIRS],
511 [
512   dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
513   dnl find the mkinstalldirs script in another subdir but $(top_srcdir).
514   dnl Try to locate is.
515   MKINSTALLDIRS=
516   if test -n "$ac_aux_dir"; then
517     MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
518   fi
519   if test -z "$MKINSTALLDIRS"; then
520     MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
521   fi
522   AC_SUBST(MKINSTALLDIRS)
523 ])