+2005-05-15 Alexandre Duret-Lutz <adl@gnu.org>
+
+ 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 <adl@gnu.org>
* COPYING, ChangeLog, ChangeLog.00, ChangeLog.01, ChangeLog.02,
use Automake::RuleDef;
use Automake::Wrap 'makefile_wrap';
use File::Basename;
+use File::Spec;
use Carp;
## ----------- ##
# 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.
# 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;
}
#! /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.
#
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
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;
}
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
+: