From: Tomek Mrugalski Date: Wed, 4 Nov 2015 13:03:51 +0000 (+0900) Subject: [4088] Bison version is now detected during configure. X-Git-Tag: trac4088fd_base~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ac6a081567d62816da9dfc8404098b6a89cd1ded;p=thirdparty%2Fkea.git [4088] Bison version is now detected during configure. --- diff --git a/configure.ac b/configure.ac index 934b360f21..edaf182092 100755 --- a/configure.ac +++ b/configure.ac @@ -1262,6 +1262,48 @@ AC_SUBST(PERL) AC_PATH_PROGS(AWK, gawk awk) AC_SUBST(AWK) +AC_ARG_ENABLE(generate_parser, [AC_HELP_STRING([--enable-generate-parser], + [indicates that the parsers will be regenerated. This implies that the + bison and flex are required [default=no]])], + enable_generate_parser=$enableval, enable_generate_parser=no) + +# Check if flex is avaible. Flex is not needed for building Kea sources, +# unless you want to regenerate grammar in src/lib/eval +AC_PROG_LEX + +# Check if bison is available. Bison is not needed for building Kea sources, +# unless you want to regenerate grammar in src/lib/eval +AC_PROG_YACC + +if test "x$enable_generate_parser" != xno; then + + if test "x$LEX" == "x"; then + AC_MSG_ERROR("Flex is required for enable-generate-parser, but was not found") + fi + + if test "x$YACC" == "x"; then + AC_MSG_ERROR("Bison it required for enable-generate-parser, but was not found") + fi + +# Ok, let's check if we have at least 3.0.0 version of the bison. The code used +# to generate src/lib/eval parser is roughly based on bison 3.0 examples. + cat > bisontest.y << EOF +%require "3.0.0" +%token X +%% +%start Y; +Y: X; +EOF +# Try to compile. + $YACC bisontest.y -o bisontest.cc + + if test $? -ne 0 ; then + $YACC -V + AC_MSG_ERROR("Error with $YACC. Possibly incorrect version? Required at least 3.0.0.") + fi + rm -f bisontest.y bisontest.cc +fi + AC_ARG_ENABLE(generate_docs, [AC_HELP_STRING([--enable-generate-docs], [regenerate documentation using Docbook [default=no]])], enable_generate_docs=$enableval, enable_generate_docs=no) @@ -1577,6 +1619,10 @@ Log4cplus: Kea config backend: CONFIG_BACKEND: ${CONFIG_BACKEND} + +Flex/bison: + FLEX: ${LEX} + BISON: ${YACC} END # Avoid confusion on DNS/DHCP and only mention MySQL if it @@ -1637,6 +1683,7 @@ Developer: C++ Code Coverage: $USE_LCOV Logger checks: $enable_logger_checks Generate Documentation: $enable_generate_docs + Parser Generation: $enable_generate_parser END diff --git a/src/lib/eval/Makefile.am b/src/lib/eval/Makefile.am index 7d34bbdc8b..5530d0825c 100644 --- a/src/lib/eval/Makefile.am +++ b/src/lib/eval/Makefile.am @@ -68,9 +68,9 @@ parser: lexer.cc location.hh position.hh stack.hh parser.cc parser.h # --- Flex/Bison stuff below -------------------------------------------------- location.hh position.hh stack.hh parser.cc parser.h: parser.yy - bison --defines=parser.h -oparser.cc parser.yy + $(YACC) --defines=parser.h -oparser.cc parser.yy lexer.cc: lexer.ll - flex -olexer.cc lexer.ll + $(LEX) -olexer.cc lexer.ll driver.o: driver.cc diff --git a/src/lib/eval/parser.yy b/src/lib/eval/parser.yy index 87468a48bb..c93f4c714d 100644 --- a/src/lib/eval/parser.yy +++ b/src/lib/eval/parser.yy @@ -1,5 +1,5 @@ %skeleton "lalr1.cc" /* -*- C++ -*- */ -%require "3.0.2" +%require "3.0.0" %defines %define parser_class_name {EvalParser} %define api.token.constructor