]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
deps: fix corner-case "make distclean" bug
authorStefano Lattarini <stefano.lattarini@gmail.com>
Sat, 3 Jan 2015 00:33:45 +0000 (01:33 +0100)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Tue, 6 Jan 2015 10:26:16 +0000 (11:26 +0100)
Assume we have package satisfying the following conditions:
  (1) automatic dependency tracking is enabled;
  (2) the 'subdir-objects' Automake option is enabled;
  (3) the package uses a recursive make setup.

Also assume that:
  (a) a subdir Makefile declares a foo_SOURCES variable containing
      a source file in the parent directory;
  (b) that parent Makefile declare a compiled program itself.

Then BSD and Solaris make used to fail when running "make distclean",
because the 'distclean' target of the subdir Makefile removed the
whole '.deps' directory before the parent Makefile was done with the
included '.Po' makefile fragments in that directory. This issue was
revealed by failures in the 'subobj-vpath-pr13928.sh' test when those
make implementations were used.

We fix the issue by ensuring the 'distclean' target of any Makefile
only removed the '.Po' makefile fragments included by it, rather than
the whole '.deps' directory where such files resides.

This change should be the last step in fixing automake bug#13928
for good.

* bin/automake.in (handle_languages), lib/am/depend.am: Adjust
to implement the new 'distclean' logic.
* t/pr224.sh: Adjust to avoid a spurious failure.
* PLANS/subdir-objects.txt: Update.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
PLANS/subdir-objects.txt
bin/automake.in
lib/am/depend.am
t/pr224.sh

index 3cf610124f5762bd82d49c840aa22ff46a0cebdd..c849e338e73f73457575a2ec63c5b2a6867579b4 100644 (file)
@@ -5,9 +5,6 @@ We want to make the behaviour currently enabled by the 'subdir-objects'
 the default one, and in fact the *only* one, in Automake 2.0.
 See automake bug#13378: <http://debbugs.gnu.org/13378>.
 
-Sadly, **THIS IS IMPOSSIBLE** until automake bug#13928 is resolved:
-http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13928
-
 Details
 -------
 
@@ -53,11 +50,10 @@ We also make sure to avoid the warning when it would be irrelevant, i.e.,
 if all source files sit in "current" directory (thanks to Peter Johansson
 for suggesting this).
 
-For some automake 1.x (*before* 2.0 can be released)
-----------------------------------------------------
+For automake 1.16 (*before* 2.0 can be released)
+------------------------------------------------
 
-Find a proper way to fix the blocking automake bug#13928:
-http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13928
+Submit the pending patch series that fixes http://debbugs.gnu.org/13928
 
 For automake 2.0
 ----------------
index dd828da62a517fef186e8c1de07ac48c108ac6ba..355d7ff30180f1517a8947565e1f595d46027f7a 100644 (file)
@@ -1242,14 +1242,16 @@ sub handle_languages ()
                              INTERNAL);
             define_variable ('am__maybe_remake_depfiles', 'depfiles', INTERNAL);
             define_variable ('am__depfiles_remade', "@dep_files", INTERNAL);
-            # Generate each 'include' directive individually.  Several make
-            # implementations (IRIX 6, Solaris 10, FreeBSD 8) will fail to
-            # properly include several files resulting from a variable
-            # expansion. Just Generating many separate includes seems thus
-            # safest.
             $output_rules .= "\n";
+            my @dist_rms;
             foreach my $depfile (@dep_files)
               {
+                push @dist_rms, "\t-rm -f $depfile";
+                # Generate each 'include' directive individually.  Several
+                # make implementations (IRIX 6, Solaris 10, FreeBSD 8) will
+                # fail to properly include several files resulting from a
+                # variable expansion. Just Generating many separate includes
+                # seems thus safest.
                 $output_rules .= subst ('AMDEP_TRUE') .
                                  subst ('am__include') .
                                  " " .
@@ -1262,11 +1264,9 @@ sub handle_languages ()
 
             require_conf_file ("$am_file.am", FOREIGN, 'depcomp');
 
-            # Compute the set of directories to remove in distclean-depend.
-            my @dep_dirs = uniq (map { dirname ($_) } @dep_files);
-            $output_rules .= file_contents ('depend',
-                                            new Automake::Location,
-                                            DEPDIRS => "@dep_dirs");
+            $output_rules .= file_contents (
+                'depend', new Automake::Location,
+                'DISTRMS' => join ("\n", @dist_rms));
           }
       }
     else
index 3711d5d12c8fdda03902858ef741457288001c84..7fb8bb9beb57081ec30c515cdf2fd85e6449d0c6 100644 (file)
@@ -27,8 +27,9 @@ am--depfiles: $(am__depfiles_remade)
 ## erase them in -am or -recursive rules; that would prevent any other
 ## rules from being recursive (for instance multilib clean rules are
 ## recursive).
+if %?DISTRMS%
 distclean:
-       -rm -rf %DEPDIRS%
-
+       %DISTRMS%
 maintainer-clean:
-       -rm -rf %DEPDIRS%
+       %DISTRMS%
+endif
index 7d907441c1787944e9040663cf27f5e40fbc9ba9..bca1d3037f87c03c4e35452987685e99ab287407 100644 (file)
@@ -56,8 +56,8 @@ cd build
 ../configure
 
 $MAKE
-test -d foo/.deps
+test -f foo/.deps/main.Po
 $MAKE distclean
-test -d foo/.deps && exit 1
+test ! -e foo/.deps/main.Po
 
 :