title: Makefile dependency-iterating generic rule
body: <p>I've been looking through makefile syntax manuals and haven't found anything that really helps the usage case I'm trying to enact here.</p>
  
  <p>What I have is a list of source files with varying directories under a common directory, like so:</p>
  
  <pre><code>src/a.h
  src/b.h
  src/dir/c.h
  src/dir/dir/d.h
  </code></pre>
  
  <p>and would like <code>make</code> to use these individually as a dependency for a rule that ultimately creates:</p>
  
  <pre><code>build/a.h
  build/b.h
  build/c.h
  build/d.h
  </code></pre>
  
  <p>which then are used as dependencies individually for more rules.</p>
  
  <h3>What I have so far:</h3>
  
  <pre><code>LIST := src/a.h src/b.h src/dir/c.h src/dir/d.h
  all : $(addprefix build/,$(notdir ${LIST}))
      @echo 'All rule invoked'
  </code></pre>
  
  <h3>What doesn't work:</h3>
  
  <hr>
  
  <pre><code>$(LIST) : build/$(notdir %).h : %.h
      @echo 'dst $* dat $@ din $&lt;'
  </code></pre>
  
  <p><em>target 'item' doesn't match the target pattern</em></p>
  
  <hr>
  
  <pre><code>build/%.h: %.h
  </code></pre>
  
  <p><em>no rule to make target 'build/a.h' needed by 'all'.</em></p>
  
  <hr>
  
  <p>I'm guessing make got mad at me at this point, as the errors started telling me to stop.</p>
  
  <p>Basically, I am reading in a list of files with a path prefix that is relevant for the search path and dependency, and want to dump each individual one only when the source file is updated. After this, these files in that single directory are used as dependencies for another batch of rules. How can I accomplish this? </p>
  
  <p>Note: I've gotten it done by ignoring the dependency chain, but that's not going to work. I can also use make to run scripts that generate an explicit makefile that can do it properly, but that feels like overkill and a waste of resources, and make ought to be able to create a rule that does that by itself, as powerful as it is. I just don't know how to create generic rules that focus on the dependency variable for its text matching, rather than the target.</p>