Subject: DESTDIR affects distcheck badly.

From: Van de Bugger <[email-masked]>
Date: Tue, 22 Jan 2019 00:05:39 +0300

Software versions
=================

*   Fedora 29, x86_64
*   autoconf-2.69-28.fc29.noarch
*   automake-1.16.1-5.fc29.noarch

Steps to reproduce
==================

    $ tar xaf distdir.patch.tar.gz
    $ cd distdir.patch
    $ mkdir _build
    $ cd _build
    $ autoreconf -i ..
    $ ../configure
    $ DESTDIR=`pwd`/_install make distcheck

The problem
===========

Note enormously long path in the 'make distcheck' output:

    <...>
    make[2]: Entering directory '/home/vdb/prj/Alien/distdir.patch/_build/distdir-1.16.1.patch/_build/sub'
    make[2]: Nothing to be done for 'install-exec-am'.
     /usr/bin/mkdir -p '/home/vdb/prj/Alien/destdir/_build/_install/home/vdb/prj/Alien/distdir.patch/_build/distdir-1.16.1.patch/_inst/share/doc/distdir'
     /usr/bin/install -c -m 644 ../../README '/home/vdb/prj/Alien/destdir/_build/_install/home/vdb/prj/Alien/distdir.patch/_build/distdir-1.16.1.patch/_inst/share/doc/distdir'
    make[2]: Leaving directory '/home/vdb/prj/Alien/distdir.patch/_build/distdir-1.16.1.patch/_build/sub'
    make[1]: Leaving directory '/home/vdb/prj/Alien/distdir.patch/_build/distdir-1.16.1.patch/_build/sub'
    <...>

Namely:

    /home/vdb/prj/Alien/destdir/_build/_install/home/vdb/prj/Alien/distdir.patch/_build/distdir-1.16.1.patch/_inst/share/doc/distdir
    
Note that build directory is doubled.

This is result of interaction between distcheck goal and DESTDIR environment
variable.

In this particular case, path length does not exceed limits, and so distcheck
goal is built successully. However, it could be a real problem in case of
longer build directory path or if DESTDIR points to a non-writable directory.

Proposed solution
=================

See distdir.am.patch.