autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: LEXLIB bug while running configure


From: Paul Eggert
Subject: Re: LEXLIB bug while running configure
Date: Fri, 25 Aug 2006 13:51:23 -0700
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Julio GarvĂ­a <address@hidden> writes:

> A workaround is setting LEXLIB to " ". Is there any other solution
> to this issue?

You could use 'flex' rather than HP-UX.  'flex' is better anyway: it's
faster and more reliable.

Thanks for reporting the bug; it uncovered some others.  I installed
this fix to Autoconf so that the workaround shouldn't be needed in the
future.

2006-08-25  Paul Eggert  <address@hidden>

        * 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.
        Lex library problem reported to us by Julio Garvia.

--- doc/autoconf.texi   25 Aug 2006 17:23:12 -0000      1.1073
+++ doc/autoconf.texi   25 Aug 2006 20:47:07 -0000
@@ -3722,8 +3722,8 @@ and @code{LEXLIB} to @option{-lfl}, if t
 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.
--- lib/autoconf/programs.m4    13 Jun 2006 17:02:59 -0000      1.61
+++ lib/autoconf/programs.m4    25 Aug 2006 20:47:07 -0000
@@ -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 =
            [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
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]