summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorAkim Demaille <akim@lrde.epita.fr>2012-05-04 14:38:53 +0200
committerAkim Demaille <akim@lrde.epita.fr>2012-05-04 14:38:53 +0200
commit72cd9a913f6d282c5e24990505c2c820bda2bf1b (patch)
treed5793581da46d1d140570cdab500f597263ebaa5 /m4
parentc50263271db482261b11f7452283c142a780a09d (diff)
parent95e343fea3fa47b88ec91d63d1b8579d7890719f (diff)
downloadbison-72cd9a913f6d282c5e24990505c2c820bda2bf1b.tar.gz
Merge remote-tracking branch 'origin/maint'
* origin/maint: (22 commits) tests: ignore code coverage/profiling failure messages doc: fix some invalid @ref. build: fix previous commit. install-pdf: fix. NEWS: Update. %printer: support both yyo and yyoutput. doc: mfcalc: demonstrate %printer. tests: style changes. build: require Flex. build: flex.m4: check for Flex. build: flex.m4: quote properly. build: flex.m4. build: autoconf: update. glr: eliminate last bits of unwanted locations. NEWS: 2.6 will drop K&R. TODO: remove dead items. TODO: import from master. gnulib: update. maint: update NEWS. doc: fix index. doc: fix documentation of YYERROR. c++: more YY_NULL Conflicts: TODO bootstrap data/c.m4 data/glr.c data/lalr1.cc doc/bison.texinfo
Diffstat (limited to 'm4')
-rw-r--r--m4/flex.m4113
1 files changed, 113 insertions, 0 deletions
diff --git a/m4/flex.m4 b/m4/flex.m4
new file mode 100644
index 00000000..2073a0dc
--- /dev/null
+++ b/m4/flex.m4
@@ -0,0 +1,113 @@
+# flex.m4 serial 1
+# 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,
+# with or without modifications, as long as this notice is preserved.
+
+# AC_PROG_LEX
+# -----------
+# Look for flex or lex. Set its associated library to LEXLIB.
+# Check if lex declares yytext as a char * by default, not a char[].
+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], [:])
+if test "x$LEX" != "x:"; then
+ _AC_PROG_LEX_YYTEXT_DECL
+fi])
+
+
+# _AC_PROG_LEX_YYTEXT_DECL
+# ------------------------
+# 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; }
+c { yymore (); }
+d { yyless (1); }
+e { /* IRIX 6.5 flex 2.5.4 underquotes its yyless argument. */
+ yyless ((input () != 0)); }
+f { unput (yytext[0]); }
+. { BEGIN INITIAL; }
+%%
+#ifdef YYTEXT_POINTER
+extern char *yytext;
+#endif
+int
+main (void)
+{
+ return ! yylex () + ! yywrap ();
+}
+]_ACEOF
+_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
+elif test -f lexyy.c; then
+ ac_cv_prog_lex_root=lexyy
+else
+ AC_MSG_ERROR([cannot find output from $LEX; giving up])
+fi])
+AC_SUBST([LEX_OUTPUT_ROOT], [$ac_cv_prog_lex_root])dnl
+
+if test -z "${LEXLIB+set}"; then
+ AC_CACHE_CHECK([lex library], [ac_cv_lib_lex], [
+ ac_save_LIBS=$LIBS
+ ac_cv_lib_lex='none needed'
+ for ac_lib in '' -lfl -ll; do
+ LIBS="$ac_lib $ac_save_LIBS"
+ AC_LINK_IFELSE([AC_LANG_DEFINES_PROVIDED[`cat $LEX_OUTPUT_ROOT.c`]],
+ [ac_cv_lib_lex=$ac_lib])
+ test "$ac_cv_lib_lex" != 'none needed' && break
+ done
+ LIBS=$ac_save_LIBS
+ ])
+ test "$ac_cv_lib_lex" != 'none needed' && LEXLIB=$ac_cv_lib_lex
+fi
+AC_SUBST([LEXLIB])
+
+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.
+ac_cv_prog_lex_yytext_pointer=no
+ac_save_LIBS=$LIBS
+LIBS="$LEXLIB $ac_save_LIBS"
+AC_LINK_IFELSE([AC_LANG_DEFINES_PROVIDED
+ [#define YYTEXT_POINTER 1
+`cat $LEX_OUTPUT_ROOT.c`]],
+ [ac_cv_prog_lex_yytext_pointer=yes])
+LIBS=$ac_save_LIBS
+])
+dnl
+if test $ac_cv_prog_lex_yytext_pointer = yes; then
+ AC_DEFINE([YYTEXT_POINTER], [1],
+ [Define to 1 if `lex' declares `yytext' as a `char *' by default,
+ not a `char[]'.])
+fi
+rm -f conftest.l $LEX_OUTPUT_ROOT.c
+])# _AC_PROG_LEX_YYTEXT_DECL