* automake.in (lang_yacc_target_hook): Use Automake::Rule::define
authorAlexandre Duret-Lutz <adl@gnu.org>
Sun, 29 Feb 2004 19:10:21 +0000 (19:10 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Sun, 29 Feb 2004 19:10:21 +0000 (19:10 +0000)
so that rules for the same headers are not output twice.
* lib/Automake/Variable.pm (value_as_list_recursive): Do not
call `return' inside `map'.
* tests/cond30.test: Make sure `a.c' and `b.c' both appear
in the Makefile.in.
* tests/cond35.test, tests/cond36.test: New files.
* tests/Makefile.am (TESTS): Add cond35.test and cond36.test.
Report from Roman Fietze.

ChangeLog
THANKS
automake.in
lib/Automake/Variable.pm
tests/Makefile.am
tests/Makefile.in
tests/cond30.test
tests/cond35.test [new file with mode: 0755]
tests/cond36.test [new file with mode: 0755]

index a907137..8386e5a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2004-02-29  Alexandre Duret-Lutz  <adl@gnu.org>
 
+       * automake.in (lang_yacc_target_hook): Use Automake::Rule::define
+       so that rules for the same headers are not output twice.
+       * lib/Automake/Variable.pm (value_as_list_recursive): Do not
+       call `return' inside `map'.
+       * tests/cond30.test: Make sure `a.c' and `b.c' both appear
+       in the Makefile.in.
+       * tests/cond35.test, tests/cond36.test: New files.
+       * tests/Makefile.am (TESTS): Add cond35.test and cond36.test.
+       Report from Roman Fietze.
+
        Fix for PR/413:
        * lib/am/distdir.am (distcheck): Create $dc_destdir with `umask
        077 && mkdir' instead of `$(mkdir_p)'.  This prevents possible
diff --git a/THANKS b/THANKS
index cbdf7dd..ebfa490 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -212,6 +212,7 @@ Robert Bihlmeyer    robbe@orcus.priv.at
 Robert Boehne          rboehne@ricardo-us.com
 Robert Collins         robert.collins@itdomain.com.au
 Roberto Bagnara                bagnara@cs.unipr.it
+Roman Fietze           roman.fietze@telemotive.de
 Ronald Landheer                ronald@landheer.com
 Rusty Ballinger                rusty@rlyeh.engr.sgi.com
 Ryan T. Sammartino     ryants@shaw.ca
index f22cffc..af5a86f 100755 (executable)
@@ -5064,13 +5064,20 @@ sub lang_yacc_target_hook
        # Add a dependency for the generated header file, and arrange
        # for that file to be included in the distribution.
        # FIXME: this fails for `nodist_*_SOURCES'.
-       $output_rules .= ("${header}: $output\n"
-                         # Recover from removal of $header
-                         . "\t\@if test ! -f \$@; then \\\n"
-                         . "\t  rm -f $output; \\\n"
-                         . "\t  \$(MAKE) $output; \\\n"
-                         . "\telse :; fi\n");
+       foreach my $cond (Automake::Rule::define (${header}, 'internal',
+                                                 RULE_AUTOMAKE, TRUE,
+                                                 INTERNAL))
+         {
+           my $condstr = $cond->subst_string;
+           $output_rules .= ("$condstr${header}: $output\n"
+                             # Recover from removal of $header
+                             . "$condstr\t\@if test ! -f \$@; then \\\n"
+                             . "$condstr\t  rm -f $output; \\\n"
+                             . "$condstr\t  \$(MAKE) $output; \\\n"
+                             . "$condstr\telse :; fi\n");
+         }
        &push_dist_common ($header);
+
        # If the files are built in the build directory, then we want
        # to remove them with `make clean'.  If they are in srcdir
        # they shouldn't be touched.  However, we can't determine this
index e743011..797d2ca 100644 (file)
@@ -620,7 +620,7 @@ sub value_as_list_recursive ($;%)
      # Collect results.
      sub {
        my ($var, $parent_cond, @allresults) = @_;
-       return map { my ($cond, @vals) = @$_; return @vals } @allresults;
+       return map { my ($cond, @vals) = @$_; @vals } @allresults;
      },
      %options);
 }
index f9c812f..a133347 100644 (file)
@@ -121,6 +121,8 @@ cond31.test \
 cond32.test \
 cond33.test \
 cond34.test \
+cond35.test \
+cond36.test \
 condd.test \
 condinc.test \
 condinc2.test \
index e6f60dd..8b80857 100644 (file)
@@ -236,6 +236,8 @@ cond31.test \
 cond32.test \
 cond33.test \
 cond34.test \
+cond35.test \
+cond36.test \
 condd.test \
 condinc.test \
 condinc2.test \
index c9fb80b..10ff041 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Copyright (C) 2003  Free Software Foundation, Inc.
+# Copyright (C) 2003, 2004  Free Software Foundation, Inc.
 #
 # This file is part of GNU Automake.
 #
@@ -56,3 +56,6 @@ grep 'BEG: a.foo :END' stdout
 EXEEXT=.foo $MAKE -e print > stdout
 cat stdout
 grep 'BEG: b.foo :END' stdout
+
+grep 'a_SOURCES = a.c' Makefile.in
+grep 'b_SOURCES = b.c' Makefile.in
diff --git a/tests/cond35.test b/tests/cond35.test
new file mode 100755 (executable)
index 0000000..3e9bae6
--- /dev/null
@@ -0,0 +1,94 @@
+#!/bin/sh
+# Copyright (C) 2004  Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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.
+#
+# GNU Automake 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 Automake; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# Check rules output for parser defined conditionally.
+# Report from Roman Fietze.
+
+required='flex bison gcc'
+. ./defs
+
+set -e
+
+cat >>configure.in <<'EOF'
+AM_CONDITIONAL([CASE_A], test -z "$case_B")
+AC_PROG_CC
+AM_PROG_LEX
+AC_PROG_YACC
+AC_OUTPUT
+EOF
+
+cat >>Makefile.am <<'EOF'
+AM_YFLAGS               =       -d
+
+BUILT_SOURCES           =       tparse.h
+
+if CASE_A
+bin_PROGRAMS            =       ta
+ta_SOURCES              =       ta.c tparse.h tscan.l tparse.y
+ta_LDADD                =       $(LEXLIB)
+else
+bin_PROGRAMS            =       tb
+tb_SOURCES              =       tb.c tparse.h tscan.l tparse.y
+tb_LDADD                =       $(LEXLIB)
+endif
+
+
+test-ta:
+       test -f ta$(EXEEXT)
+test-tb:
+       test -f tb$(EXEEXT)
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+test `grep tparse.h: Makefile.in | wc -l` = 1
+
+cat > tscan.l << 'END'
+%%
+"END"   return EOF;
+END
+
+cat > tparse.y << 'END'
+%{
+void yyerror (char *s) {}
+%}
+%token EOF
+%%
+foobar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
+END
+
+cat >ta.c <<'END'
+int main()
+{
+  return 0;
+}
+END
+
+cp ta.c tb.c
+
+./configure
+$MAKE
+$MAKE test-ta
+
+./configure case_B=yes
+$MAKE
+$MAKE test-tb
diff --git a/tests/cond36.test b/tests/cond36.test
new file mode 100755 (executable)
index 0000000..e87c460
--- /dev/null
@@ -0,0 +1,64 @@
+#!/bin/sh
+# Copyright (C) 2004  Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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.
+#
+# GNU Automake 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 Automake; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# Check rules output for parser defined conditionally.
+
+required='flex bison gcc'
+. ./defs
+
+set -e
+
+cat >>configure.in <<'EOF'
+AM_CONDITIONAL([CASE_A], test -z "$case_B")
+AC_PROG_CC
+AM_PROG_LEX
+AC_PROG_YACC
+AC_OUTPUT
+EOF
+
+cat >>Makefile.am <<'EOF'
+AM_YFLAGS               =       -d
+
+BUILT_SOURCES           =       tparse.h
+
+if CASE_A
+bin_PROGRAMS            =       ta
+ta_SOURCES              =       ta.c tparse.h tscan.l tparse.y
+ta_LDADD                =       $(LEXLIB)
+else
+bin_PROGRAMS            =       tb
+tb_SOURCES              =       tb.c tparse.h tscan.l tparse.y
+tb_LDADD                =       $(LEXLIB)
+tparse.h: tparce.c
+       echo whatever
+endif
+EOF
+
+$ACLOCAL
+
+# Presently Automake doesn't fully support partially overriden rules
+# and should complain.
+AUTOMAKE_fails --add-missing
+grep 'tparse.h.*already defined' stderr
+
+# Still and all, it should generate two rules.
+test `grep tparse.h: Makefile.in | wc -l` = 2
+grep '@CASE_A_TRUE@tparse.h:' Makefile.in
+grep '@CASE_A_FALSE@tparse.h:' Makefile.in