From: Akim Demaille Date: Sun, 3 May 2020 06:54:58 +0000 (+0200) Subject: bison: rely on bison's %require to check a version requirement X-Git-Tag: v1.0~4138 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=3db0ae5f4fd5948baa6c133e01892aebc9db844f;p=gnulib.git bison: rely on bison's %require to check a version requirement See https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00021.html. * m4/bison.m4 (gl_PROG_BISON): Let bison itself decide if it it recent enough of not. So far it is the only know Yacc tool that supports '%require'. Other yaccs will actually even choke on seeing the -o option after the input file name. * m4/parse-datetime.m4: Simplify gl_PROG_BISON invocation. --- diff --git a/ChangeLog b/ChangeLog index 0bf6ca0dd8..1ac3d104f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2020-05-03 Akim Demaille + + bison: rely on bison's %require to check a version requirement + See https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00021.html. + * m4/bison.m4 (gl_PROG_BISON): Let bison itself decide if it it recent + enough of not. + So far it is the only know Yacc tool that supports '%require'. + Other yaccs will actually even choke on seeing the -o option after the + input file name. + * m4/parse-datetime.m4: Simplify gl_PROG_BISON invocation. + + 2020-05-02 Bruno Haible list: Add get_first, get_last, set_first, set_last operations. diff --git a/m4/bison.m4 b/m4/bison.m4 index 5802a5ca51..76b62baf80 100644 --- a/m4/bison.m4 +++ b/m4/bison.m4 @@ -1,4 +1,4 @@ -# serial 8 +# serial 9 # Copyright (C) 2002-2006, 2008-2020 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation @@ -25,9 +25,9 @@ # - %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]) +# gl_PROG_BISON([VARIABLE], [MIN_BISON_VERSION]) # Example: -# gl_PROG_BISON([PARSE_DATETIME_BISON], [2.4], [1.* | 2.[0-3] | 2.[0-3].*]) +# gl_PROG_BISON([PARSE_DATETIME_BISON], [2.4]) # 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 @@ -47,18 +47,23 @@ AC_DEFUN([gl_PROG_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 + cat >conftest.y <<_ACEOF +%require "$2" +%% +exp: +_ACEOF + AC_MSG_CHECKING([for bison $2 or newer]) + ac_prog_version=`$$1 --version 2>&1 | sed -n 's/^.*GNU Bison.* \([[0-9]]*\.[[0-9.]]*\).*$/\1/p'` + : ${ac_prog_version:='v. ?.??'} + if $$1 conftest.y -o conftest.c 2>/dev/null; then + ac_prog_version="$ac_prog_version, ok" + ac_verc_fail=false + else + ac_prog_version="$ac_prog_version, bad" + ac_verc_fail=true + fi AC_MSG_RESULT([$ac_prog_version]) + rm -f conftest.y conftest.c fi if test $ac_verc_fail = yes; then [$1]=: diff --git a/m4/parse-datetime.m4 b/m4/parse-datetime.m4 index 0849b82036..3bb487f9be 100644 --- a/m4/parse-datetime.m4 +++ b/m4/parse-datetime.m4 @@ -35,7 +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. - gl_PROG_BISON([PARSE_DATETIME_BISON], [2.4], [1.* | 2.[0-3] | 2.[0-3].*]) + gl_PROG_BISON([PARSE_DATETIME_BISON], [2.4]) dnl Prerequisites of lib/parse-datetime.h. AC_REQUIRE([AM_STDBOOL_H])