title: Make implicit rule fails at first time but succeeds at second time
body: <p>I encounter an error relating to implicit rule in <code>make</code> (3.81). The example codes are:</p>
  
  <pre><code>dongli:test02 dongli$ ls -R
  Makefile a.F90    b.F90    dir
  
  ./dir:
  a.t.F90
  </code></pre>
  
  <p>The dependencies among the codes are:</p>
  
  <pre><code>a.t.F90: a.F90
  a.t.o: a.t.F90
  b.o: b.F90
  b: a.t.o b.o
  </code></pre>
  
  <p>That is <code>a.F90</code> is intermediate code, and <code>a.t.F90</code> will be updated when <code>a.F90</code> is updated. My <code>make</code> process is:</p>
  
  <p><strong>Test 1</strong> (All codes on position):</p>
  
  <pre><code>-------------------------------------------------------------
   Project: &gt;&gt;&gt; test &lt;&lt;&lt;
  -------------------------------------------------------------
   Creating dependency a.t.o
  -------------------------------------------------------------
  -----&gt; ./dir/a.t.F90
   Creating dependency b.o
  -------------------------------------------------------------
  -----&gt; b.F90
   Creating target 'b'
   ---&gt; b is created.
  -------------------------------------------------------------
   Finished
  -------------------------------------------------------------
  </code></pre>
  
  <p><strong>Test 2</strong> (touch <code>a.F90</code>):</p>
  
  <pre><code>dongli:test02 dongli$ touch a.F90
  dongli:test02 dongli$ make
  -------------------------------------------------------------
   Project: &gt;&gt;&gt; test &lt;&lt;&lt;
  -------------------------------------------------------------
   Processing templates in a.F90
  -------------------------------------------------------------
   Creating dependency a.t.o
  -------------------------------------------------------------
  -----&gt; a.t.F90
  gfortran: error: a.t.F90: No such file or directory
  gfortran: fatal error: no input files
  compilation terminated.
  make: *** [a.t.o] Error 1
  </code></pre>
  
  <p><strong>Test 3</strong>: (Run <code>make</code> again):</p>
  
  <pre><code>dongli:test02 dongli$ make
  -------------------------------------------------------------
   Project: &gt;&gt;&gt; test &lt;&lt;&lt;
  -------------------------------------------------------------
   Creating dependency a.t.o
  -------------------------------------------------------------
  -----&gt; ./dir/a.t.F90
   Creating dependency b.o
  -------------------------------------------------------------
  -----&gt; b.F90
   Creating target 'b'
   ---&gt; b is created.
  -------------------------------------------------------------
   Finished
  -------------------------------------------------------------
  </code></pre>
  
  <p>I know there is a bug in <code>make</code> about <strong>directory caching</strong> (see <a href="http://savannah.gnu.org/bugs/?func=detailitem&amp;item_id=15583" rel="nofollow">here</a>), but in my case, <code>dir/a.t.F90</code> exists all the time. Any idea? Thanks!</p>
  
  <p><strong>Update1:</strong></p>
  
  <p>I use <code>make -d</code> to capture the following information in test 2:</p>
  
  <pre><code>       Finished prerequisites of target file `a.t.F90'.
         Prerequisite `a.F90' is newer than target `a.t.F90'.
        Must remake target `a.t.F90'.
    Ignoring VPATH name `./dir/a.t.F90'.
  
    ...
  
          Successfully remade target file `a.t.F90'.
   Finished prerequisites of target file `a.t.o'.
   Prerequisite `a.t.F90' of target `a.t.o' does not exist.
  Must remake target `a.t.o'.
  </code></pre>
  
  <p>Why <code>./dir/a.t.F90</code> is ignored when its prerequisite <code>a.F90</code> is newer than it?</p>
  
  <p><strong>Update2:</strong></p>
  
  <p>I have put the example codes on <a href="https://gist.github.com/dongli/6059091" rel="nofollow">gist</a>.</p>
  
  <p><strong>Update3:</strong></p>
  
  <p>I found the following relating information:</p>
  
  <blockquote>
    <p>If a target needs to be rebuilt, GNU make discards the file name found
    during the VPATH search for this target, and builds the file locally
    using the file name given in the makefile. If a target does not need
    to be rebuilt, GNU make uses the file name found during the VPATH
    search.</p>
  </blockquote>