summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2020-05-01 18:06:05 +0200
committerBruno Haible <bruno@clisp.org>2020-05-01 18:20:50 +0200
commit6c71b2c51bc633f230054d9496d6bb2f0c1d4874 (patch)
tree7220416a2e5fe25825661a2c487c7d4c91be700c /m4
parenta8544a6b85dc1ff7f592bb6d74989635f08b2e8a (diff)
downloadgnulib-6c71b2c51bc633f230054d9496d6bb2f0c1d4874.tar.gz
bison: New module.
* m4/bison.m4 (gl_PROG_BISON): New macro, extracted from m4/parse-datetime.m4. * m4/parse-datetime.m4 (gl_PARSE_DATETIME): Invoke gl_PROG_BISON. * modules/bison: New file. * modules/parse-datetime (Files): Remove m4/bison.m4. (Depends-on): Add bison.
Diffstat (limited to 'm4')
-rw-r--r--m4/bison.m468
-rw-r--r--m4/parse-datetime.m424
2 files changed, 67 insertions, 25 deletions
diff --git a/m4/bison.m4 b/m4/bison.m4
index 6326cd50f2..5802a5ca51 100644
--- a/m4/bison.m4
+++ b/m4/bison.m4
@@ -1,13 +1,75 @@
-# serial 7
+# serial 8
-# Copyright (C) 2002, 2005, 2009-2020 Free Software Foundation, Inc.
+# Copyright (C) 2002-2006, 2008-2020 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
+# There are two types of parser skeletons:
+#
+# * Those that can be used with any Yacc implementation, including bison.
+# For these, in the configure.ac, up to Autoconf 2.69, you could use
+# AC_PROG_YACC
+# In newer Autoconf versions, however, this macro is broken. See
+# https://lists.gnu.org/archive/html/autoconf-patches/2013-03/msg00000.html
+# https://lists.gnu.org/archive/html/bug-autoconf/2018-12/msg00001.html
+# In the Makefile.am you could use
+# $(SHELL) $(YLWRAP) $(srcdir)/foo.y \
+# y.tab.c foo.c \
+# y.tab.h foo.h \
+# y.output foo.output \
+# -- $(YACC) $(YFLAGS) $(AM_YFLAGS)
+# or similar.
+#
+# * Those that make use of Bison extensions. For example,
+# - %define api.pure requires bison 2.7 or newer,
+# - %precedence requires bison 3.0 or newer.
+# For these, in the configure.ac you will need an invocation of
+# gl_PROG_BISON([VARIABLE], [MIN_BISON_VERSION], [BISON_VERSIONS_TO_EXCLUDE])
+# Example:
+# gl_PROG_BISON([PARSE_DATETIME_BISON], [2.4], [1.* | 2.[0-3] | 2.[0-3].*])
+# With this preparation, in the Makefile.am there are two ways to formulate
+# the invocation. Both are direct, without use of 'ylwrap'.
+# (a) You can invoke
+# $(VARIABLE) -d $(SOME_BISON_OPTIONS) --output foo.c $(srcdir)/foo.y
+# or similar.
+# (b) If you want the invocation to honor an YFLAGS=... parameter passed to
+# 'configure' or an YFLAGS environment variable present at 'configure'
+# time, add an invocation of gl_BISON to the configure.ac, and write
+# $(VARIABLE) -d $(YFLAGS) $(AM_YFLAGS) $(srcdir)/foo.y
+# or similar.
+
+# This macro defines the autoconf variable VARIABLE to 'bison' if the specified
+# minimum version of bison is found in $PATH, or to ':' otherwise.
+AC_DEFUN([gl_PROG_BISON],
+[
+ AC_CHECK_PROGS([$1], [bison])
+ if test -z "$[$1]"; then
+ ac_verc_fail=yes
+ else
+ dnl Found it, now check the version.
+ AC_MSG_CHECKING([version of bison])
+changequote(<<,>>)dnl
+ ac_prog_version=`$<<$1>> --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
+ case $ac_prog_version in
+ '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
+ <<$3>>)
+ ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
+ *) ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
+ esac
+changequote([,])dnl
+ AC_MSG_RESULT([$ac_prog_version])
+ fi
+ if test $ac_verc_fail = yes; then
+ [$1]=:
+ fi
+ AC_SUBST([$1])
+])
+
+# This macro sets the autoconf variables YACC (for old-style yacc Makefile
+# rules) and YFLAGS (to allow options to be passed as 'configure' time).
AC_DEFUN([gl_BISON],
[
- # parse-datetime.y works with bison only.
: ${YACC='bison -o y.tab.c'}
dnl
dnl Declaring YACC & YFLAGS precious will not be necessary after GNULIB
diff --git a/m4/parse-datetime.m4 b/m4/parse-datetime.m4
index 52a10aa51c..0849b82036 100644
--- a/m4/parse-datetime.m4
+++ b/m4/parse-datetime.m4
@@ -1,4 +1,4 @@
-# parse-datetime.m4 serial 24
+# parse-datetime.m4 serial 25
dnl Copyright (C) 2002-2006, 2008-2020 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -35,27 +35,7 @@ AC_DEFUN([gl_PARSE_DATETIME],
dnl the files or have a broken "make" program, hence the parse-datetime.c
dnl rule will sometimes fire. To avoid an error, defines PARSE_DATETIME_BISON
dnl to ":" if it is not present or too old.
- AC_CHECK_PROGS([PARSE_DATETIME_BISON], [bison])
- if test -z "$PARSE_DATETIME_BISON"; then
- ac_verc_fail=yes
- else
- dnl Found it, now check the version.
- AC_MSG_CHECKING([version of bison])
-changequote(<<,>>)dnl
- ac_prog_version=`$PARSE_DATETIME_BISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
- case $ac_prog_version in
- '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
- 1.* | 2.[0-3] | 2.[0-3].*)
-changequote([,])dnl
- ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
- *) ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
- esac
- AC_MSG_RESULT([$ac_prog_version])
- fi
- if test $ac_verc_fail = yes; then
- PARSE_DATETIME_BISON=:
- fi
- AC_SUBST([PARSE_DATETIME_BISON])
+ gl_PROG_BISON([PARSE_DATETIME_BISON], [2.4], [1.* | 2.[0-3] | 2.[0-3].*])
dnl Prerequisites of lib/parse-datetime.h.
AC_REQUIRE([AM_STDBOOL_H])