X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/22cd137bc99f9368a5e3087cef701f8d74d8fd71..a0cd287e64e2d53bc5896e0a7c5ad072cb8bf469:/m4/flex.m4 diff --git a/m4/flex.m4 b/m4/flex.m4 index 3327bf9b..984c5143 100644 --- a/m4/flex.m4 +++ b/m4/flex.m4 @@ -1,4 +1,4 @@ -# flex.m4 serial 1 +# flex.m4 serial 2 # Copyright (C) 2012 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -12,7 +12,7 @@ AN_MAKEVAR([LEX], [AC_PROG_LEX]) AN_PROGRAM([lex], [AC_PROG_LEX]) AN_PROGRAM([flex], [AC_PROG_LEX]) AC_DEFUN_ONCE([AC_PROG_LEX], -[AC_CHECK_PROGS(LEX, flex lex, :) +[AC_CHECK_PROGS([LEX], [flex lex], [:]) if test "x$LEX" != "x:"; then _AC_PROG_LEX_YYTEXT_DECL fi]) @@ -20,10 +20,27 @@ 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_lex_is_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_lex_is_flex=yes +else + ac_cv_prog_lex_is_flex=no +fi +]) +AC_SUBST([LEX_IS_FLEX], + [`test "$ac_cv_prog_lex_is_flex" = yes && echo true || echo false`])dnl + +cat >conftest.l <<_ACEOF[ %% a { ECHO; } b { REJECT; } @@ -43,7 +60,7 @@ main (void) return ! yylex () + ! yywrap (); } ]_ACEOF -_AC_DO_VAR(LEX conftest.l) +_AC_DO_VAR([LEX conftest.l]) AC_CACHE_CHECK([lex output file root], [ac_cv_prog_lex_root], [ if test -f lex.yy.c; then ac_cv_prog_lex_root=lex.yy @@ -68,9 +85,10 @@ if test -z "${LEXLIB+set}"; then ]) test "$ac_cv_lib_lex" != 'none needed' && LEXLIB=$ac_cv_lib_lex fi -AC_SUBST(LEXLIB) +AC_SUBST([LEXLIB]) -AC_CACHE_CHECK(whether yytext is a pointer, ac_cv_prog_lex_yytext_pointer, +AC_CACHE_CHECK([whether yytext is a pointer], + [ac_cv_prog_lex_yytext_pointer], [# POSIX says lex can declare yytext either as a pointer or an array; the # default is implementation-dependent. Figure out which it is, since # not all implementations provide the %pointer and %array declarations. @@ -85,7 +103,7 @@ LIBS=$ac_save_LIBS ]) dnl if test $ac_cv_prog_lex_yytext_pointer = yes; then - AC_DEFINE(YYTEXT_POINTER, 1, + AC_DEFINE([YYTEXT_POINTER], [1], [Define to 1 if `lex' declares `yytext' as a `char *' by default, not a `char[]'.]) fi