GNU bug report logs - #20300
Are paths containing directories allowed in AC_REQUIRE_AUX_FILE?

Previous Next

Package: automake;

Reported by: Moritz Klammler <moritz <at> klammler.eu>

Date: Sat, 11 Apr 2015 08:14:01 UTC

Severity: normal

Tags: confirmed

Done: Mike Frysinger <vapier <at> gentoo.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 20300 in the body.
You can then email your comments to 20300 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-automake <at> gnu.org:
bug#20300; Package automake. (Sat, 11 Apr 2015 08:14:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Moritz Klammler <moritz <at> klammler.eu>:
New bug report received and forwarded. Copy sent to bug-automake <at> gnu.org. (Sat, 11 Apr 2015 08:14:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Moritz Klammler <moritz <at> klammler.eu>
To: bug-automake <at> gnu.org
Subject: Are paths containing directories allowed in AC_REQUIRE_AUX_FILE?
Date: Sat, 11 Apr 2015 02:56:25 +0200
[Message part 1 (text/plain, inline)]
Hello everybody,

last week, I have asked this question on Stack Overflow [1] but did not
receive any answer.  I'll be happy to post a summary of the replies I'll
get on this list there.  But if you have an account and want to gain
some valuable internet points, I'll accept your answer, of course.

Please consider this directory structure

    demo/
    demo/Makefile.am
    demo/build-aux/
    demo/build-aux/bar/
    demo/build-aux/bar/baz.txt
    demo/build-aux/foo.txt
    demo/configure.ac

with the following `configure.ac`

     AC_PREREQ([2.69])
     AC_INIT([example], [1.0], [bugs <at> example.com])
     AC_CONFIG_AUX_DIR([build-aux])
     AC_REQUIRE_AUX_FILE([foo.txt])      # this works
     AC_REQUIRE_AUX_FILE([bar/baz.txt])  # this does not work
     AM_INIT_AUTOMAKE([foreign])
     AC_OUTPUT([Makefile])

and an empty `Makefile.am`.  I have attached a tar ball with this setup
for your convenience.

As indicated by the comments, the invocation of `AC_REQUIRE_AUX_FILE`
for `bar/baz.txt` does not work as expected.  If running `autoreconf`
From the top-level directory, Automake will fail with the following
error message:

    $ test -f build-aux/bar/baz.txt && autoreconf -ivs
    autoreconf: Entering directory `.'
    autoreconf: configure.ac: not using Gettext
    autoreconf: running: aclocal
    autoreconf: configure.ac: tracing
    autoreconf: configure.ac: not using Libtool
    autoreconf: running: /usr/bin/autoconf
    autoreconf: configure.ac: not using Autoheader
    autoreconf: running: automake --add-missing --no-force
    configure.ac:5: error: required file 'build-aux/bar/baz.txt' not found
    configure.ac:6: installing 'build-aux/install-sh'
    configure.ac:6: installing 'build-aux/missing'
    autoreconf: automake failed with exit status: 1

Note that the reported error names the file name exactly as expected but
incorrectly says it does not exist.

I have checked the documentation for `AC_REQUIRE_AUX_FILE` in the
Autoconf manual [2] as well as what I consider the relevant reference in
the Automake manual [3] and none of this suggests to me that I shouldn't
be allowed to list file names in sub-directories of ${auxdir} here.

It seems to me that the error message is triggered by the function
`rewrite_inputs_into_dependencies` in `automake.in` [4] but I cannot
trace back the logic due to my limited Perl skills.

Am I missing something here?  Is this intended to work?  If naming paths
containing directory parts is not allowed, could the manual be updated
to say so?


Thank you & kind regards

Moritz Klammler



Autoconf version: 2.69
Automake version: 1.15
Platform: Parabola GNU/Linux

References:

[1] https://stackoverflow.com/q/29445704/1392132
[2] https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Input.html#index-AC_005fREQUIRE_005fAUX_005fFILE-60
[3] https://www.gnu.org/software/automake/manual/html_node/Optional.html
[4] http://git.savannah.gnu.org/cgit/automake.git/tree/bin/automake.in#n3775
-- 
OpenPGP:

Public Key:   http://openpgp.klammler.eu
Fingerprint:  80C1 EC79 B554 3D84 0A35 A728 7057 B288 CE61 2235

[demo.tar.gz (application/octet-stream, attachment)]
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-automake <at> gnu.org:
bug#20300; Package automake. (Mon, 21 Feb 2022 04:43:02 GMT) Full text and rfc822 format available.

Message #8 received at 20300 <at> debbugs.gnu.org (full text, mbox):

From: Mike Frysinger <vapier <at> gentoo.org>
To: 20300 <at> debbugs.gnu.org
Subject: [PATCH] automake: allow required files to be in subdirs
Date: Sun, 20 Feb 2022 23:42:11 -0500
Fixes automake bug https://bugs.gnu.org/20300.

The internal method for caching path lookups expects the $filename to
only be a filename.  If it's actually a subdir/file itself, then the
cache logic gets confused, and it never matches.  This manifests as
AC_REQUIRE_AUX_FILE([subdir/file]) claiming that the subdir/file path
doesn't exist even when it does.

Before we process any required files, since we already construct the
full path locally, reset the dir & file inputs to the final values.

* bin/automake.in: Split dir & file name back out from the constructed
required file path.
* t/auxdir-subsubdir.sh: New test.
* t/list-of-tests.mk: Add t/auxdir-subsubdir.sh.
---
 bin/automake.in       |  7 +++++++
 t/auxdir-subsubdir.sh | 39 +++++++++++++++++++++++++++++++++++++++
 t/list-of-tests.mk    |  1 +
 3 files changed, 47 insertions(+)
 create mode 100644 t/auxdir-subsubdir.sh

diff --git a/bin/automake.in b/bin/automake.in
index 5a151455019e..5eba649d240c 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -7628,6 +7628,13 @@ sub required_file_check_or_copy
   my ($where, $dir, $file) = @_;
 
   my $fullfile = "$dir/$file";
+  # In cases where $file is actually a subdir/filename, split the full path back
+  # into dir & file names.  The FileUtils (e.g. dir_has_case_matching_file) do
+  # not handle this scenario at all and expect $file to only be a filename.
+  # https://bugs.gnu.org/20300
+  $dir = dirname ($fullfile);
+  $file = basename ($fullfile);
+
   my $found_it = 0;
   my $dangling_sym = 0;
 
diff --git a/t/auxdir-subsubdir.sh b/t/auxdir-subsubdir.sh
new file mode 100644
index 000000000000..21880f23591f
--- /dev/null
+++ b/t/auxdir-subsubdir.sh
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 2022 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+# Make sure auxdir with subdir aux files works.
+
+. test-init.sh
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([build-aux])
+AC_REQUIRE_AUX_FILE([top-file])
+AC_REQUIRE_AUX_FILE([subdir/file])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES(Makefile)
+END
+
+touch Makefile.am
+
+mkdir -p build-aux/subdir
+: >build-aux/top-file
+: >build-aux/subdir/file
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+
+:
diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk
index d8e50b080166..85de422193a0 100644
--- a/t/list-of-tests.mk
+++ b/t/list-of-tests.mk
@@ -188,6 +188,7 @@ t/auxdir-computed.tap \
 t/auxdir-misplaced.sh \
 t/auxdir-nonexistent.sh \
 t/auxdir-pr19311.sh \
+t/auxdir-subsubdir.sh \
 t/auxdir-unportable.tap \
 t/backcompat.sh \
 t/backcompat2.sh \
-- 
2.34.1





Added tag(s) confirmed. Request was from Mike Frysinger <vapier <at> gentoo.org> to control <at> debbugs.gnu.org. (Mon, 21 Feb 2022 04:43:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-automake <at> gnu.org:
bug#20300; Package automake. (Wed, 23 Feb 2022 02:24:02 GMT) Full text and rfc822 format available.

Message #13 received at 20300 <at> debbugs.gnu.org (full text, mbox):

From: Karl Berry <karl <at> freefriends.org>
To: vapier <at> gentoo.org
Cc: 20300 <at> debbugs.gnu.org
Subject: Re: bug#20300: [PATCH] automake: allow required files to be in subdirs
Date: Tue, 22 Feb 2022 19:23:48 -0700
    * bin/automake.in: Split dir & file name back out from the constructed
    required file path.

Looks like good work to me. Thanks. -k




bug closed, send any further explanations to 20300 <at> debbugs.gnu.org and Moritz Klammler <moritz <at> klammler.eu> Request was from Mike Frysinger <vapier <at> gentoo.org> to control <at> debbugs.gnu.org. (Thu, 24 Feb 2022 04:46:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 24 Mar 2022 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 27 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.