]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
Fix PR automake/461:
authorAlexandre Duret-Lutz <adl@gnu.org>
Sun, 15 May 2005 06:56:22 +0000 (06:56 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Sun, 15 May 2005 06:56:22 +0000 (06:56 +0000)
* 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.

ChangeLog
automake.in
tests/subobj9.test

index 277473833eb9b529f0460acf834372f781219bcc..f532bcf4d99c7f4875228b34c4dbdfa36655dd7a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+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,
index eaf5c660904273ae8c7fdedf393a528b1810a13e..514bc13bb964f802465548bab064eb7c3658738d 100755 (executable)
@@ -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;
 }
index ecf26661efebd1444e201ba3257d13e68d85ef9e..d1e9932178e0b31e3768e5c5e6e2c03f098ef5df 100755 (executable)
@@ -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
+: