title: How to get non-recursive list of directory contents with their paths in Makefile?
body: <p>My project's directory structure is as follows:</p>
  
  <p><a href="https://i.stack.imgur.com/1Ndal.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1Ndal.png" alt="enter image description here"></a></p>
  
  <p>My Makefile looks like this:</p>
  
  <pre><code>dir1_contents = $(shell ls dir1/*)
  dir3_contents = $(shell ls dir3/*)
  
  all: clean_dir1 clean_dir3
  
  clean_dir1:
      echo 'dir1_contents = $(dir1_contents)'
  
  clean_dir3:
      echo 'dir3_contents = $(dir3_contents)'
  </code></pre>
  
  <p>When I run make, this is what I get:</p>
  
  <pre><code>$ pwd
  make-test
  
  $ make -s
  dir1_contents = dir1/file2.junk  dir1/dir2: file1.junk
  dir3_contents = dir3/file3.junk
  </code></pre>
  
  <p>I want to get the contents of <code>dir1</code> in <code>dir1_contents</code>. But I don't want the recursive contents. Just the contents that are immediately below the <code>dir1</code> directory. How can I do it?</p>
  
  <p>If I remove the <code>/*</code> from the first two lines of the Makefile, I get the right contents I want. But then they are missing their paths which I also need:</p>
  
  <pre><code>$ pwd
  make-test
  
  $ make -s
  dir1_contents = dir2 file2.junk
  dir3_contents = file3.junk
  </code></pre>
  
  <p>How can I get the right contents I want with the file paths that I need also?</p>