New module 'bison-i18n'.
[gnulib.git] / m4 / bison-i18n.m4
1 # bison-i18n.m4 serial 1 (bison-2.1)
2 dnl Copyright (C) 2005 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.
6
7 dnl From Bruno Haible.
8
9 dnl Support for internationalization of bison-generated parsers.
10
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],
16 [
17   if test -z "$USE_NLS"; then
18     echo "The BISON-I18N macro is used without being preceded by AM-GNU-GETTEXT." 1>&2
19     exit 1
20   fi
21   BISON_LOCALEDIR=
22   if test "$USE_NLS" = yes; then
23     dnl AC_PROG_YACC sets the YACC variable; other macros set the BISON variable.
24     if test -n "$YACC"; then
25       case "$YACC" in
26         *bison*)
27           if ($YACC --print-localedir) >/dev/null 2>&1; then
28             BISON_LOCALEDIR=`$YACC --print-localedir`
29           fi
30           ;;
31       esac
32     else
33       if test -n "$BISON"; then
34         if test "$BISON" != ":"; then
35           if ($BISON --print-localedir) >/dev/null 2>&1; then
36             BISON_LOCALEDIR=`$BISON --print-localedir`
37           fi
38         fi
39       fi
40     fi
41     AC_SUBST([BISON_LOCALEDIR])
42     if test -n "$BISON_LOCALEDIR"; then
43       USER_LINGUAS="${LINGUAS-%UNSET%}"
44       if test -n "$USER_LINGUAS"; then
45         BISON_USE_NLS=yes
46       else
47         BISON_USE_NLS=no
48       fi
49     else
50       BISON_USE_NLS=no
51     fi
52   else
53     BISON_USE_NLS=no
54   fi
55   if test $BISON_USE_NLS = yes; then
56     AC_DEFINE([YYENABLE_NLS], 1,
57       [Define to 1 to internationalize bison runtime messages.])
58   fi
59 ])