title: Makefile: How can I store and manipulate the current target/recipe/rule's value?
body: <p>So I've got a makefile where I'm generating targets based on a list of directories, e.g.:</p>
  
  <pre><code>DIRLIST := dir1 dir2 dir3
  </code></pre>
  
  <p>I'm generating use case specific targets with prefixes added to the directory names, like so:</p>
  
  <pre><code>CLEANLIST := $(addprefix clean-,$(DIRLIST))
  </code></pre>
  
  <p>I'd then like to strip off the prefix in the target/recipe/rule, but I can't seem to read $@ into a variable:</p>
  
  <pre><code>$(CLEANLIST):
     @(eval TARGET=$@) #&lt;-- this part results in TARGET being empty
     @(eval REALTARGET=$(TARGET:clean-%=%))
     #...do stuff...
  </code></pre>
  
  <p>Is there any way to populate a variable within the target/recipe/rule that has the directory name with the prefix stripped off?</p>
  
  <p><strong>UPDATE:</strong> Thanks to Etan for pointing out that I messed up the syntax. It should be <code>$(eval ...)</code> instead of <code>@(eval ...)</code>. This is the most direct solution to my problem.</p>
  
  <p>The relevant part of my recipe now looks like this:</p>
  
  <pre><code>$(CLEANLIST):
      $(eval REALTARGET=$(@:clean-%=%))
      #...derive some exported variable values from REALTARGET for use by secondary.mk...
      $(MAKE) -f secondary.mk clean
  </code></pre>