The AC_PROG_LEX Autoconf macro does not diagnose a failure to find
the "lex library" expected to provide a `yywrap' function (function
which is required to link most lex-generated programs). On the
contrary, when all the link attempts (i.e., with `-ll' and `-lfl')
fail, configure declares that no lex library is needed, and simply
proceeds with the configuration process -- only for the build to
possibly fail later, at make time.
This behaviour is intended; the Autoconf manual reads:
``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 `yywrap' or, if you don't use
it (e.g., your scanner has no `#include'-like feature), simply
include a `%noyywrap' statement in the scanner's source.''
This AC_PROG_LEX behaviour is causing some spurious failures of
the Automake testsuite in environments which lack a proper library
providing `yywrap' (this happens for example on Fedora-based
systems). The proper workaround is to simply provide a fall-back
implementation of `yywrap' in our lexers.
* tests/cond35.test: Provide a dummy `yywrap' function.
* tests/lex3.test: Likewise.
* tests/silent-lex-generic.test: Likewise.
* tests/silent-lex-gcc.test: Likewise.
* tests/silent-many-generic.test: Likewise.
* tests/silent-many-gcc.test: Likewise.
Reported by Jim Meyering:
<http://lists.gnu.org/archive/html/automake-patches/2011-10/msg00092.html>
Cherry-picked (with some edits) from commits `
v1.11-1085-gb5c3968'
(master) and `
v1.11-871-geb147a1' (testsuite-work).
+2011-12-04 Stefano Lattarini <stefano.lattarini@gmail.com>
+
+ tests: fix spurious failures due to missing 'yywrap()' function
+
+ The AC_PROG_LEX Autoconf macro does not diagnose a failure to find
+ the "lex library" expected to provide a `yywrap' function (function
+ which is required to link most lex-generated programs). On the
+ contrary, when all the link attempts (i.e., with `-ll' and `-lfl')
+ fail, configure declares that no lex library is needed, and simply
+ proceeds with the configuration process -- only for the build to
+ possibly fail later, at make time.
+
+ This behaviour is intended; the Autoconf manual reads:
+ ``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 `yywrap' or, if you don't use
+ it (e.g., your scanner has no `#include'-like feature), simply
+ include a `%noyywrap' statement in the scanner's source.''
+
+ This AC_PROG_LEX behaviour is causing some spurious failures of
+ the Automake testsuite in environments which lack a proper library
+ providing `yywrap' (this happens for example on Fedora-based
+ systems). The proper workaround is to simply provide a fall-back
+ implementation of `yywrap' in our lexers.
+
+ See also partially-overlapping commit `v1.11-871-geb147a1' (from
+ the 'testsuite-work' branch), which was motivated by similar
+ spurious failures experienced when cross-compiling.
+
+ From a report by Jim Meyering:
+ <http://lists.gnu.org/archive/html/automake-patches/2011-10/msg00092.html>
+
+ * tests/cond35.test: Provide a dummy `yywrap' function.
+ * tests/lex3.test: Likewise.
+ * tests/silent-lex-generic.test: Likewise.
+ * tests/silent-lex-gcc.test: Likewise.
+ * tests/silent-many-generic.test: Likewise.
+ * tests/silent-many-gcc.test: Likewise.
+
2011-12-04 Paul Eggert <eggert@cs.ucla.edu>
depcomp: spelling fix
#!/bin/sh
-# Copyright (C) 2004 Free Software Foundation, Inc.
+# Copyright (C) 2004, 2011 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
cat > tscan.l << 'END'
%%
"END" return EOF;
+%%
+/* Avoid possible link errors. */
+int yywrap (void)
+{
+ return 1;
+}
END
cat > tparse.y << 'END'
#! /bin/sh
-# Copyright (C) 1999, 2001, 2002, 2003, 2004, 2010 Free Software
+# Copyright (C) 1999, 2001, 2002, 2003, 2004, 2010, 2011 Free Software
# Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
return 0;
}
+
+/* Avoid possible link errors. */
+int yywrap (void)
+{
+ return 1;
+}
END
set -e
#!/bin/sh
-# Copyright (C) 2010 Free Software Foundation, Inc.
+# Copyright (C) 2010, 2011 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
"END" return EOF;
.
%%
+/* Avoid possible link errors. */
+int yywrap (void) { return 1; }
+int main (void) { return 0; }
EOF
cp foo.l sub/bar.l
#!/bin/sh
-# Copyright (C) 2010 Free Software Foundation, Inc.
+# Copyright (C) 2010, 2011 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
"END" return EOF;
.
%%
+/* Avoid possible link errors. */
+int yywrap (void) { return 1; }
+int main (void) { return 0; }
EOF
cp foo.l sub/bar.l
#!/bin/sh
-# Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+# Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
"END" return EOF;
.
%%
+/* Avoid possible link errors. */
+int yywrap (void)
+{
+ return 1;
+}
EOF
cat > foo6.y <<'EOF'
%{
# Force gcc ("fast") depmode.
# This apparently useless "for" loop is here to simplify the syncing
-# with sister test `silent-many-gcc.test'.
+# with sister test `silent-many-generic.test'.
for config_args in \
am_cv_CC_dependencies_compiler_type=gcc
do
#!/bin/sh
-# Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+# Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
"END" return EOF;
.
%%
+/* Avoid possible link errors. */
+int yywrap (void)
+{
+ return 1;
+}
EOF
cat > foo6.y <<'EOF'
%{