summaryrefslogtreecommitdiff
path: root/tests/lex-pr204.test
diff options
context:
space:
mode:
authorStefano Lattarini <stefano.lattarini@gmail.com>2011-05-13 20:51:50 +0200
committerStefano Lattarini <stefano.lattarini@gmail.com>2011-05-14 16:20:51 +0200
commitfea854ed044c3bdb3f7d85fafa35e1d17a9e63fc (patch)
tree0aade3055c5d2cf792a76560a9cc0d0f1ae75148 /tests/lex-pr204.test
parentb67712acad6d2b0be448687c76e69a43b71e27b4 (diff)
downloadautomake-fea854ed044c3bdb3f7d85fafa35e1d17a9e63fc.tar.gz
lex: "make clean" removes .c files from non-distributed .l
Previously, while automake did *not* distribute C source and header files derived from non-distributed Lex sources, it still caused them to be removed only by "make maintainer-clean" only, and not by simply "make clean" or "make distclean". This caused "make distcheck" to fail, unless the developer put those generated .c files in CLEANFILES or in DISTCLEANFILES by hand. This change fixes this issue, by making non-distributed `.c' files generated by non-distributed Lex sources cleaned by "make clean". A similar problem for Yacc support had been fixed with the commit v1.11-263-ged2c8bc. * tests/automake.in (lang_lex_target_hook): Make C source files derived from non-distributed Lex files cleaned by "make clean", not only by "make maintainer-clean". * tests/lex-clean.test: New test. * tests/lex-clean-cxx.test: Likewise. * tests/lex-nodist.test: Likewise. * tests/lex-pr204.test: Likewise. * tests/pr204.test: For consistency, renamed ... * tests/yacc-pr204.test: ... to this, and updated to keep it more in sync with 'lex-pr204.test'. * tests/yacc-nodist.test: Updated to keep it more in sync with 'lex-nodist.test'. * tests/Makefile.am (TESTS): Update. * NEWS: Update.
Diffstat (limited to 'tests/lex-pr204.test')
-rwxr-xr-xtests/lex-pr204.test88
1 files changed, 88 insertions, 0 deletions
diff --git a/tests/lex-pr204.test b/tests/lex-pr204.test
new file mode 100755
index 000000000..095d61143
--- /dev/null
+++ b/tests/lex-pr204.test
@@ -0,0 +1,88 @@
+#! /bin/sh
+# Copyright (C) 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Related to PR 204.
+# C sources derived from nodist_ lex sources should not be distributed.
+# See also related test `lex-nodist.test'.
+# The tests 'yacc-nodist.test' and 'yacc-pr204.test' does similar checks
+# for yacc-generated .c and .h files.
+
+required=lex
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in <<'EOF'
+AM_MAINTAINER_MODE
+AC_PROG_CC
+dnl We use AC_PROG_LEX deliberately.
+dnl Sister 'lex-nodist.test' should use 'AM_PROG_LEX' instead.
+AC_PROG_LEX
+AC_OUTPUT
+EOF
+
+# The LEXER2 intermediate variable is there to make sure Automake
+# matches 'nodist_' against the right variable name...
+cat > Makefile.am << 'EOF'
+EXTRA_PROGRAMS = foo
+LEXER2 = lexer2.l
+nodist_foo_SOURCES = lexer.l $(LEXER2)
+
+distdirtest: distdir
+ test ! -f $(distdir)/lexer.c
+ test ! -f $(distdir)/lexer.l
+ test ! -f $(distdir)/lexer.h
+ test ! -f $(distdir)/lexer2.c
+ test ! -f $(distdir)/lexer2.l
+ test ! -f $(distdir)/lexer2.h
+EOF
+
+cat > lexer.l << 'END'
+%%
+"GOOD" return EOF;
+.
+%%
+int main (void)
+{
+ return yylex ();
+}
+END
+
+cp lexer.l lexer2.l
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE distdirtest
+
+# Make sure lexer.c and lexer2.c are still targets.
+$MAKE lexer.c lexer2.c
+test -f lexer.c
+test -f lexer2.c
+
+# Ensure the rebuild rule works despite AM_MAINTAINER_MODE, because
+# it's a nodist_ lexer.
+$sleep
+touch lexer.l lexer2.l
+$sleep
+$MAKE lexer.c lexer2.c
+stat lexer.c lexer.l lexer2.c lexer2.l || : # For debugging.
+test `ls -t lexer.c lexer.l | sed 1q` = lexer.c
+test `ls -t lexer2.c lexer2.l | sed 1q` = lexer2.c
+
+: