title: Make - Apply rule to a dynamically created file
body: <p>I have the following rule:</p>
  
  <pre><code>%.o: $(SRCDIR)%.S
      $(CC) $(ASFLAGS) -c $&lt; -o $(BINDIR)$@
  </code></pre>
  
  <p>It works great, except for the case where one of the source files <code>vectors.S</code> is created dynamically. The file does not come into existence until the following rule is ran:</p>
  
  <pre><code>vectors.S: $(SRCDIR)vectors.pl
      $(SRCDIR)vectors.pl &gt; $(SRCDIR)vectors.S
  </code></pre>
  
  <p>The rule creates the file <code>src/vectors.S</code>. Why doesn't the previous rule get applied to this new file? (The default implicit rule is used instead). What can I do to make it apply?</p>
  
  <p>For reference, here is a sample of the Makefile output:</p>
  
  <pre><code>gcc -m32 -gdwarf-2 -Wa,-divide -c src/swtch.S -o bin/swtch.o
  gcc -m32 -gdwarf-2 -Wa,-divide -c src/trapasm.S -o bin/trapasm.o
  src/vectors.pl &gt; src/vectors.S
  gcc -m32 -gdwarf-2 -Wa,-divide   -c -o vectors.o vectors.S
  gcc: error: vectors.S: No such file or directory
  gcc: fatal error: no input files
  compilation terminated.
  make: *** [vectors.o] Error 4
  </code></pre>
  
  <p><br>
  <strong>-- Update --</strong></p>
  
  <p>I managed to get it to work by specifying an explicit rule for <code>vectors.o</code>:</p>
  
  <pre><code>vectors.o: vectors.S
      $(CC) $(ASFLAGS) -c $(SRCDIR)$&lt; -o $(BINDIR)$@
  </code></pre>
  
  <p>I am still curious <strong>why</strong> the custom <code>%.o: $(SRCDIR)%.S</code> rule is ignored and the implicit one chosen... And what (if any) is the standard way to resolve this.</p>