]> sourceware.org Git - automake.git/commitdiff
* automake.in (maybe_push_required_file): Add $(srcdir) in front
authorAlexandre Duret-Lutz <adl@gnu.org>
Sat, 27 Dec 2003 01:38:41 +0000 (01:38 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Sat, 27 Dec 2003 01:38:41 +0000 (01:38 +0000)
a required files outside the current directory or its subdirectories.
* lib/am/distdir.am (distdir): Update comment.
Report from Nicolas Joly.

ChangeLog
automake.in
lib/am/distdir.am

index e493e789b21f37078a960144446623c0fbab65b5..564b76f7624573d09d7ab7926d5c5a0719a7998c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2003-12-27  Alexandre Duret-Lutz  <adl@gnu.org>
+
+       * automake.in (maybe_push_required_file): Add $(srcdir) in front
+       a required files outside the current directory or its subdirectories.
+       * lib/am/distdir.am (distdir): Update comment.
+       Report from Nicolas Joly.
+
 2003-12-26  Alexandre Duret-Lutz  <adl@gnu.org>
 
        * doc/automake.texi (@copying): Do not repeat the version.
index 26e3bd3fae42edfc40b62365df6d39b11373e448..194c6f6e65665ef53a3312c8ebc35de7555b13da 100755 (executable)
@@ -6434,22 +6434,52 @@ my @require_file_paths = ();
 # encodes the rules for deciding when to do so.
 sub maybe_push_required_file
 {
-    my ($dir, $file, $fullfile) = @_;
+  my ($dir, $file, $fullfile) = @_;
 
-    if ($dir eq $relative_dir)
+  if ($dir eq $relative_dir)
     {
-       push_dist_common ($file);
-       return 1;
+      push_dist_common ($file);
+      return 1;
     }
-    elsif ($relative_dir eq '.' && ! &is_make_dir ($dir))
+  elsif ($relative_dir eq '.' && ! &is_make_dir ($dir))
     {
-       # If we are doing the topmost directory, and the file is in a
-       # subdir which does not have a Makefile, then we distribute it
-       # here.
-       push_dist_common ($fullfile);
-       return 1;
+      # If we are doing the topmost directory, and the file is in a
+      # subdir which does not have a Makefile, then we distribute it
+      # here.
+
+      # If a required file is above the source tree, it is important
+      # to prefix it with `$(srcdir)' so that no VPATH search is
+      # performed.  Otherwise problems occur with Make implementations
+      # that rewrite and simplify rules whose dependencies are found in a
+      # VPATH location.  Here is an example with OSF1/Tru64 Make.
+      #
+      #   % cat Makefile
+      #   VPATH = sub
+      #   distdir: ../a
+      #                  echo ../a
+      #   % ls
+      #   Makefile a
+      #   % make
+      #   echo a
+      #   a
+      #
+      # Dependency `../a' was found in `sub/../a', but this make
+      # implementation simplified it as `a'.  (Note that the sub/
+      # directory does not even exist.)
+      #
+      # This kind of VPATH rewriting seems hard to cancel.  The
+      # distdir.am hack against VPATH rewriting works only when no
+      # simplification is done, i.e., for dependencies which are in
+      # subdirectories, not in enclosing directories.  Hence, in
+      # the latter case we use a full path to make sure no VPATH
+      # search occurs.
+      $fullfile = '$(srcdir)/' . $fullfile
+       if $dir =~ m,^\.\.(?:$|/),;
+
+      push_dist_common ($fullfile);
+      return 1;
     }
-    return 0;
+  return 0;
 }
 
 
index 2ffe9bbc1a3f4366b77d0ef5cbb03780f2597dc8..0671a4843f0e46f3ae7845f5803dbc073d4e2243 100644 (file)
@@ -64,25 +64,39 @@ endif %?TOPDIR_P%
 ## Yet another hack to support SUN make.
 ##
 ## Let's assume `foo' appears in DISTFILES and is not a built file.
-## When building with VPATH=$(srcdir), SUN make will rewrite `foo' as
-## `$(srcdir)/foo'.  An attempt to install the file with
+## When building with VPATH=$(srcdir), SUN make and OSF1/Tru64 will
+## rewrite `foo' as `$(srcdir)/foo'.  An attempt to install the file
+## with
 ##    cp $file $(distdir)/$file
 ## will thus install $(srcdir)/foo as $(distdir)/$(srcdir)/foo
 ## instead of $(distdir)/foo.
 ##
 ## So let's strip this leading $(srcdir)/ when it exists.  (As far we
-## know, only SUN make adds it.)  Searching whether the file is to be
-## found in the source or build directory will be done latter.
+## know, only SUN make and OSF1/Tru64 make add it.)  Searching whether
+## the file is to be found in the source or build directory will be
+## done latter.
 ##
-## In case we are _not_ using SUN make, how can we be sure we are
-## not stripping a legitimate filename that starts with the same
-## pattern as $(srcdir)?
+## In case we are _not_ using SUN or OSF1/Tru64 make, how can we be sure
+## we are not stripping a legitimate filename that starts with the
+## same pattern as $(srcdir)?
 ## Well, it can't happen without the Makefile author distributing
 ## something out of the distribution (which is bad).   As an example,
 ## consider `EXTRA_DIST = ../bar'.  This is an issue if $srcdir is `..',
 ## however getting this value for srcdir is impossible: `EXTRA_DIST = ../bar'
 ## implies we are in a subdirectory (so `../bar' is within the package),
 ## hence `$srcdir' is something like `../../subdir'.
+##
+## There is more to say about files which are above the current directory,
+## like `../bar' in the previous example.  The OSF1/Tru64 make
+## implementation can simplify filenames resulting from a VPATH lookup.
+## For instance if `VPATH = ../../subdir' and `../bar' is found in that
+## VPATH directory, then occurrences of `../bar' will be replaced by
+## `../../bar' (instead of `../../subdir/../bar').  This obviously defeats
+## any attempt to strip a leading $srcdir.  Presently we have no workaround
+## for this.  We avoid this issue by writing `EXTRA_DIST = $(srcdir)/../bar'
+## instead of `EXTRA_DIST = ../bar'.  This prefixing is needed only for files
+## above the current directory.  Fortunately, apart from auxdir files which
+## can be located in .. or ../.., this situation hardly occurs in practice.
 ##
          case $$file in \
            $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
This page took 0.05125 seconds and 5 git commands to generate.