]> git.puffer.fish Git - mirror/frr.git/commitdiff
build: fix bison < 3.0 compatibility
authorDavid Lamparter <equinox@opensourcerouting.org>
Thu, 15 Dec 2016 23:37:52 +0000 (00:37 +0100)
committerDavid Lamparter <equinox@opensourcerouting.org>
Fri, 16 Dec 2016 19:42:01 +0000 (20:42 +0100)
bison-2.7.x really wants "foo" for api.prefix while bison-3.0.x really
wants {foo} ... great.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
configure.ac
lib/Makefile.am
lib/command_parse.y

index 128300cc6cf1a7b06ae7ee87486ac9b7ce11a201..c46575d83f0bf7a9501bbd8278654294162d9fea 100755 (executable)
@@ -1419,7 +1419,46 @@ if test "x$LEX" != xflex; then
     AC_SUBST([LEX_OUTPUT_ROOT], [lex.yy])
     AC_SUBST([LEXLIB], [''])
 fi
+
 AC_PROG_YACC
+dnl thanks GNU bison for this b*llshit...
+AC_MSG_CHECKING(version of bison)
+quagga_ac_bison_version="$(eval $YACC -V | grep bison | head -n 1)"
+quagga_ac_bison_version="${quagga_ac_bison_version##* }"
+quagga_ac_bison_missing="false"
+case "x${quagga_ac_bison_version}" in
+  x2.7*)
+    BISON_OPENBRACE='"'
+    BISON_CLOSEBRACE='"'
+    AC_MSG_RESULT([$quagga_ac_bison_version - 2.7 or older])
+    ;;
+  x2.*|x1.*)
+    AC_MSG_RESULT([$quagga_ac_bison_version])
+    AC_MSG_WARN([installed bison is too old.  Please install GNU bison 2.7.x or newer.])
+    quagga_ac_bison_missing="true"
+    ;;
+  x)
+    AC_MSG_RESULT([none])
+    AC_MSG_WARN([could not determine bison version.  Please install GNU bison 2.7.x or newer.])
+    quagga_ac_bison_missing="true"
+    ;;
+  *)
+    BISON_OPENBRACE='{'
+    BISON_CLOSEBRACE='}'
+    AC_MSG_RESULT([$quagga_ac_bison_version - 3.0 or newer])
+    ;;
+esac
+AC_SUBST(BISON_OPENBRACE)
+AC_SUBST(BISON_CLOSEBRACE)
+
+if $quagga_ac_bison_missing; then
+  YACC="$SHELL $missing_dir/missing bison -y"
+  if test -f "${srcdir}/lib/command_parse.c" -a -f "${srcdir}/lib/command_parse.h"; then
+    AC_MSG_WARN([using pregenerated bison output files])
+  else
+    AC_MSG_ERROR([bison failure and pregenerated files not included (probably a git build)])
+  fi
+fi
 
 dnl -------------------
 dnl capabilities checks
index 2906b9513a5cc97f6c93c8b51162ea3394b46c13..1bb2d395c8702a8786be0db885ff87d0a40e7d30 100644 (file)
@@ -3,7 +3,7 @@
 AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib
 AM_CFLAGS = $(WERROR)
 DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
-AM_YFLAGS = -d
+AM_YFLAGS = -d -Dapi.prefix=@BISON_OPENBRACE@cmd_yy@BISON_CLOSEBRACE@
 
 command_lex.h: command_lex.c
        @if test ! -f $@; then rm -f command_lex.c; else :; fi
index 3dba8f0e89a587c90c277735c0c9374cc39f361f..d2dd5aa5cc3a57717347fabf196a02fd6ed19661 100644 (file)
@@ -33,7 +33,7 @@ typedef union CMD_YYSTYPE CMD_YYSTYPE;
 %}
 
 %define api.pure full
-%define api.prefix {cmd_yy}
+/* define api.prefix {cmd_yy} */
 
 /* names for generated header and parser files */
 %defines "command_parse.h"