title: Why is make not deleting intermediate files?
body: <p>I'm having problems with GNU make 3.81 not deleting intermediate files. The issue is similar to <a href="https://stackoverflow.com/questions/6512914/gnu-make-not-deleting-intermediate-files">GNU make Not Deleting Intermediate Files</a>, but that answer doesn't solve my problem. I've distilled the issue to this test case:</p>
  
  <pre><code>default: 
      @echo no $@ target; exit 1
  
  oncetwice: once twice
      @echo $@: $^
  
  ## Uncommenting the following line is sufficient to cause GNU make 3.81 to
  ## not delete the intermediate 'twice.dep', even if it didn't exist
  ## previously (i.e., was created by this invocation).
  #another: twice.dep
  
  %: %.dep
      @echo $^ &gt;$@
  
  ## the following .INTERMEDIATE has no effect re: the twice: twice.dep
  ## dependency
  .INTERMEDIATE: %.dep
  %.dep:
      @echo $@ &gt;$@
  </code></pre>
  
  <p>N.B. command blocks must be tab-indented.</p>
  
  <p>That is, the target <code>once</code> depends on <code>once.dep</code> and <code>twice</code> depends on <code>twice.dep</code>. In addition, <code>another</code> also depends on <code>twice.dep</code>. It is this line that causes <code>twice.dep</code> to never be removed, even if make created it and despite the .INTERMEDIATE line.</p>
  
  <p>The Makefile as posted gives:</p>
  
  <pre><code>snafu$ rm -f once* twice*; make oncetwice
  oncetwice: once twice
  rm once.dep twice.dep
  </code></pre>
  
  <p>Uncommenting the <code>twice: twice.dep</code> line:</p>
  
  <pre><code>snafu$ rm -f once* twice*; make oncetwice
  oncetwice: once twice
  rm once.dep
  </code></pre>
  
  <p>Notice that twice.dep is not rm'd in the second invocation.</p>
  
  <p>From the info pages:</p>
  
  <pre><code>.INTERMEDIATE
  The targets which .INTERMEDIATE depends on are treated as intermediate files.
  
  [...]
  
  Intermediate files are remade using their rules just like all other
  files. But intermediate files are treated differently in two ways.
  
  The first difference [...]
  
  **The second difference is that if make does create b in order to update
  something else, it deletes b later on after it is no longer
  needed. Therefore, an intermediate file which did not exist before make
  also does not exist after make.**
  </code></pre>
  
  <p>I've tried making <code>another: twice.dep</code> a real rule with a command block. I've also tried variations of specifying .INTERMEDIATE as a pattern, a literal filename, and both. I've also tried using .PHONY.  make-3.82 NEWS doesn't appear to have any relevant fixes.  The behavior I'm witnessing looks more like that described for .SECONDARY targets.</p>
  
  <p>Thanks,</p>
  
  <p>Reece</p>