]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Fix Lex library problem reported to us by Julio Garvia.
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 25 Aug 2006 20:48:02 +0000 (20:48 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 25 Aug 2006 20:48:02 +0000 (20:48 +0000)
* doc/autoconf.texi (Particular Programs): YYTEXT_POINTER is
for the default, which the user can override.
* lib/autoconf/programs.m4 (AC_PROG_LEX): Let _AC_PROG_LEX_YYTEXT_DECL
deal with LEXLIB.
(_AC_PROG_LEX_YYTEXT_DECL): Handle caching correctly; the old code
didn't work if some values were cached but not others.  Test for
broken lex libraries like native ia64-hp-hpux11.22; see
<http://sources.redhat.com/ml/binutils/2003-12/msg00337.html>, and
work around the problem by preferring an empty LEXLIB to -lfl or
-ll.  Let the user set LEXLIB='' to indicate no library needed.

ChangeLog
doc/autoconf.texi
lib/autoconf/programs.m4

index 66739d9094384a1dec5afad22f280bdf8b17fcfd..bff7eb43106bdb1c7f16b87b39662b49ccc657a9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2006-08-25  Paul Eggert  <eggert@cs.ucla.edu>
 
+       Fix Lex library problem reported to us by Julio Garvia.
+       * doc/autoconf.texi (Particular Programs): YYTEXT_POINTER is
+       for the default, which the user can override.
+       * lib/autoconf/programs.m4 (AC_PROG_LEX): Let _AC_PROG_LEX_YYTEXT_DECL
+       deal with LEXLIB.
+       (_AC_PROG_LEX_YYTEXT_DECL): Handle caching correctly; the old code
+       didn't work if some values were cached but not others.  Test for
+       broken lex libraries like native ia64-hp-hpux11.22; see
+       <http://sources.redhat.com/ml/binutils/2003-12/msg00337.html>, and
+       work around the problem by preferring an empty LEXLIB to -lfl or
+       -ll.  Let the user set LEXLIB='' to indicate no library needed.
+
        * NEWS: Recommend M4 1.4.6 instead of 1.4.5.
        * README: Likewise.
        * doc/autoconf.texi (Introduction, Why GNU M4): Likewise.
index 46c3ffd18fe5e8fffaa7220a3d93bdf9d301bd57..5db693228504ec74d92ca8527f29794bdf1b9d42 100644 (file)
@@ -3722,8 +3722,8 @@ and @code{LEXLIB} to @option{-lfl}, if that library is in a standard
 place.  Otherwise set @code{LEX} to @samp{lex} and @code{LEXLIB} to
 @option{-ll}.
 
-Define @code{YYTEXT_POINTER} if @code{yytext} is a @samp{char *} instead
-of a @samp{char []}.  Also set output variable @code{LEX_OUTPUT_ROOT} to
+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.
index 0e66a919cc6d66014230086ea470aaf83700e1f4..60540e4a1eeed3e5f6834f8874d60a9bcee2f07e 100644 (file)
@@ -697,12 +697,6 @@ 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 -z "$LEXLIB"
-then
-  AC_CHECK_LIB(fl, yywrap, LEXLIB="-lfl",
-    [AC_CHECK_LIB(l, yywrap, LEXLIB="-ll")])
-fi
-AC_SUBST(LEXLIB)
 if test "x$LEX" != "x:"; then
   _AC_PROG_LEX_YYTEXT_DECL
 fi])
@@ -710,16 +704,30 @@ fi])
 
 # _AC_PROG_LEX_YYTEXT_DECL
 # ------------------------
-# Check if lex declares yytext as a char * by default, not a char[].
+# Check 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(lex output file root, ac_cv_prog_lex_root,
-[# The minimal lex program is just a single line: %%.  But some broken lexes
-# (Solaris, I think it was) want two %% lines, so accommodate them.
-cat >conftest.l <<_ACEOF
+[cat >conftest.l <<_ACEOF[
 %%
+a { ECHO; }
+b { REJECT; }
+c { yymore (); }
+d { yyless (1); }
+e { yyless (input () != 0); }
+f { unput (yytext[0]); }
+. { BEGIN INITIAL; }
 %%
-_ACEOF
+#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
@@ -727,20 +735,35 @@ elif test -f lexyy.c; then
 else
   AC_MSG_ERROR([cannot find output from $LEX; giving up])
 fi])
-rm -f conftest.l
 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([`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
+# 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
-echo 'extern char *yytext;' >>$LEX_OUTPUT_ROOT.c
 ac_save_LIBS=$LIBS
-LIBS="$LIBS $LEXLIB"
-AC_LINK_IFELSE([`cat $LEX_OUTPUT_ROOT.c`], ac_cv_prog_lex_yytext_pointer=yes)
+LIBS="$LEXLIB $ac_save_LIBS"
+AC_LINK_IFELSE(
+  [#define YYTEXT_POINTER 1
+`cat $LEX_OUTPUT_ROOT.c`],
+  [ac_cv_prog_lex_yytext_pointer=yes])
 LIBS=$ac_save_LIBS
-rm -f "${LEX_OUTPUT_ROOT}.c"
 ])
 dnl
 if test $ac_cv_prog_lex_yytext_pointer = yes; then
@@ -748,6 +771,7 @@ if test $ac_cv_prog_lex_yytext_pointer = yes; then
            [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