immutable: Add tests.
[gnulib.git] / m4 / bison-i18n.m4
blob1d25aae137ee473f1e3109bd23de7ad2f734bee3
1 # bison-i18n.m4 serial 4
2 dnl Copyright (C) 2005-2006, 2009-2021 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 dnl From Bruno Haible.
9 dnl Support for internationalization of bison-generated parsers.
11 dnl BISON_I18N
12 dnl should be used in configure.ac, after AM_GNU_GETTEXT. If USE_NLS is yes, it
13 dnl sets BISON_LOCALEDIR to indicate where to find the bison-runtime.mo files
14 dnl and defines YYENABLE_NLS if there are bison-runtime.mo files at all.
15 AC_DEFUN([BISON_I18N],
17   if test -z "$USE_NLS"; then
18     echo "The BISON-I18N macro is used without being preceded by AM-GNU-GETTEXT." | sed -e 's/-/_/g' 1>&2
19     exit 1
20   fi
21   BISON_LOCALEDIR=
22   BISON_USE_NLS=no
23   if test "$USE_NLS" = yes; then
24     dnl Determine bison's localedir.
25     dnl Generally, accept an option --with-bison-prefix=PREFIX to indicate where
26     dnl find bison's runtime data. Additionally, for users who have installed
27     dnl bison in user directories, query the 'bison' program found in $PATH
28     dnl (but not when cross-compiling).
29     dnl Usually ${prefix}/share/locale, but can be influenced by the configure
30     dnl options --datarootdir and --localedir.
31     BISON_LOCALEDIR="${localedir}"
32     AC_ARG_WITH([bison-prefix],
33       [[  --with-bison-prefix=DIR  search for bison's runtime data in DIR/share]],
34       [if test "X$withval" != "X" && test "X$withval" != "Xno"; then
35          BISON_LOCALEDIR="$withval/share/locale"
36        fi
37       ])
38     if test $cross_compiling != yes; then
39       dnl AC_PROG_YACC sets the YACC variable; other macros set the BISON
40       dnl variable. But even is YACC is called "yacc", it may be a script that
41       dnl invokes bison and accepts the --print-localedir option.
42       dnl YACC's default value is empty; BISON's default value is :.
43       if (${YACC-${BISON-:}} --print-localedir) >/dev/null 2>&1; then
44         BISON_LOCALEDIR=`${YACC-${BISON-:}} --print-localedir`
45       fi
46     fi
47     if test -n "$BISON_LOCALEDIR"; then
48       dnl There is no need to enable internationalization if the user doesn't
49       dnl want message catalogs.  So look at the language/locale names for
50       dnl which the user wants message catalogs.  This is $LINGUAS.  If unset,
51       dnl he wants all of them; if non-empty, he wants some of them.
52       USER_LINGUAS="${LINGUAS-%UNSET%}"
53       if test -n "$USER_LINGUAS"; then
54         BISON_USE_NLS=yes
55       fi
56     fi
57     AC_SUBST([BISON_LOCALEDIR])
58   fi
59   if test $BISON_USE_NLS = yes; then
60     AC_DEFINE([YYENABLE_NLS], [1],
61       [Define to 1 to internationalize bison runtime messages.])
62   fi