]> Savannah Git Hosting - gnulib.git/commitdiff
bison: New module.
authorBruno Haible <bruno@clisp.org>
Fri, 1 May 2020 16:06:05 +0000 (18:06 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 1 May 2020 16:20:50 +0000 (18:20 +0200)
* 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.

ChangeLog
m4/bison.m4
m4/parse-datetime.m4
modules/bison [new file with mode: 0644]
modules/parse-datetime

index 60c3e3aaf906897f4a311b02768ccc972e0e61b4..be6d1f132eba85dd0f614f583a4b31411fda6e33 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2020-05-01  Bruno Haible  <bruno@clisp.org>
+
+       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.
+
 2020-05-01  Jose E. Marchesi  <jemarch@gnu.org>
 
        Update users.txt.
index 6326cd50f293e5550a35fbfee3791b5c3da1d0a0..5802a5ca51c86479c6d351300861ea437f3e240b 100644 (file)
@@ -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
index 52a10aa51cd424c9bf7895f243548d42cd6dc7f5..0849b82036ec3db33547b159ec40268083ba3614 100644 (file)
@@ -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])
diff --git a/modules/bison b/modules/bison
new file mode 100644 (file)
index 0000000..126c5ec
--- /dev/null
@@ -0,0 +1,21 @@
+Description:
+Building bison-generated parsers.
+
+Files:
+m4/bison.m4
+
+Depends-on:
+
+configure.ac:
+# See the comments in bison.m4.
+
+Makefile.am:
+# See the comments in bison.m4.
+
+Include:
+
+License:
+GPLed build tool
+
+Maintainer:
+all
index 5ef3264f05d3795046ea2b57cd375e087c84c9f4..7571e066f2d72c943b25f593793b8bf91494ba06 100644 (file)
@@ -5,11 +5,11 @@ Files:
 doc/parse-datetime.texi
 lib/parse-datetime.h
 lib/parse-datetime.y
-m4/bison.m4
 m4/tm_gmtoff.m4
 m4/parse-datetime.m4
 
 Depends-on:
+bison
 c-ctype
 stdbool
 gettime