]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
tests: fix spurious failures due to missing 'yywrap()' function
authorStefano Lattarini <stefano.lattarini@gmail.com>
Sun, 12 Feb 2012 15:37:44 +0000 (16:37 +0100)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Sun, 12 Feb 2012 15:37:44 +0000 (16:37 +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.

See also similar commits 'v1.11-546-gca0ba5d' (24-10-2011),
'v1.11-1085-gb5c3968' (24-10-2011) and 'v1.11-871-geb147a1'
(25-05-2011).

* tests/lex-clean.test: Provide a dummy 'yywrap' function.
* tests/lex-line.test: Likewise.
* tests/lex-nodist.test: Likewise.
* tests/lex-depend.test: Likewise.
* tests/lex-clean-cxx.test: Move the dummy 'yywrap' function
from the main '.cc' file into the '.lxx' file, so that it won't
be subject to the namespace declaration in the '.cc' file (which
was causing a spurious link error in systems without a default
"lex library").

tests/lex-clean-cxx.test
tests/lex-clean.test
tests/lex-depend.test
tests/lex-line.test
tests/lex-nodist.test

index ba7e367083b2a5a65fa1858ff39af301bec10b13..6ca8071384c873e57de9ca67e15309bdeb5a5da2 100755 (executable)
@@ -58,16 +58,17 @@ cat > parsefoo.lxx << 'END'
 %%
 "GOOD"   return EOF;
 .
+%%
+int yywrap (void)
+{
+  return 1;
+}
 END
 cp parsefoo.lxx parsebar.ll
 
 cat > mainfoo.cc << 'END'
 // This file should contain valid C++ but invalid C.
 using namespace std;
-int yywrap (void)
-{
-  return 1;
-}
 int main (int argc, char **argv)
 {
   extern int yylex (void);
index 5bcb5c177cc678fd6ff45cb1a26d18de5dd2eb35..6f038871e02eeace5bea91395b4895c1bfdcf3e7 100755 (executable)
@@ -64,6 +64,12 @@ int main (void)
 {
   return yylex ();
 }
+
+/* Avoid possible link errors. */
+int yywrap (void)
+{
+  return 1;
+}
 END
 
 $ACLOCAL
index 13d5554dff4fcb5763aa73191d077e9982c8f415..2ef27dadfd90953ca857bdc9ab567dfa927cae80 100755 (executable)
@@ -55,6 +55,11 @@ int main (void)
   printf("%s\n", MESSAGE);
   return 0;
 }
+/* Avoid possible link errors. */
+int yywrap (void)
+{
+  return 1;
+}
 END
 
 cat > my-hdr.h <<'END'
index 27958c895086200b1884a59b5f65fa9a33444576..a7e1640740de9b84a0ae4566108bf704b8a97bbd 100755 (executable)
@@ -70,6 +70,12 @@ int main ()
     ;
   return 0;
 }
+
+/* Avoid possible link errors. */
+int yywrap (void)
+{
+  return 1;
+}
 END
 
 cp zardoz.l dir/quux.l
index 5948400ea33a9861d5cb3312832254e9e62a6fd8..092e089605881cf185b8b69bd300e9b6ec861362 100755 (executable)
@@ -65,6 +65,12 @@ int main ()
 {
   return yylex ();
 }
+
+/* Avoid possible link errors. */
+int yywrap (void)
+{
+  return 1;
+}
 END
 
 $ACLOCAL