title: Iterating through a list of directories in a Makefile
body: <p>I would like to execute a task in several directories but found no "makefile-like" solution up to now. I know this is an often asked question and I know how to solve it for sub-makfiles and so on, but I am looking for something simpler.</p>
  
  <p>Instead of doing</p>
  
  <pre><code>copy: 
       cd module1 &amp;&amp; mkdir foo
       cd module2 &amp;&amp; mkdir foo
       cd module3 &amp;&amp; mkdir foo
  </code></pre>
  
  <p>I would like to have something like</p>
  
  <pre><code>directories = module1 module2 module3
  
  copy: $(directories)
       cd $&lt; &amp;&amp; mkdir foo
  </code></pre>
  
  <p>but that does not work, since the receipe is called only once with the first directory. I came up with this solution which works but is probably not in the style of Makefiles:</p>
  
  <pre><code>directories = module1 module2 module3
  
  copy: 
       for d in $(directories); do cd $$d &amp;&amp; mkdir foo &amp;&amp; cd ..; done
  </code></pre>
  
  <p>How can I do this more nicely?</p>