title: How to generate list of make targets automatically by globbing subdirectories?
body: <p>I would like to use a single Makefile to generate targets in hundreds of subdirectories. Each subdirectory is a date/time stamp like this: <code>20120119_153957</code>, which matches the following pattern <code>????????_??????</code>. There are no other subdirectories that match this pattern.</p>
  
  <p>One target I would like to generate is called <code>????????_??????/graph.pdf</code>. I have a script called <code>make_graph</code> that will make the graph given the subdirectory name. But I'm not sure how to write a Makefile that will automatically glob all of the subdirectores and generate these targets programmatically.</p>
  
  <p>For example, the code <code>SUBDIRS:=????????_??????</code> seems to correctly glob all of the subdirectories. I can check with this rule:</p>
  
  <pre><code>.PHONY: print
  print:
          echo $(SUBDIRS)
  </code></pre>
  
  <p>However this variable assignment</p>
  
  <pre><code>TARGETS:=$(SUBDIRS:%=%/graph.pdf)
  </code></pre>
  
  <p>does not seem to do what I expect and assign lots and lots of targets. Instead the following rule just prints one target.</p>
  
  <pre><code>.PHONY: print
  print:
          echo $(TARGETS)
  </code></pre>
  
  <p>It is very confusing that <code>SUBDIRS</code> should have the correct subdirectories but <code>TARGET</code> only has one file.</p>