automake
[Top][All Lists]
Advanced

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

Re: Incorrect directory creation with 'make dist' and EXTRA_DIST


From: Alexandre Duret-Lutz
Subject: Re: Incorrect directory creation with 'make dist' and EXTRA_DIST
Date: Fri, 06 Jan 2006 00:32:26 +0100
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/22.0.50 (gnu/linux)

>>> "SK" == Stepan Kasal <address@hidden> writes:

 SK> # Prepend $(distdir) to each directory given.
 SK> -  my %rewritten = map { s|^\$[({](top_)?srcdir[)}]|\$($1builddir)|;
 SK> +  my %rewritten = map { s|^\$[({]((top_)?)srcdir[)}]|\$($1builddir)|;
 SK> '$(distdir)/' . "$_" => 1 } keys %dist_dirs;
 SK> $transform{'DISTDIRS'} = join (' ', sort keys %rewritten);
 
Hum, on which version of Automake was this supposed to apply?

Anyway, Automake is already rewriting srcdir occurrences in
these directories, so I've installed the following patch to
gather everything in one place.

2006-01-05  Stepan Kasal  <address@hidden>
            Alexandre Duret-Lutz  <address@hidden>

        * automake.in (top_srcdir): New global.
        (generate_makefile): Compute it.
        (fill_dist_dirs): New function extracted from handle_dist.
        (handle_dist, handle_configure): Use fill_dist_dirs.
        * tests/distdir.test: Test for cases where $(top_srcdir) or
        $(srcdir) appear in EXTRA_DIST.  Report from Sander Niemeijer.

Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1613
diff -u -r1.1613 automake.in
--- automake.in 3 Oct 2005 20:52:27 -0000       1.1613
+++ automake.in 5 Jan 2006 23:22:51 -0000
@@ -7,7 +7,7 @@
 
 # automake - create Makefile.in from Makefile.am
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -463,6 +463,9 @@
 my $in_file_name;
 my $relative_dir;
 
+# Relative path to the top directory.
+my $topsrcdir;
+
 # Greatest timestamp of the output's dependencies (excluding
 # configure's dependencies).
 my $output_deps_greatest_timestamp;
@@ -3485,6 +3488,23 @@
     return $a cmp $b;
 }
 
+# fill_dist_dirs(@FILES)
+# ----------------------
+# Record in %dist_dirs the directory part of any file passed.
+sub fill_dist_dirs (@)
+{
+  my @copy = @_;
+  foreach (@copy)
+    {
+      s/\$\(top_srcdir\)/$topsrcdir/;
+      s/\$\(srcdir\)/./;
+      # Strip any leading `./'.
+      s,^(:?\./+)*,,;
+      next unless s,/+[^/]+$,,;
+      $dist_dirs{$_} = 1
+       unless $_ eq '.';
+    }
+}
 
 # handle_dist
 # -----------
@@ -3602,34 +3622,18 @@
   # originally, but there were so many requests that I finally
   # relented.
   my $extra_dist = var ('EXTRA_DIST');
-  if ($extra_dist)
-    {
-      # FIXME: This should be fixed to work with conditions.  That
-      # will require only making the entries in %dist_dirs under the
-      # appropriate condition.  This is meaningful if the nature of
-      # the distribution should depend upon the configure options
-      # used.
-      foreach ($extra_dist->value_as_list_recursive (skip_ac_subst => 1))
-       {
-         next unless s,/+[^/]+$,,;
-         $dist_dirs{$_} = 1
-           unless $_ eq '.';
-       }
-    }
+  # FIXME: This should be fixed to work with conditions.  That
+  # will require only making the entries in %dist_dirs under the
+  # appropriate condition.  This is meaningful if the nature of
+  # the distribution should depend upon the configure options
+  # used.
+  fill_dist_dirs ($extra_dist->value_as_list_recursive (skip_ac_subst => 1))
+    if $extra_dist;
 
   # We have to check DIST_COMMON for extra directories in case the
   # user put a source used in AC_OUTPUT into a subdir.
-  my $topsrcdir = backname ($relative_dir);
-  foreach (rvar ('DIST_COMMON')->value_as_list_recursive (skip_ac_subst => 1))
-    {
-      s/\$\(top_srcdir\)/$topsrcdir/;
-      s/\$\(srcdir\)/./;
-      # Strip any leading `./'.
-      s,^(:?\./+)*,,;
-      next unless s,/+[^/]+$,,;
-      $dist_dirs{$_} = 1
-       unless $_ eq '.';
-    }
+  fill_dist_dirs (rvar ('DIST_COMMON')
+                  ->value_as_list_recursive (skip_ac_subst => 1));
 
   $transform{'DISTCHECK-HOOK'} = !! rule 'distcheck-hook';
   $transform{'GETTEXT'} = $seen_gettext && !$seen_gettext_external;
@@ -4065,13 +4069,8 @@
       # is a bit ugly but it easier than spreading out the logic,
       # especially in cases like AC_OUTPUT(foo/out:bar/in), where
       # there is no Makefile in bar/.
-      if ($relative_dir eq '.')
-       {
-         foreach (@inputs)
-           {
-             $dist_dirs{dirname ($_)} = 1;
-           }
-       }
+      fill_dist_dirs (@inputs)
+       if $relative_dir eq '.';
 
       # We skip files that aren't in this directory.  However, if
       # the file's directory does not have a Makefile, and we are
@@ -7370,6 +7369,7 @@
 
   $relative_dir = dirname ($makefile);
   $am_relative_dir = dirname ($makefile_am);
+  $topsrcdir = backname ($relative_dir);
 
   read_main_am_file ($makefile_am);
   if (handle_options)
Index: tests/distdir.test
===================================================================
RCS file: /cvs/automake/automake/tests/distdir.test,v
retrieving revision 1.8
diff -u -r1.8 distdir.test
--- tests/distdir.test  14 May 2005 20:28:54 -0000      1.8
+++ tests/distdir.test  5 Jan 2006 23:22:51 -0000
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 1996, 2001, 2002, 2003  Free Software Foundation, Inc.
+# Copyright (C) 1996, 2001, 2002, 2003, 2006  Free Software Foundation, Inc.
 #
 # This file is part of GNU Automake.
 #
@@ -19,22 +19,38 @@
 # Boston, MA 02110-1301, USA.
 
 # Test to make sure subdirs in EXTRA_DIST work.  Also tests to make
-# sure "./" is ignored.
+# sure "./" is ignored and *srcdir properly handled.
 
 . ./defs || exit 1
 
 set -e
 
+echo AC_OUTPUT >>configure.in
+
 cat > Makefile.am << 'END'
-EXTRA_DIST = foo/bar ./joe
+EXTRA_DIST = foo/bar ./joe $(top_srcdir)/woo/doo $(srcdir)/dada
+check-local:
+       test -f $(srcdir)/foo/bar
+       test -f $(srcdir)/woo/doo
+       test -f $(srcdir)/joe
+       test -f $(srcdir)/dada
 END
 
 $ACLOCAL
+$AUTOCONF
 $AUTOMAKE
 
+mkdir foo woo
+touch foo/bar joe woo/doo dada
+
 grep '\$(mkdir_p).*\.' Makefile.in && exit 1
+grep '\$(mkdir_p).*srcdir' Makefile.in && exit 1
 grep '\$(mkdir_p).*foo' Makefile.in
 
 # Check to make sure `foo' isn't made in build directory.
 grep 'mkdir_p.*foo.*foo' Makefile.in && exit 1
+
+./configure --prefix `pwd`
+$MAKE distcheck
+
 exit 0
-- 
Alexandre Duret-Lutz

Shared books are happy books.     http://www.bookcrossing.com/friend/gadl





reply via email to

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