title: Are paths containing directories allowed in AC_REQUIRE_AUX_FILE?
body: <p>The <em>Autoconf</em> macro <a href="https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Input.html#index-AC_005fREQUIRE_005fAUX_005fFILE-60" rel="nofollow"><code>AC_REQUIRE_AUX_FILE</code></a> can be used to register auxiliary files needed during the build process.</p>
  
  <blockquote>
    <p>— Macro: <code>AC_REQUIRE_AUX_FILE (<i>file</i>)</code></p>
    
    <p>Declares that <em><code>file</code></em> is expected in the directory defined above. In Autoconf proper, this macro does nothing: its sole purpose is to be traced by third-party tools to produce a list of expected auxiliary files. For instance it is called by macros like <code>AC_PROG_INSTALL</code> (see <em>Particular Programs</em>) or <code>AC_CANONICAL_BUILD</code> (see <em>Canonicalizing</em>) to register the auxiliary files they need.</p>
  </blockquote>
  
  <p>The files are expected in the directory registered via <a href="https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Input.html#index-AC_005fCONFIG_005fAUX_005fDIR-58" rel="nofollow"><code>AC_CONFIG_AUX_DIR</code></a> or a default directory determined as described in the documentation for <code>AC_CONFIG_AUX_DIR</code> if the macro is not used (referred to as <code>${auxdir}</code> in the following).  This is the “directory defined above” in the above quote from the manual.</p>
  
  <p><em>Automake</em> <a href="https://www.gnu.org/software/automake/manual/html_node/Optional.html" rel="nofollow">uses the information</a> to add those auxiliary files to the list of distributed files.</p>
  
  <blockquote>
    <p><code>AC_REQUIRE_AUX_FILE</code></p>
    
    <p>For each <code>AC_REQUIRE_AUX_FILE([<i>file</i>])</code>, Automake will ensure that <em><code>file</code></em> exists in the aux directory, and will complain otherwise. It will also automatically distribute the file. This macro should be used by third-party Autoconf macros that require some supporting files in the aux directory specified with <code>AC_CONFIG_AUX_DIR</code> above. See <em>Finding <code>configure</code> Input</em> in <em>The Autoconf Manual</em>.</p>
  </blockquote>
  
  <p>From this documentation – which is all I can find about this topic – I assume that I should also be able to list files in sub-directories of <code>${auxdir}</code>.</p>
  
  <p><strong>However, the following example fails with a funny error.</strong></p>
  
  <p>Given this directory structure</p>
  
  <pre class="lang-none prettyprint-override"><code>./
  ./Makefile.am
  ./build-aux/
  ./build-aux/bar/
  ./build-aux/bar/baz.txt
  ./build-aux/foo.txt
  ./configure.ac
  </code></pre>
  
  <p>with the following <code>configure.ac</code></p>
  
  <pre class="lang-sh prettyprint-override"><code>AC_PREREQ([2.69])
  AC_INIT([example], [1.0], [bugs@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])
  </code></pre>
  
  <p>and an empty <code>Makefile.am</code>, running <code>autoreconf -ivs</code> fails.</p>
  
  <pre>
  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
  <b>configure.ac:5: error: required file 'build-aux/bar/baz.txt' not found</b>
  configure.ac:6: installing 'build-aux/install-sh'
  configure.ac:6: installing 'build-aux/missing'
  <b>autoreconf: automake failed with exit status: 1</b>
  </pre>
  
  <p>Ironically, the error message names the correct file exactly.</p>
  
  <p>I think that the erratic error message is triggered by the function <a href="http://git.savannah.gnu.org/cgit/automake.git/tree/bin/automake.in#n3775" rel="nofollow"><code>rewrite_inputs_into_dependencies</code></a> but I cannot make sense of the cause of the error due to my limited <em>Perl</em> skills.</p>
  
  <p><strong>So, my question is:</strong></p>
  
  <ul>
  <li>Is naming files in sub-directories of <code>${auxdir}</code> allowed?</li>
  <li>Am I doing something wrong?</li>
  <li>Is there a bug in <em>Automake</em>?</li>
  </ul>
  
  <p>If there is a simple workaround to achieve the same effect as if by listing the file in <code>AC_REQUIRE_AUX_FILE</code>, I'd be happy to know that too.  Please note that I'm writing an <em>Autoconf</em> macro supposed to be used by other people so I cannot add the files to the <code>EXTRA_DIST</code> variable in the <code>Makefile.am</code> directly.</p>