From: Alexandre Duret-Lutz Date: Sun, 15 May 2005 06:56:22 +0000 (+0000) Subject: Fix PR automake/461: X-Git-Tag: Release-1-9b~154 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dc90eb4e61f5b1b8892105f6891ced2302b99139;p=thirdparty%2Fautomake.git Fix PR automake/461: * automake.in (require_build_directory): Canonize directories with different name, such as `foo/bar' and `./foo//bar'. * tests/subobj9.test: Augment to test that. Report from Tom Tromey. --- diff --git a/ChangeLog b/ChangeLog index 277473833..f532bcf4d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2005-05-15 Alexandre Duret-Lutz + + Fix PR automake/461: + * automake.in (require_build_directory): Canonize directories with + different name, such as `foo/bar' and `./foo//bar'. + * tests/subobj9.test: Augment to test that. + Report from Tom Tromey. + 2005-05-14 Alexandre Duret-Lutz * COPYING, ChangeLog, ChangeLog.00, ChangeLog.01, ChangeLog.02, diff --git a/automake.in b/automake.in index eaf5c6609..514bc13bb 100755 --- a/automake.in +++ b/automake.in @@ -147,6 +147,7 @@ use Automake::Rule; use Automake::RuleDef; use Automake::Wrap 'makefile_wrap'; use File::Basename; +use File::Spec; use Carp; ## ----------- ## @@ -523,7 +524,9 @@ my %object_compilation_map; # This keeps track of the directories for which we've already -# created dirstamp code. +# created dirstamp code. Keys are directories, values are stamp files. +# Several keys can share the same stamp files if they are equivalent +# (as are `.//foo' and `foo'). my %directory_map; # All .P files. @@ -7265,27 +7268,38 @@ sub require_conf_file_with_macro ($$$@) # Emit rules to create $DIRECTORY if needed, and return # the file that any target requiring this directory should be made # dependent upon. +# We don't want to emit the rule twice, and want to reuse it +# for directories with equivalent names (e.g., `foo/bar' and `./foo//bar'). sub require_build_directory ($) { my $directory = shift; - my $dirstamp = "$directory/\$(am__dirstamp)"; - # Don't emit the rule twice. - if (! defined $directory_map{$directory}) + return $directory_map{$directory} if exists $directory_map{$directory}; + + my $cdir = File::Spec->canonpath ($directory); + + if (exists $directory_map{$cdir}) { - $directory_map{$directory} = 1; + my $stamp = $directory_map{$cdir}; + $directory_map{$directory} = $stamp; + return $stamp; + } - # Set a variable for the dirstamp basename. - define_pretty_variable ('am__dirstamp', TRUE, INTERNAL, - '$(am__leading_dot)dirstamp'); + my $dirstamp = "$cdir/\$(am__dirstamp)"; - # Directory must be removed by `make distclean'. - $clean_files{$dirstamp} = DIST_CLEAN; + $directory_map{$directory} = $dirstamp; + $directory_map{$cdir} = $dirstamp; - $output_rules .= ("$dirstamp:\n" - . "\t\@\$(mkdir_p) $directory\n" - . "\t\@: > $dirstamp\n"); - } + # Set a variable for the dirstamp basename. + define_pretty_variable ('am__dirstamp', TRUE, INTERNAL, + '$(am__leading_dot)dirstamp'); + + # Directory must be removed by `make distclean'. + $clean_files{$dirstamp} = DIST_CLEAN; + + $output_rules .= ("$dirstamp:\n" + . "\t\@\$(mkdir_p) $directory\n" + . "\t\@: > $dirstamp\n"); return $dirstamp; } diff --git a/tests/subobj9.test b/tests/subobj9.test index ecf26661e..d1e993217 100755 --- a/tests/subobj9.test +++ b/tests/subobj9.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2002, 2004 Free Software Foundation, Inc. +# Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. # # This file is part of GNU Automake. # @@ -36,7 +36,7 @@ END cat > Makefile.am << 'END' noinst_LTLIBRARIES = libfoo.la -libfoo_la_SOURCES = src/foo.cc +libfoo_la_SOURCES = src/foo.cc .//src/bar.cc # the `.//' is meant. print: @echo BEG1: "$(LTCXXCOMPILE)" :1END @@ -45,7 +45,15 @@ END mkdir src cat > src/foo.cc << 'END' +int doit2 (void); int doit (void) +{ + return doit2(); +} +END + +cat > src/bar.cc << 'END' +int doit2 (void) { return 23; } @@ -70,4 +78,8 @@ if test -n "`./libtool --help | grep tag=TAG`"; then fi $MAKE -$MAKE distcheck +$MAKE distcheck 2>&1 | tee out +# GNU Make used to complain that the Makefile contained two rules +# for `src/.dirstamp' and `.//src/.dirstamp'. +grep 'overriding commands' out && exit 1 +: