title: when multiple pattern rules match a target
body: <p>The <a href="http://www.gnu.org/software/make/manual/make.html#Pattern-Match" rel="noreferrer">GNU make manual</a> says</p>
  
  <blockquote>
    <p>It is possible that more than one pattern rule will meet these criteria. In that case, make will choose the rule with the shortest stem (that is, the pattern that matches most specifically).</p>
  </blockquote>
  
  <p>So it surprised me that:</p>
  
  <pre><code>$ touch make_specific.cpp
  
  $ cat Makefile.general_first
  %.o: %.cpp
  @echo using general rule
  $(CXX) -c $&lt; -o $@
  
  %_specific.o: %_specific.cpp
  @echo using specific rule
  $(CXX) -c $&lt; -o $@
  
  $ make -B -f Makefile.general_first make_specific.o
  using general rule
  g++44 -c make_specific.cpp -o make_specific.o
  </code></pre>
  
  <p>Multiple pattern rules match the target, and since the stem for the <code>%_specific.o : %_specific.cpp</code> rule ('make' in this case) is shorter than the stem for the <code>%.o : %.cpp</code> rule, I expected the specific rule to be selected, but it's not.</p>
  
  <p>What am I missing?</p>