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 <chauplac@gmail.com>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
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"])
#----------------------------------------