@caindex prog_LEX
If @code{flex} is found, set output variable @code{LEX} to @samp{flex}.
Otherwise set @code{LEX} to @samp{lex}, if found.
-If neither variant is available, set @code{LEX}
-to @samp{:}; for packages that ship the generated @file{file.yy.c}
+If neither variant is available, set @code{LEX} to @samp{:};
+for packages that ship the generated @file{file.yy.c}
alongside the source @file{file.l}, this default allows users without a
lexer generator to still build the package even if the timestamp for
@file{file.l} is inadvertently changed.
-If generated lexers need a library to work, set output variable
-@code{LEXLIB} to an option for that library (e.g., @option{-ll});
-otherwise define @code{LEXLIB} to empty. A library that merely defines
-@code{main} and @code{yywrap} placeholder functions is not considered
-to be needed.
-
-Define @code{YYTEXT_POINTER} if @code{yytext} defaults to @samp{char *} instead
-of to @samp{char []}. Also set output variable @code{LEX_OUTPUT_ROOT} to
-the base of the file name that the lexer generates; usually
-@file{lex.yy}, but sometimes something else. These results vary
-according to whether @code{lex} or @code{flex} is being used.
-
-You are encouraged to use Flex in your sources, since it is both more
-pleasant to use than plain Lex and the C source it produces is portable.
-In order to ensure portability, however, you must either provide a
-function @code{yywrap} or, if you don't use it (e.g., your scanner has
-no @samp{#include}-like feature), simply include a @samp{%noyywrap}
-statement in the scanner's source. Once this done, the scanner is
-portable (unless @emph{you} felt free to use nonportable constructs) and
-does not depend on any library. In this case, and in this case only, it
-is suggested that you use this Autoconf snippet:
+The result of this test can be influenced by setting the variable
+@code{LEX} or the cache variable @code{ac_cv_prog_LEX}.
+
+If either @code{flex} or @code{lex} is found, this macro performs
+additional checks for common portability pitfalls. If these additional
+checks fail, @code{LEX} is also set to @samp{:}.
+
+Output variable @code{LEX_OUTPUT_ROOT} is set to the base of the file
+name that the lexer generates; this is usually either @file{lex.yy} or
+@file{lexyy}. Preprocessor macro @code{YYTEXT_POINTER} is defined if
+the lexer skeleton, by default, declares @code{yytext} as a @samp{char
+*} rather than a @samp{char []}. Finally, if generated lexers need a
+library to work, set output variable @code{LEXLIB} to an option for that
+library (e.g., @option{-ll}); otherwise define @code{LEXLIB} to empty.
+A library that merely defines @code{main} and @code{yywrap} placeholder
+functions is not considered to be needed.
+
+@strong{Caution:} As a side-effect of the test, this macro may delete
+any file in the configure script's current working directory named
+@file{lex.yy.c} or @file{lexyy.c}.
+
+@strong{Caution:} Packages that ship a generated @file{lex.yy.c}
+cannot assume that the definition of @code{YYTEXT_POINTER} matches
+the code in that file. They also cannot assume that @code{LEXLIB}
+provides the library routines required by the code in that file.
+
+If you use Flex to generate @file{lex.yy.c}, you can work around these
+limitations by defining @code{yywrap} and @code{main} yourself
+(rendering @code{-lfl} unnecessary), and by using either the
+@option{--array} or @option{--pointer} options to control how
+@code{yytext} is declared. The code generated by Flex is also more
+portable than the code generated by historical versions of Lex.
+
+If you have used Flex to generate @file{lex.yy.c}, and especially if
+your scanner depends on Flex features, we recommend you use this
+Autoconf snippet to prevent the scanner being regenerated with
+historical Lex:
@example
AC_PROG_LEX
@env{LEX}, so if Flex is required, it is better to check that the user
provided something sufficient by parsing the output of @samp{$LEX
--version} than by simply relying on @code{test "x$LEX" = xflex}.
-
-To ensure backward compatibility, Automake's @code{AM_PROG_LEX} invokes
-(indirectly) this macro twice, which causes an annoying but benign
-``@code{AC_PROG_LEX} invoked multiple times'' warning. Future versions
-of Automake will fix this issue; meanwhile, just ignore this message.
-
-As part of running the test, this macro may delete any file in the
-configuration directory named @file{lex.yy.c} or @file{lexyy.c}.
-
-The result of this test can be influenced by setting the variable
-@code{LEX} or the cache variable @code{ac_cv_prog_LEX}.
@end defmac
@anchor{AC_PROG_LN_S}