title: Does autotools Makefile automatically consider included header files as dependencies?
body: <p>I have an autotools-managed project (<a href="http://pastebin.com/p9d1XNcU" rel="noreferrer">sscce</a> tar.gz package <a href="https://docs.google.com/open?id=0Bw9sT8pzNEH7Y3ZNM3FaWjlQaFk" rel="noreferrer">here</a>) with this structure:</p>
  
  <p><a href="http://pastebin.com/dMPNukHi" rel="noreferrer"><code>./main.c</code></a><br>
  <a href="http://pastebin.com/p9d1XNcU" rel="noreferrer"><code>./foo.c</code></a><br>
  <a href="http://pastebin.com/xN0UQWeR" rel="noreferrer"><code>./foo/foo.h</code></a></p>
  
  <p>My <code>configure.ac</code> is:</p>
  
  <pre><code>AC_INIT([foo], [1.0], [foo@bar.ba])
  AM_INIT_AUTOMAKE([foreign -Wall -Werror])
  AC_PROG_CC
  AC_CONFIG_HEADERS([config.h])
  AC_CONFIG_FILES([Makefile])
  
  AC_OUTPUT
  </code></pre>
  
  <p>My <code>Makefile.am</code> were:</p>
  
  <pre><code>bin_PROGRAMS = main
  main_SOURCES = main.c foo.c foo.h
  </code></pre>
  
  <p>It compiled and ran perfectly... but then I note my <code>Makefile.am</code> was not correct. It stated that my main code depended upon <code>foo.h</code>, but the real file was <code>foo/foo.h</code>. I changed it, and the compilation was working as expected, as it was before:</p>
  
  <pre><code>bin_PROGRAMS = main
  main_SOURCES = main.c foo.c foo/foo.h
  </code></pre>
  
  <p>However, it made me wonder: how did it work when the dependencies were wrong? It worked so well that I could even edit <code>foo/foo.h</code> and <code>make</code> would recompile the dependent files. Actually, I could even remove the header file from the dependencies...</p>
  
  <pre><code>bin_PROGRAMS = main
  main_SOURCES = main.c foo.c
  </code></pre>
  
  <p>...and it would be still scanned an would trigger the recompilation of dependent files.</p>
  
  <p>So, my questions are:</p>
  
  <ul>
  <li>How does the autotools-generated <code>Makefile</code> know that <code>foo/foo.h</code> is a dependency to be analyzed during the <code>make</code> invocation?</li>
  <li>Should I add the header files to the <code>main_SOURCES</code> variable?</li>
  <li>Shouldn't <code>make</code> fail in the first case, since I am declaring that a non-existent file is a dependency?</li>
  </ul>