]> sourceware.org Git - automake.git/commitdiff
Fix for PR automake/352:
authorAlexandre Duret-Lutz <adl@gnu.org>
Tue, 28 Jan 2003 23:24:25 +0000 (23:24 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Tue, 28 Jan 2003 23:24:25 +0000 (23:24 +0000)
* automake.in (transform_variable_recursively): If the destination
and the source variables are the same, delete the source variable
before defining the destination variable.
(handle_programs): Strip any $(EXEEXT) suffix from $one_file,
or this will confuse handle_source_transform.
(append_exeext): Rewrite using transform_variable_recursively.
* tests/cond29.test, tests/cond30.test: New files.
* tests/exeext.test: Run ./configure and make, this uncovered
the above handle_programs issue.
* tests/Makefile.am (TESTS): Add cond29.test and cond20.test.

ChangeLog
NEWS
automake.in
tests/Makefile.am
tests/Makefile.in
tests/cond29.test [new file with mode: 0755]
tests/cond30.test [new file with mode: 0755]
tests/exeext.test

index 4bcff2e2a86e4c87e1d528e3d9df895406a19741..bfae341ab08cd3352e7871bc0ee1ef85f0263282 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2003-01-28  Alexandre Duret-Lutz  <adl@gnu.org>
 
+       Fix for PR automake/352:
+       * automake.in (transform_variable_recursively): If the destination
+       and the source variables are the same, delete the source variable
+       before defining the destination variable.
+       (handle_programs): Strip any $(EXEEXT) suffix from $one_file,
+       or this will confuse handle_source_transform.
+       (append_exeext): Rewrite using transform_variable_recursively.
+       * tests/cond29.test, tests/cond30.test: New files.
+       * tests/exeext.test: Run ./configure and make, this uncovered
+       the above handle_programs issue.
+       * tests/Makefile.am (TESTS): Add cond29.test and cond20.test.
+
        * automake.in (%subobjvar): Replace by ...
        (%gen_varname): ... this.
        (subobjname): Replace by ...
diff --git a/NEWS b/NEWS
index 19a01caea9dc0c9550e48dc40939caa1c620dde2..2134ac8c4435a857cf05ee368880ea2d1188f6b4 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,18 +1,52 @@
 New in 1.7a:
+* The NEWS file is more verbose.
+
+* Defining programs conditionally using Automake conditionals
+  no longer leads to a combinatorial explosion.  The following
+  construct used to be troublesome when used with dozens
+  of conditions.
+
+    bin_PROGRAMS = a
+    if COND1
+      bin_PROGRAMS += a1
+    endif
+    if COND2
+      bin_PROGRAMS += a2
+    endif
+    if COND3
+      bin_PROGRAMS += a3
+    endif
+    ...
+
+* It is now allowed to define bin_PROGRAMS (or any *_PROGRAMS variable)
+  in several conditions.  As in
+
+    if COND1
+      bin_PROGRAMS = a1
+    endif
+    if COND2
+      bin_PROGRAMS = a2
+    endif
+
+* install-sh now understands --version and --help.
+
 * Cleanup the definitions of $(distdir) and $(top_distdir).
   $(top_distdir) now points to the root of the distribution directory
   created during `make dist', as it did in Automake 1.4, not to the
   root of the build tree as it did in intervening versions.
   Furthermore these two variables are now only defined in the top
   level Makefile, and passed to sub-directories when running `make dist'.
+
 * elisp sources are compiled all at once, instead of one by one.
-  This allows interdependencies and speed up compilation.
+  This allows interdependencies and speeds up compilation.
+
 * AM_PROG_CC_STDC is now empty.  The content of this macro was
   merged in AC_PROG_CC.  If your code uses $am_cv_prog_cc_stdc,
   you should adjust it to use $ac_cv_prog_cc_stdc instead.
   (This renaming should be safe, even if you have to support several,
   versions of Automake, because AC_PROG_CC defines this variable since
   Autoconf 2.54.)
+
 \f
 New in 1.7:
 * Autoconf 2.54 is required.
index 91b9699a9c5f26266f78ad6ed60a216af3326481..e1036f101715a81d36b32c43638ad82aedfae1d1 100755 (executable)
@@ -2756,6 +2756,11 @@ sub transform_variable_recursively ($$$$$&)
        # Define the variable if required.
        unless ($nodefine)
         {
+          # If the new variable is the source variable, we assume
+          # we are trying to override a user variable.  Delete
+          # the old variable first.
+          macro_delete ($varname) if $varname eq $var;
+          # Define for all conditions.
           foreach my $pair (@$allresults)
             {
               my ($cond, @result) = @$pair;
@@ -3217,6 +3222,10 @@ sub handle_programs
       $where->push_context ("while processing program `$one_file'");
       $where->set (INTERNAL->get);
 
+      # Strip any $(EXEEXT) suffix the user might have added, or this
+      # will confuse &handle_source_transform.  We'll add $(EXEEXT) back
+      # later anyway.
+      $one_file =~ s/\$\(EXEEXT\)$//;
       my $linker = &handle_source_transform ($xname, $one_file, $obj, $where);
 
       my $xt = '';
@@ -3267,18 +3276,13 @@ sub handle_programs
       # make sure this directory will exist.
       my $dirstamp = require_build_directory_maybe ($one_file);
 
-      # Don't add $(EXEEXT) if user already did.
-      my $extension = ($one_file !~ /\$\(EXEEXT\)$/
-                      ? "\$(EXEEXT)"
-                      : '');
-
       $output_rules .= &file_contents ('program',
                                       $where,
                                       PROGRAM  => $one_file,
                                       XPROGRAM => $xname,
                                       XLINK    => $xlink,
                                       DIRSTAMP => $dirstamp,
-                                      EXEEXT   => $extension);
+                                      EXEEXT   => '$(EXEEXT)');
 
       if ($seen_libobjs || $seen_global_libobjs)
        {
@@ -8175,46 +8179,15 @@ sub append_exeext ($)
   prog_error "append_exeext ($macro)"
     unless $macro =~ /_PROGRAMS$/;
 
-  # FIXME: we should use traverse_variable_recursively to fix PR/352.
-  my @conds = variable_conditions_recursive ($macro)->conds;
-
-  my @condvals;
-  foreach my $cond (@conds)
-    {
-      my @one_binlist = ();
-      my @condval = variable_value_as_list_recursive ($macro, $cond);
-      foreach my $rcurs (@condval)
-       {
-         # Skip autoconf substs.  Also skip if the user
-         # already applied $(EXEEXT).
-         if ($rcurs =~ /^\@.*\@$/ || $rcurs =~ /\$\(EXEEXT\)$/)
-           {
-             push (@one_binlist, $rcurs);
-           }
-         else
-           {
-             push (@one_binlist, $rcurs . '$(EXEEXT)');
-           }
-       }
-
-      push (@condvals, $cond);
-      push (@condvals, "@one_binlist");
-    }
-
-  # FIXME: Currently it's a bit hard to chose a condition becose the
-  # set of input condition is different from the set of ouput
-  # conditions.  See also PR/352.   So we just pick the first one.
-  my $cond = variable_conditions ($macro)->one_cond;
-  my $where = $var_location{$macro}{$cond};
-
-  macro_delete ($macro);
-  while (@condvals)
-    {
-      my $cond = shift (@condvals);
-      my @val = split (' ', shift (@condvals));
-      define_pretty_variable ($macro, $cond, $where, @val);
-    }
- }
+  transform_variable_recursively
+    ($macro, $macro, 'am__EXEEXT', 0, INTERNAL,
+     sub {
+       my ($subvar, $val, @cond_stack) = @_;
+       # Append $(EXEEXT) unless the user did it already.
+       $val .= '$(EXEEXT)' unless $val =~ /\$\(EXEEXT\)$/;
+       return $val;
+     });
+}
 
 
 # @PREFIX
index e445ecefdaf5825e1d1525043c3a95b377799d30..b3d905d7622e2fdfb081904546a3744fae7071e2 100644 (file)
@@ -98,6 +98,8 @@ cond25.test \
 cond26.test \
 cond27.test \
 cond28.test \
+cond29.test \
+cond30.test \
 condd.test \
 condinc.test \
 condinc2.test \
index 5fa62a16a87f53d7bca42d2062e9424fe55ebcb7..5830a6016f32d770e8f4b9c2c74cc1d787d8f2e7 100644 (file)
@@ -191,6 +191,8 @@ cond25.test \
 cond26.test \
 cond27.test \
 cond28.test \
+cond29.test \
+cond30.test \
 condd.test \
 condinc.test \
 condinc2.test \
@@ -642,9 +644,6 @@ check-TESTS: $(TESTS)
        else :; fi
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 
-top_distdir = ..
-distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
-
 distdir: $(DISTFILES)
        @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
        topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
diff --git a/tests/cond29.test b/tests/cond29.test
new file mode 100755 (executable)
index 0000000..03ba240
--- /dev/null
@@ -0,0 +1,47 @@
+#!/bin/sh
+# Copyright (C) 2003  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 that many conditions do not lead to combinatorial explosion.
+# (This is related to PR/352.)
+#
+# On this test, Automake 1.7.x would compute all 2**22 = 4194304 possible
+# combinations of conditionals, eating all memory, swap, or cpu time it can
+# found.  Although this test wont print `FAIL' if it fails, it will take
+# long enough so it can't go unnoticed.
+
+. ./defs
+
+set -e
+
+echo AC_PROG_CC >>configure.in
+
+echo 'bin_PROGRAMS = a' > Makefile.am
+
+for i in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22; do
+cat >>Makefile.am <<EOF
+if C$i
+bin_PROGRAMS += a$i
+endif C$i
+EOF
+echo "AM_CONDITIONAL([C$i], [:])" >>configure.in
+done
+
+$ACLOCAL
+$AUTOMAKE
diff --git a/tests/cond30.test b/tests/cond30.test
new file mode 100755 (executable)
index 0000000..3b00cd1
--- /dev/null
@@ -0,0 +1,58 @@
+#!/bin/sh
+# Copyright (C) 2003  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.
+
+# For PR/352: make sure we support bin_PROGRAMS being defined conditionally.
+
+. ./defs
+
+set -e
+
+cat >>configure.in <<'EOF'
+AC_PROG_CC
+AM_CONDITIONAL(C1, [test -z "$two"])
+AM_CONDITIONAL(C2, [test -n "$two"])
+AC_OUTPUT
+EOF
+
+cat >>Makefile.am <<'EOF'
+if C1
+bin_PROGRAMS = a
+endif
+if C2
+bin_PROGRAMS = b
+endif
+
+print:
+       @echo 'BEG: $(bin_PROGRAMS) :END'
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+EXEEXT=.foo $MAKE -e print > stdout
+cat stdout
+grep 'BEG: a.foo :END' stdout
+
+./configure two=yes
+EXEEXT=.foo $MAKE -e print > stdout
+cat stdout
+grep 'BEG: b.foo :END' stdout
index f3b3ccd9e50a132fb18c4ae69a974b252cbb5e73..e7a2c3b716fc3b31840905934c3921de1a7b7396 100755 (executable)
 # Test to make sure `.' in an exe name doesn't fool us.
 # Report from Robert Collins.
 # Also make sure we rewrite conditionals variables.
+# Also check for PR/352.
 
 . ./defs || exit 1
 
 cat >> configure.in << 'END'
 AC_PROG_CC
-AM_CONDITIONAL([WANT_MT], [:])
-AM_CONDITIONAL([WANT_RMT], [:])
+AM_CONDITIONAL([WANT_MT], [test -z "$revert"])
+AM_CONDITIONAL([WANT_RMT], [test -z "$revert"])
+AC_OUTPUT
 END
 
 cat > Makefile.am << 'END'
@@ -44,24 +46,42 @@ endif
 if WANT_RMT
   libexec_PROGRAMS = rmt
 endif
+
+print:
+       @echo 1BEG: $(bin_PROGRAMS) :END1
+       @echo 2BEG: $(sbin_PROGRAMS) :END2
+       @echo 3BEG: $(check_PROGRAMS) :END3
+       @echo 4BEG: $(libexec_PROGRAMS) :END4
 END
 
 set -e
 
 $ACLOCAL
+$AUTOCONF
 $AUTOMAKE
 
 grep '^maude$(EXEEXT):' Makefile.in
-grep 'bin_PROGRAMS =.*maude$(EXEEXT)' Makefile.in
-
 grep '^maude\.static$(EXEEXT):' Makefile.in
-grep 'sbin_PROGRAMS =.*maude\.static$(EXEEXT)' Makefile.in
-
 grep '^maude3$(EXEEXT):' Makefile.in
-grep 'check_PROGRAMS =.*maude3$(EXEEXT)' Makefile.in
-
 grep '^mt$(EXEEXT):' Makefile.in
-grep '@WANT_MT_TRUE@bin_PROGRAMS =.* mt$(EXEEXT)' Makefile.in
-
 grep '^rmt$(EXEEXT):' Makefile.in
-grep '@WANT_RMT_TRUE@libexec_PROGRAMS =.*rmt$(EXEEXT)' Makefile.in
+
+./configure
+
+EXEEXT=.foo $MAKE -e print > stdout
+cat stdout
+
+grep '1BEG: maude.foo mt.foo :END1' stdout
+grep '2BEG: maude.static.foo :END2' stdout
+grep '3BEG: maude3.foo :END3' stdout
+grep '4BEG: rmt.foo :END4' stdout
+
+./configure revert=yes
+
+EXEEXT=.foo $MAKE -e print > stdout
+cat stdout
+
+grep '1BEG: maude.foo :END1' stdout
+grep '2BEG: maude.static.foo :END2' stdout
+grep '3BEG: maude3.foo :END3' stdout
+grep '4BEG: :END4' stdout
This page took 0.055474 seconds and 5 git commands to generate.