changeset 30170:72adc88bc674

modernize bison rules * bootstrap.conf (gnulib_modules): Include bison in the list. * m4/acinclude.m4 (OCTAVE_PROG_BISON): Use gl_PROG_BISON to define BISON instead of AC_PROG_YACC to define YACC. Don't substitute WARN_YFLAGS. * libinterp/module.mk (%.cc %.h : %.yy): Assume we have bison, that it supports --defines=FILE and --output=FILE, and that we don't have to use ylwrap or work around weird y.tab.c and y.tab.h generated file names. * Makefile.am (AM_YFLAGS): Delete. (YACC): Define so that automake doesn't complain about seeing .yy source files without a definition of YACC in the Makefile. (AM_V_BISON, am__v_BISON_, am__v_BISON_0, am__v_BISON_1): New macros.
author John W. Eaton <jwe@octave.org>
date Tue, 14 Sep 2021 10:34:59 -0400
parents cefa5d2d30bc
children 7bac3fb3d6b6
files Makefile.am bootstrap.conf libinterp/module.mk m4/acinclude.m4
diffstat 4 files changed, 25 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.am	Tue Sep 14 17:54:04 2021 +0900
+++ b/Makefile.am	Tue Sep 14 10:34:59 2021 -0400
@@ -42,7 +42,19 @@
 
 AM_LFLAGS = @LFLAGS@
 
-AM_YFLAGS = -dv ${WARN_YFLAGS}
+# Until modern Bison rules are handled by autoconf/automake.
+
+AM_V_BISON = $(am__v_BISON_$(V))
+am__v_BISON_ = $(am__v_BISON_$(AM_DEFAULT_VERBOSITY))
+am__v_BISON_0 = @echo "  BISON   " $@;
+am__v_BISON_1 =
+
+BISON = @BISON@
+BISONCOMPILE = $(BISON) $(AM_BISONFLAGS) $(BISONFLAGS)
+
+# Define YACC to pacify automake
+
+YACC = $(BISON)
 
 if AMCOND_LIB_VISIBILITY_FLAGS
   OCTAVE_VISIBILITY_FLAGS = ${CFLAG_VISIBILITY}
--- a/bootstrap.conf	Tue Sep 14 17:54:04 2021 +0900
+++ b/bootstrap.conf	Tue Sep 14 10:34:59 2021 -0400
@@ -29,6 +29,7 @@
 gnulib_modules="
   areadlink
   base64
+  bison
   canonicalize
   chdir
   clock-time
--- a/libinterp/module.mk	Tue Sep 14 17:54:04 2021 +0900
+++ b/libinterp/module.mk	Tue Sep 14 10:34:59 2021 -0400
@@ -194,15 +194,8 @@
 ## Cancel the suffix rule and use a pattern rule instead.
 .yy.cc:
 
-## The ylwrap script always updates the parser source file so we use a temporary file
-## name and our own move-if-change rule for that file.  Additionally fix up the file
-## name comments that bison writes into the source file.
 %.cc %.h : %.yy
-	$(AM_V_YACC)$(am__skipyacc) rm -f $*.cc-t $*.cc-tt && \
-	$(SHELL) $(YLWRAP) $< y.tab.c $*.cc-t y.tab.h $*.h y.output $*.output -- $(YACCCOMPILE) && \
-	$(SED) 's|"$*\.cc-t"|"$*.cc"|g' $*.cc-t > $*.cc-tt && \
-	mv $*.cc-tt $*.cc-t && \
-	$(call move_if_change_rule,$*.cc-t,$*.cc)
+	$(AM_V_BISON)$(am__skipbison) $(BISONCOMPILE) --defines="$*.h" --output="$*.cc" $<
 
 ## Special rules:
 ## Mostly for sources which must be built before rest of compilation.
--- a/m4/acinclude.m4	Tue Sep 14 17:54:04 2021 +0900
+++ b/m4/acinclude.m4	Tue Sep 14 10:34:59 2021 -0400
@@ -2959,21 +2959,17 @@
 dnl Check for bison.
 dnl
 AC_DEFUN([OCTAVE_PROG_BISON], [
-  AC_PROG_YACC
-  WARN_YFLAGS=
+  dnl FIXME: What is our actual required minimum version for Bison?
+  gl_PROG_BISON([BISON], [3.0])
+  WARN_BISONFLAGS=
 
-  case "`$YACC --version`" in
+  case "`$BISON --version`" in
     *bison*) tmp_have_bison=yes ;;
     *) tmp_have_bison=no ;;
   esac
 
   if test $tmp_have_bison = yes; then
-    dnl FIXME: Call GNU bison with the `-Wno-yacc` option, which works with
-    dnl bison 2.5 and all later versions, as recommended by the bison NEWS.
-    dnl This is needed as long as Octave supports Autoconf version 2.69 or
-    dnl older.  In Autoconf 2.70, AC_PROG_YACC no longer adds the `-y`
-    dnl option to emulate POSIX yacc.
-    WARN_YFLAGS="-Wno-yacc"
+    WARN_BISONFLAGS="-Wno-yacc"
 
     AC_CACHE_CHECK([syntax of bison api.prefix (or name-prefix) declaration],
                    [octave_cv_bison_api_prefix_decl_style], [
@@ -3002,7 +2998,7 @@
 %%
 EOF
           ## Older versions of bison only warn and exit with success.
-          octave_bison_output=`$YACC $WARN_YFLAGS conftest.yy 2>&1`
+          octave_bison_output=`$BISON $WARN_BISONFLAGS conftest.yy 2>&1`
           ac_status=$?
           if test $ac_status -eq 0 && test -z "$octave_bison_output"; then
             octave_cv_bison_api_prefix_decl_style="$s $q"
@@ -3040,13 +3036,13 @@
 %%
 EOF
       ## Older versions of bison only warn and exit with success.
-      $YACC $WARN_YFLAGS conftest.yy
-      if grep PREFIX_symbol_kind_t y.tab.c > /dev/null; then
+      $BISON $WARN_BISONFLAGS --defines --output conftest.cc conftest.yy
+      if grep PREFIX_symbol_kind_t conftest.cc > /dev/null; then
         octave_cv_bison_api_prefix_applies_to_yysymbol_kind_t=yes
       else
         octave_cv_bison_api_prefix_applies_to_yysymbol_kind_t=no
       fi
-      rm -f conftest.yy y.tab.h y.tab.c
+      rm -f conftest.yy y.tab.h conftest.cc
       ])
   fi
 
@@ -3063,7 +3059,7 @@
   fi
 
   if test $tmp_have_bison = no; then
-    YACC='${top_srcdir}/build-aux/missing bison'
+    BISON='${top_srcdir}/build-aux/missing bison'
     warn_bison="
 
 I didn't find bison, or the version of bison that I found does not
@@ -3080,7 +3076,6 @@
   fi
   AC_SUBST(OCTAVE_PARSER_CPPFLAGS)
   AC_SUBST(OCTAVE_TEX_PARSER_CPPFLAGS)
-  AC_SUBST(WARN_YFLAGS)
 ])
 dnl
 dnl Find find program.