title: Generate a list of files/objects dynamically from within makefile
body: <p>I am trying to do this:</p>
  
  <p>From a directory, pick all the <code>C</code> (<code>.c</code>) files, generate <code>.o</code> and add it to
  my final target executable. The <code>C</code> files can be added or removed at anytime, so when I 
  run <code>make</code> for my target, the available <code>C</code> files from the directory has to be picked
  to compile and link with my target.</p>
  
  <p>So far, I have the following:</p>
  
  <pre><code>define test_tgt = 
  DIR = full/path/to/dir
  FILES = $(wildcard $(DIR)/*.c)
  OBJS = &lt;rule-to-convert-C-to-O&gt;
  endef
  
  get_new_files: 
       $(eval $(test_tgt))
  
  final-target: get_new_files 
        $(CC) &lt;other-objs&gt; $(OBJS)
  </code></pre>
  
  <p>Somehow this doesn't seem to work. I see a lot of similar examples, but not sure what
  is wrong here. If this approach is not correct, can anyone suggest a better way to 
  accomplish this.</p>
  
  <p>TIA.</p>