3 # Copyright (C) 2002-2006, 2008-2020 Free Software Foundation, Inc.
4 # This file is free software; the Free Software Foundation
5 # gives unlimited permission to copy and/or distribute it,
6 # with or without modifications, as long as this notice is preserved.
8 # There are two types of parser skeletons:
10 # * Those that can be used with any Yacc implementation, including bison.
11 # For these, in the configure.ac, up to Autoconf 2.69, you could use
13 # In newer Autoconf versions, however, this macro is broken. See
14 # https://lists.gnu.org/archive/html/autoconf-patches/2013-03/msg00000.html
15 # https://lists.gnu.org/archive/html/bug-autoconf/2018-12/msg00001.html
16 # In the Makefile.am you could use
17 # $(SHELL) $(YLWRAP) $(srcdir)/foo.y \
20 # y.output foo.output \
21 # -- $(YACC) $(YFLAGS) $(AM_YFLAGS)
24 # * Those that make use of Bison extensions. For example,
25 # - %define api.pure requires bison 2.7 or newer,
26 # - %precedence requires bison 3.0 or newer.
27 # For these, in the configure.ac you will need an invocation of
28 # gl_PROG_BISON([VARIABLE], [MIN_BISON_VERSION])
30 # gl_PROG_BISON([PARSE_DATETIME_BISON], [2.4])
31 # With this preparation, in the Makefile.am there are two ways to formulate
32 # the invocation. Both are direct, without use of 'ylwrap'.
34 # $(VARIABLE) -d $(SOME_BISON_OPTIONS) --output foo.c $(srcdir)/foo.y
36 # (b) If you want the invocation to honor an YFLAGS=... parameter passed to
37 # 'configure' or an YFLAGS environment variable present at 'configure'
38 # time, add an invocation of gl_BISON to the configure.ac, and write
39 # $(VARIABLE) -d $(YFLAGS) $(AM_YFLAGS) $(srcdir)/foo.y
42 # This macro defines the autoconf variable VARIABLE to 'bison' if the specified
43 # minimum version of bison is found in $PATH, or to ':' otherwise.
44 AC_DEFUN([gl_PROG_BISON],
46 AC_CHECK_PROGS([$1], [bison])
47 if test -z "$[$1]"; then
50 cat >conftest.y <<_ACEOF
55 AC_MSG_CHECKING([for bison $2 or newer])
56 ac_prog_version=`$$1 --version 2>&1 | sed -n 's/^.*GNU Bison.* \([[0-9]]*\.[[0-9.]]*\).*$/\1/p'`
57 : ${ac_prog_version:='v. ?.??'}
58 if $$1 conftest.y -o conftest.c 2>/dev/null; then
59 ac_prog_version="$ac_prog_version, ok"
62 ac_prog_version="$ac_prog_version, bad"
65 rm -f conftest.y conftest.c
66 AC_MSG_RESULT([$ac_prog_version])
68 if test $ac_verc_fail = yes; then
74 # This macro sets the autoconf variables YACC (for old-style yacc Makefile
75 # rules) and YFLAGS (to allow options to be passed as 'configure' time).
78 : ${YACC='bison -o y.tab.c'}
80 dnl Declaring YACC & YFLAGS precious will not be necessary after GNULIB
81 dnl requires an Autoconf greater than 2.59c, but it will probably still be
82 dnl useful to override the description of YACC in the --help output, re
83 dnl parse-datetime.y assuming 'bison -o y.tab.c'.
85 [The "Yet Another C Compiler" implementation to use. Defaults to
86 'bison -o y.tab.c'. Values other than 'bison -o y.tab.c' will most likely
87 break on most systems.])dnl
89 [YFLAGS contains the list arguments that will be passed by default to Bison.
90 This script will default YFLAGS to the empty string to avoid a default value of
91 '-d' given by some make applications.])dnl