changeset 19139:6b4dfb1e5afb stable

allow building with old versions of bison again (bug #43023) * libinterp/parse-tree/module.mk: Handle brace style for Bison's api prefix declaration. * acinclude.m4 (OCTAVE_PROG_BISON): Don't rely solely on Bison's exit status. Handle braces for the api.prefix declaration. Improve warning message.
author John W. Eaton <jwe@octave.org>
date Wed, 10 Sep 2014 11:23:37 -0400
parents 14bb81940528
children 203431f40cb2
files libinterp/parse-tree/module.mk m4/acinclude.m4
diffstat 2 files changed, 50 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/parse-tree/module.mk	Wed Sep 10 08:19:43 2014 -0400
+++ b/libinterp/parse-tree/module.mk	Wed Sep 10 11:23:37 2014 -0400
@@ -87,8 +87,22 @@
 
 parse-tree/oct-parse.yy: parse-tree/oct-parse.in.yy
 	case "$(BISON_API_PREFIX_DECL_STYLE)" in \
-	  *api*) api_prefix_decl='%define api.prefix "octave_"'; ;; \
-	  *name*) api_prefix_decl='%name-prefix="octave_"'; ;; \
+	  *api*) \
+	    case "$(BISON_API_PREFIX_DECL_STYLE)" in \
+	     *brace*) \
+	       api_prefix_decl='%define api.prefix {octave_}'; ;; \
+	     *) \
+	       api_prefix_decl='%define api.prefix "octave_"'; ;; \
+             esac; \
+            ;; \
+	  *name*) \
+	    case "$(BISON_API_PREFIX_DECL_STYLE)" in \
+	      *brace*) \
+	        api_prefix_decl='%name-prefix {octave_}'; ;; \
+	      *) \
+	        api_prefix_decl='%name-prefix="octave_"'; ;; \
+            esac; \
+          ;; \
 	esac; \
 	case "$(BISON_PUSH_PULL_DECL_STYLE)" in \
 	  *quote*) quote='"' ;; \
--- a/m4/acinclude.m4	Wed Sep 10 08:19:43 2014 -0400
+++ b/m4/acinclude.m4	Wed Sep 10 11:23:37 2014 -0400
@@ -1765,26 +1765,38 @@
     AC_CACHE_CHECK([syntax of bison api.prefix (or name-prefix) declaration],
                    [octave_cv_bison_api_prefix_decl_style], [
       style="api name"
+      quote="quote brace"
       for s in $style; do
-        if test $s = "api"; then
-          def='%define api.prefix "foo_"'
-        else
-          def='%name-prefix="foo_"'
-        fi
-        cat << EOF > conftest.yy
+        for q in $quote; do
+          if test $s = "api"; then
+            if test $q = "quote"; then
+              def='%define api.prefix "foo_"'
+            else
+              def='%define api.prefix {foo_}'
+            fi
+          else
+            if test $q = "quote"; then
+              def='%name-prefix="foo_"'
+            else
+              def='%name-prefix {foo_}'
+            fi
+          fi
+          cat << EOF > conftest.yy
 $def
 %start input
 %%
 input:;
 %%
 EOF
-        $YACC conftest.yy > /dev/null 2>&1
-        ac_status=$?
-        if test $ac_status -eq 0; then
-          octave_cv_bison_api_prefix_decl_style="$s"
-          break
-        fi
-        if test $ac_status -eq 0; then
+          ## Older versions of bison only warn and exit with success.
+          octave_bison_output=`$YACC 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"
+            break
+          fi
+        done
+        if test -n "$octave_cv_bison_api_prefix_decl_style"; then
           break
         fi
       done
@@ -1795,7 +1807,7 @@
   AC_SUBST(BISON_API_PREFIX_DECL_STYLE, $octave_cv_bison_api_prefix_decl_style)
 
   if test -z "$octave_cv_bison_api_prefix_decl_style"; then
-    YACC=
+    tmp_have_bison=no
     warn_bison_api_prefix_decl_style="
 
 I wasn't able to find a suitable style for declaring the api prefix
@@ -1828,9 +1840,9 @@
 input:;
 %%
 EOF
-          $YACC conftest.yy > /dev/null 2>&1
+          octave_bison_output=`$YACC conftest.yy 2>&1`
           ac_status=$?
-          if test $ac_status -eq 0; then
+          if test $ac_status -eq 0 && test -z "$octave_bison_output"; then
             if test $q = noquote; then
               q=
             fi
@@ -1838,7 +1850,7 @@
             break
           fi
         done
-        if test $ac_status -eq 0; then
+        if test -n "$octave_cv_bison_push_pull_decl_style"; then
           break
         fi
       done
@@ -1849,7 +1861,7 @@
   AC_SUBST(BISON_PUSH_PULL_DECL_STYLE, $octave_cv_bison_push_pull_decl_style)
 
   if test -z "$octave_cv_bison_push_pull_decl_style"; then
-    YACC=
+    tmp_have_bison=no
     warn_bison_push_pull_decl_style="
 
 I wasn't able to find a suitable style for declaring a push-pull
@@ -1862,9 +1874,10 @@
     YACC='$(top_srcdir)/build-aux/missing bison'
     warn_bison="
 
-I didn't find bison, but it's only a problem if you need to
-reconstruct parse.cc, which is the case if you're building from VCS
-sources.
+I didn't find bison, or the version of bison that I found does not
+support all the features that are required, but it's only a problem
+if you need to reconstruct parse.cc, which is the case if you're
+building from VCS sources.
 "
     OCTAVE_CONFIGURE_WARNING([warn_bison])
   fi