title: How to list all source files in a certain directory using Make
body: <p>I'm trying to list all relevant source files in a make project so that the relevant part of a code coverage report generated during unit testing can be filtered out.</p>
  
  <p>My solution so far works well but has the flaw that it doesn't list files in subdirectories. It only lists files in the root of the specified directories.</p>
  
  <p>USER_DIR is set to the location of the source files. It can contain several directories. Then the following lines will create the lists used to filter out relevant files from the code coverage report:</p>
  
  <pre><code>SRCEXTS = .c .cc .cpp
  HDREXTS = .h .H .hh .hpp .HPP .h++ .hxx .hp
  
  SW_SOURCE := $(foreach d,$(USER_DIR),$(wildcard $(addprefix $(d)/*,$(SRCEXTS))))
  SW_HEADERS := $(foreach d,$(USER_DIR),$(wildcard $(addprefix $(d)/*,$(HDREXTS))))
  </code></pre>
  
  <p>How could i alter my solution so that it also finds files in all subdirectories of USER_DIR? Alternatively, of course, if there is a better approach to this rather than the foreach i have that would also be of interest, but i think i would like to keep the format of the lists.</p>