diff options
author | Stefano Lattarini <stefano.lattarini@gmail.com> | 2015-01-03 01:33:45 +0100 |
---|---|---|
committer | Stefano Lattarini <stefano.lattarini@gmail.com> | 2015-01-04 18:13:47 +0100 |
commit | 78b8b79e53d18dcca504735679647e4edeec1aa3 (patch) | |
tree | c999305f38c301ea7a6eb80a9a803f5d2dad9ca5 | |
parent | 18136a910464996a3bdd6569b48ece1a82c7a71b (diff) | |
download | automake-experimental/deps-pr13928-take-2.tar.gz |
deps: fix corner-case "make distclean" bugexperimental/deps-pr13928-take-2
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 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.
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: XXX
* lib/am/depend.am: XXX
* t/pr224.sh: Adjust to avoid a spurious failure.
Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
-rw-r--r-- | bin/automake.in | 20 | ||||
-rw-r--r-- | lib/am/depend.am | 7 | ||||
-rw-r--r-- | t/pr224.sh | 4 |
3 files changed, 16 insertions, 15 deletions
diff --git a/bin/automake.in b/bin/automake.in index d8ecca514..21cccbe9e 100644 --- a/bin/automake.in +++ b/bin/automake.in @@ -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 diff --git a/lib/am/depend.am b/lib/am/depend.am index 0b226b6ba..3813996ec 100644 --- a/lib/am/depend.am +++ b/lib/am/depend.am @@ -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 diff --git a/t/pr224.sh b/t/pr224.sh index fcea14865..1961786b1 100644 --- a/t/pr224.sh +++ b/t/pr224.sh @@ -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 : |