title: In a Makefile, is it possible to have a target be out of date iff another target is out of date?
body: <p>I want to write a rule that looks something like this:</p>
  
  <pre><code>foo.out: (out of date if foo.in is newer than foo.out.stamp)
      # update foo.out if and only if the new foo.out has different contents
      # than the old foo.out (a change to foo.in may or may not change foo.out)
      &amp;&amp; touch foo.out.stamp
  </code></pre>
  
  <p>I can't do this:</p>
  
  <pre><code>foo.out.stamp: foo.in
      # update foo.out if and only if the new foo.out has different contents
      # than the old foo.out (a change to foo.in may or may not change foo.out)
      &amp;&amp; touch foo.out.stamp
  
  foo.out: foo.out.stamp
  </code></pre>
  
  <p>Because if <code>foo.in</code> changes, but the recipe for <code>foo.out.stamp</code> does not change <code>foo.out</code>, <code>make</code> will always view <code>foo.out</code> as out of date.</p>
  
  <p>Is there any way to write this kind of rule?</p>
  
  <p>Edit: Explanation of why I don't unconditionally touch <code>foo.out</code>:</p>
  
  <p>I am working with Vala. The Vala compilation process looks something like this:</p>
  
  <ol>
  <li>For each <code>.vala</code> file, generate a <code>.vapi</code> file (similar to a header file).</li>
  <li>For each <code>.vala</code> file, generate a <code>.c</code> file (this requires the individual <code>.vala</code> file and <em>every</em> <code>.vapi</code> file to be given to the compiler)</li>
  <li>Continue the typical <code>.c -&gt; .o -&gt; executable/library</code> process.</li>
  </ol>
  
  <p>For steps #1 and #2, the Vala compiler only updates the <code>.vapi</code>/<code>.c</code> file if its contents have been changed. This is to prevent needless <code>.c -&gt; .o</code> recompilation.</p>
  
  <p>In makefile terms:</p>
  
  <ul>
  <li>A <code>.vapi</code> file is out of date if the <code>.vala</code> file has changed since the last time the Vala compiler regenerated the <code>.vapi</code> file (not the last time that the <code>.vapi</code> file was modified).</li>
  <li>A <code>.c</code> file is out of date if the <code>.vala</code> or <em>any</em> <code>.vapi</code> file has changed since the last time the Vala compiler regenerated the <code>.c</code> file (not the last time that the <code>.c</code> file was modified).</li>
  </ul>