]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
tests: fix spurious failures due to missing 'yywrap()' function
authorStefano Lattarini <stefano.lattarini@gmail.com>
Mon, 24 Oct 2011 21:18:34 +0000 (23:18 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Sun, 4 Dec 2011 12:22:00 +0000 (13:22 +0100)
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).

ChangeLog
tests/cond35.test
tests/lex3.test
tests/silent-lex-gcc.test
tests/silent-lex-generic.test
tests/silent-many-gcc.test
tests/silent-many-generic.test

index 1c97ecdef3194646b2f1adc975f7fa7e59953515..b1520229c289af0556b24ecb40f1caba931f0664 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,43 @@
+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
index 0f3b8cf8c2bc2543ceb02a38124aac61b4a454ff..0e75c790e7ac34b56739f8b4030e0498c4a38f2b 100755 (executable)
@@ -1,5 +1,5 @@
 #!/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
@@ -61,6 +61,12 @@ test `grep tparse.h: Makefile.in | wc -l` = 1
 cat > tscan.l << 'END'
 %%
 "END"   return EOF;
+%%
+/* Avoid possible link errors. */
+int yywrap (void)
+{
+  return 1;
+}
 END
 
 cat > tparse.y << 'END'
index c4120cfc6ac6778240fbc3b1b8e6a4d713573457..c0af6b2b375c120b1677a68a20965abc65698aef 100755 (executable)
@@ -1,5 +1,5 @@
 #! /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
@@ -57,6 +57,12 @@ main ()
 
   return 0;
 }
+
+/* Avoid possible link errors. */
+int yywrap (void)
+{
+  return 1;
+}
 END
 
 set -e
index 426dc504cc4fd24e5a1ac943a7b70eebf1081e7e..6545752c94a4a1426c15748e2e9b7739f360709a 100755 (executable)
@@ -1,5 +1,5 @@
 #!/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
@@ -57,6 +57,9 @@ cat > foo.l <<'EOF'
 "END"   return EOF;
 .
 %%
+/* Avoid possible link errors. */
+int yywrap (void) { return 1; }
+int   main (void) { return 0; }
 EOF
 cp foo.l sub/bar.l
 
index 66535e800a4a0aa05a42b4655f915e0e20caae8e..2b2183e072d0aec885204e5b3da4dd8effd81628 100755 (executable)
@@ -1,5 +1,5 @@
 #!/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
@@ -57,6 +57,9 @@ cat > foo.l <<'EOF'
 "END"   return EOF;
 .
 %%
+/* Avoid possible link errors. */
+int yywrap (void) { return 1; }
+int   main (void) { return 0; }
 EOF
 cp foo.l sub/bar.l
 
index d770a467c17ce862e9e3dd58615b5d37f03289f3..910167523bb9b2ad6e291eec2e096758c29c96e5 100755 (executable)
@@ -1,5 +1,5 @@
 #!/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
@@ -160,6 +160,11 @@ cat > foo5.l <<'EOF'
 "END"   return EOF;
 .
 %%
+/* Avoid possible link errors. */
+int yywrap (void)
+{
+  return 1;
+}
 EOF
 cat > foo6.y <<'EOF'
 %{
@@ -184,7 +189,7 @@ $AUTOCONF
 
 # 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
index 223a97c64811a0e2a07f627f8fb7e19a03f8706d..4a234c1e07d10502c9d7004901c8e32902e42afa 100755 (executable)
@@ -1,5 +1,5 @@
 #!/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
@@ -162,6 +162,11 @@ cat > foo5.l <<'EOF'
 "END"   return EOF;
 .
 %%
+/* Avoid possible link errors. */
+int yywrap (void)
+{
+  return 1;
+}
 EOF
 cat > foo6.y <<'EOF'
 %{