From 0d49053a75ada3da6de8934fd9f4d08b8deb246a Mon Sep 17 00:00:00 2001
From: Akim Demaille <akim@lrde.epita.fr>
Date: Tue, 10 Apr 2012 21:36:19 +0200
Subject: [PATCH 3/4] build: flex.m4: check for Flex.

* m4/flex.m4 (_AC_PROG_LEX_YYTEXT_DECL): Check that $LEX
supports some of the Flex options, and exclusive start conditions.
Define FLEX to 'yes'/'', as AC_PROG_CC does for GCC.
---
 m4/flex.m4 |   23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/m4/flex.m4 b/m4/flex.m4
index 7e1b914..2073a0d 100644
--- a/m4/flex.m4
+++ b/m4/flex.m4
@@ -20,10 +20,29 @@ fi])
 
 # _AC_PROG_LEX_YYTEXT_DECL
 # ------------------------
-# Check for the Lex output root, the Lex library, and whether Lex
-# declares yytext as a char * by default.
+# Check whether this is Flex, for the Lex output root, the Lex library,
+# and whether Lex declares yytext as a char * by default.
 m4_define([_AC_PROG_LEX_YYTEXT_DECL],
+[AC_CACHE_CHECK([whether lex is flex],
+                [ac_cv_prog_flex],
 [cat >conftest.l <<_ACEOF[
+%option debug nodefault noinput nounput noyywrap never-interactive
+%x SC_CONF_TEST
+%%
+a { BEGIN SC_CONF_TEST; }
+]_ACEOF
+if _AC_DO_VAR([LEX conftest.l]); then
+  ac_cv_prog_flex=yes
+else
+  ac_cv_prog_flex=no
+fi
+])
+FLEX=
+if test $ac_cv_prog_flex = yes; then
+  AC_SUBST([FLEX], [yes])dnl
+fi
+
+cat >conftest.l <<_ACEOF[
 %%
 a { ECHO; }
 b { REJECT; }
-- 
1.7.9.5

