automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FYI: canonize dirstamp directories (PR/461)


From: Alexandre Duret-Lutz
Subject: FYI: canonize dirstamp directories (PR/461)
Date: Sun, 15 May 2005 08:56:06 +0200
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux)

Hi Tom!

Thanks for the report.  I'm installing this on HEAD and branch-1-9.

2005-05-15  Alexandre Duret-Lutz  <address@hidden>

        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.

Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1603
diff -u -r1.1603 automake.in
--- automake.in 14 May 2005 20:28:50 -0000      1.1603
+++ automake.in 15 May 2005 05:03:05 -0000
@@ -147,6 +147,7 @@
 use Automake::RuleDef;
 use Automake::Wrap 'makefile_wrap';
 use File::Basename;
+use File::Spec;
 use Carp;
 
 ## ----------- ##
@@ -523,7 +524,9 @@
 
 
 # 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 @@
 # 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"
-                       . "address@hidden(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"
+                   . "address@hidden(mkdir_p) $directory\n"
+                   . "\t\@: > $dirstamp\n");
 
   return $dirstamp;
 }
Index: tests/subobj9.test
===================================================================
RCS file: /cvs/automake/automake/tests/subobj9.test,v
retrieving revision 1.10
diff -u -r1.10 subobj9.test
--- tests/subobj9.test  14 May 2005 20:28:56 -0000      1.10
+++ tests/subobj9.test  15 May 2005 05:03:08 -0000
@@ -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 @@
 
 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,8 +45,16 @@
 
 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;
 }
 END
@@ -70,4 +78,8 @@
 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
+:

-- 
Alexandre Duret-Lutz





reply via email to

[Prev in Thread] Current Thread [Next in Thread]