From 7c03674c1980cb4524caa5488ad883cddac8bdac Mon Sep 17 00:00:00 2001 From: Clement Chauplannaz Date: Sat, 11 May 2013 19:42:23 +0200 Subject: [PATCH] Configure: check for lex/yacc availability in path Autoconf provides macros to check for `Particular programs'. Among those are `lex' and `yacc' families of programs. When the relevant macro is used, autoconf will look for a list of programs in the PATH, perform execution check of the programs found, and set the associated variable to the best possible match (for example, `flex' has precedence over `lex'). The problem comes from the behavior of those two macros when no match is found in the PATH: associated variables are set to a default value and no further check is performed. This can lead to running ./configure successfully and encountering an obfuscated error during compilation for the output of `lex' and `yacc' could not be produced and fed to the compiler. This patch adds checks on the result of autoconf macros, and aborts ./configure execution if needed. Signed-off-by: Clement Chauplannaz Signed-off-by: Yann E. MORIN --- configure.ac | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/configure.ac b/configure.ac index 648850e..814d8c8 100644 --- a/configure.ac +++ b/configure.ac @@ -219,9 +219,22 @@ AS_IF( AS_IF( [test "$need_pkgconfig" = "yes"], [PKG_PROG_PKG_CONFIG()]) +# Look for `lex'. If it cannot be found, autoconf sets $LEX to ':'. AC_PROG_LEX +AS_IF( + [test "$LEX" = ":"], + [AC_MSG_ERROR([can not find a lexer generator (such as lex or flex)])]) AC_SUBST([AM_LFLAGS], ["-L -P zconf"]) +# Look for `yacc'. If it cannot be found, autoconf sets $YACC to 'yacc'. AC_PROG_YACC +AS_IF( + [test "$YACC" = "yacc"], + [AC_CHECK_PROGS( + [YACC_IN_PATH], + [yacc])] + AS_IF( + [test -z "$YACC_IN_PATH"], + [AC_MSG_ERROR([can not find a parser generator (such as yacc or bison)])])) AC_SUBST([AM_YFLAGS], ["-t -l -p zconf"]) #---------------------------------------- -- 2.39.5