title: Make: Unexpected Behavior with Dependencies and include Statement
body: <p>I have the following Makefile:</p>
  
  <pre><code>a.d:
      gcc -m32 -MM -o $@ a.c
      sed 's!a.o!$@ a.o!' --in-place $@
  
  a.o:
      gcc -c -m32 -o $@ a.c
  
  all: a.d a.o
  
  -include a.d
  </code></pre>
  
  <p>The contents of a.d are:</p>
  
  <pre><code>a.d a.o: a.c a.h
  </code></pre>
  
  <p>I'm having 2 problems. 1, after running "make all" if I run:</p>
  
  <pre><code>touch a.h
  make a.d
  </code></pre>
  
  <p>I see this:</p>
  
  <pre><code>gcc -m32 -MM -o a.d a.c
  sed 's!a.o!a.d a.o!' --in-place a.d
  make: 'a.d' is up to date.
  </code></pre>
  
  <p>The a.d rule clearly ran, why do I see "make: 'a.d' is up to date."?</p>
  
  <p>2, after running "make all" when I run this:</p>
  
  <pre><code>touch a.h
  make a.o
  </code></pre>
  
  <p>I see this:</p>
  
  <pre><code>gcc -m32 -MM -o a.d a.c
  sed 's!a.o!a.d a.o!' --in-place a.d
  gcc -c -m32 -o a.o a.c
  </code></pre>
  
  <p>Why did it also run the a.d rule? There are no dependencies on it.</p>
  
  <p>What I really don't understand is when I replace "-include a.d" with the contents of a.d in the make file, for example:</p>
  
  <pre><code>#-include a.d
  a.d a.o: a.c a.h
  </code></pre>
  
  <p>I don't see either problem. Shouldn't the include statement make it as if the include file were included directly in the same make file?</p>
  
  <p>This is what my a.h looks like:</p>
  
  <pre><code>#define FOO 0
  </code></pre>
  
  <p>And this is a.c:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include "a.h"
  
  void foo(void)
  {
      printf("foo %d", FOO);
  }
  </code></pre>
  
  <p>I'm using Cygwin 64-bit. Here's my output from make -v:</p>
  
  <pre><code>$ make -v
  GNU Make 4.1
  Built for x86_64-unknown-cygwin
  Copyright (C) 1988-2014 Free Software Foundation, Inc.
  License GPLv3+: GNU GPL version 3 or later &lt;http://gnu.org/licenses/gpl.html&gt;
  This is free software: you are free to change and redistribute it.
  There is NO WARRANTY, to the extent permitted by law.
  </code></pre>