title: gnu make recreating directory structure in target
body: <p>I'd like to use GNUmake to do image compression and some preparations for my websites.</p>
  
  <p>I have a structure like</p>
  
  <pre><code>src
      www.site1.org
          images
              foo.jpg
              bar.png
          css
              style.scss
      www.site2.org
          images
              baz.svg
          css
              design.scss
  </code></pre>
  
  <p>I want be able to recreate this structure in <code>target</code> directory while using some other tools to optimize/compile the sources like e.g. <code>convert --strip src/www.site1.org/images/foo.jpg target/www.site1.org/images/foo.jpg</code></p>
  
  <p>I can find all my jpegs using something like <code>SRC:=$(shell find . -name '*.jpg')</code> and even create a variable holding all the targets with <code>TARGETS=$(SRC:src=target)</code>.</p>
  
  <p>But now I don't find a way of writing a rule for which would (naively) look like:</p>
  
  <pre><code>$(TARGET): $(SRC)
      convert --strip $&lt; $@
  </code></pre>
  
  <p>I've searched the internet for quiet some time now but didn't find anything appropriate.</p>