title: Make target using a pattern
body: <p>I'm doing something which it feels like should be pretty straightforward. I have source files in a directory called <code>./src</code> which are transformed and saved to <code>./</code>. <em>For the sake of the question, I'll just say they get copied there.</em></p>
  
  <p>Here's what the directory looks like before building:</p>
  
  <pre><code>/src/lib/foo.js
  /src/lib/mod/bar.js
  /src/bin/baz.js
  /Makefile
  </code></pre>
  
  <p>Here's what should be there after building:</p>
  
  <pre><code>/src/lib/foo.js
  /src/lib/mod/bar.js
  /src/bin/baz.js
  /lib/foo.js
  /lib/mod/bar.js
  /bin/baz.js
  /Makefile
  </code></pre>
  
  <p>In my Makefile I have this:</p>
  
  <pre><code>SRC_FILES := src/lib/foo.js src/lib/mod/bar.js src/bin/baz.js
  OUT_FILES := lib/foo.js lib/mod/bar.js bin/baz.js
  </code></pre>
  
  <p><em>These are generated from <code>find</code> and a pattern substitution, but are listed like this here for simplicity...</em></p>
  
  <p>Now, what I was hoping would work would be:</p>
  
  <pre><code>%.js: src/%.js
      cp $&lt; $@
  </code></pre>
  
  <p>But when I run <code>make lib/foo.js</code> I get <code>Nothing to be done for 'lib/foo.js'.</code></p>
  
  <p>Looking at the output from debugging, it appears to be trying to find a dependency named <code>lib/src/foo.js</code>. This is kind of what is described in <a href="http://www.gnu.org/software/make/manual/html_node/Pattern-Match.html#Pattern-Match" rel="nofollow">the manual</a>.</p>
  
  <p>This feels as though it should be a really easy thing! What am I doing wrong?</p>
  
  <hr>
  
  <p>Additionally, I tried:</p>
  
  <pre><code>$(OUT_FILES): $(SRC_FILES)
      cp $&lt; $@
  </code></pre>
  
  <p>...which works, but it rebuilds every single file if any of the sources change. <em>(Remember that my actual transformation isn't just <code>cp</code>, it's a relatively expensive operation, so this is undesirable)</em></p>