title: How to implement an implicit rule which depends on a similarly named file in GNU Make?
body: <p>If I want to create <code>foo.txt</code> when the user runs <code>make foo</code>, that's simple enough:</p>
  
  <pre><code>foo: foo.txt
  
  foo.txt:
      touch foo.txt
  </code></pre>
  
  <p>But what if I don't know about the name <code>foo</code> ahead of time, and I want to support creating any other arbitrarily named text file?</p>
  
  <p>Here's what I tried:</p>
  
  <pre><code>%: %.txt
  
  %.txt:
      touch %.txt
  </code></pre>
  
  <p>But if I try <code>make clojure</code>, instead of running <code>touch clojure.txt</code>, it fails with <code>No rule to make target clojure</code>.</p>
  
  <p>How is this done?</p>