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 <equinox@opensourcerouting.org>
This commit is contained in:
David Lamparter 2016-12-16 00:37:52 +01:00
parent eed831e065
commit 0d37f9f325
3 changed files with 41 additions and 2 deletions

View File

@ -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

View 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

View 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"