From: David Lamparter Date: Thu, 15 Dec 2016 23:37:52 +0000 (+0100) Subject: build: fix bison < 3.0 compatibility X-Git-Tag: frr-3.0-branchpoint~113^2~5 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=0d37f9f325217a6dc3e396c9227d2a164775f4d9;p=mirror%2Ffrr.git build: fix bison < 3.0 compatibility bison-2.7.x really wants "foo" for api.prefix while bison-3.0.x really wants {foo} ... great. Signed-off-by: David Lamparter --- diff --git a/configure.ac b/configure.ac index 128300cc6c..c46575d83f 100755 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/lib/Makefile.am b/lib/Makefile.am index 2906b9513a..1bb2d395c8 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -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 diff --git a/lib/command_parse.y b/lib/command_parse.y index 3dba8f0e89..d2dd5aa5cc 100644 --- a/lib/command_parse.y +++ b/lib/command_parse.y @@ -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"