From: Bruno Haible Date: Fri, 1 May 2020 16:06:05 +0000 (+0200) Subject: bison: New module. X-Git-Tag: v1.0~4146 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=6c71b2c51bc633f230054d9496d6bb2f0c1d4874;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index 60c3e3aaf9..be6d1f132e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2020-05-01 Bruno Haible + + 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 Update users.txt. 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]) diff --git a/modules/bison b/modules/bison new file mode 100644 index 0000000000..126c5ec0c5 --- /dev/null +++ b/modules/bison @@ -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 diff --git a/modules/parse-datetime b/modules/parse-datetime index 5ef3264f05..7571e066f2 100644 --- a/modules/parse-datetime +++ b/modules/parse-datetime @@ -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