title: How do you get the list of targets in a makefile?
body: <p>I've used rake a bit (a Ruby make program), and it has an option to get a list of all the available targets, eg</p>
  
  <pre><code>&gt; rake --tasks
  rake db:charset      # retrieve the charset for your data...
  rake db:collation    # retrieve the collation for your da...
  rake db:create       # Creates the databases defined in y...
  rake db:drop         # Drops the database for your curren...
  ...
  </code></pre>
  
  <p>but there seems to be no option to do this in GNU make. </p>
  
  <p>Apparently the code is almost there for it, as of 2007 - <a href="http://www.mail-archive.com/help-make@gnu.org/msg06434.html">http://www.mail-archive.com/help-make@gnu.org/msg06434.html</a>. </p>
  
  <p>Anyway, I made little hack to extract the targets from a makefile, which you can include in a makefile. </p>
  
  <pre><code>list:
      @grep '^[^#[:space:]].*:' Makefile
  </code></pre>
  
  <p>It will give you a list of the defined targets. It's just a start - it doesn't filter out the dependencies, for instance. </p>
  
  <pre><code>&gt; make list
  list:
  copy:
  run:
  plot:
  turnin:
  </code></pre>