title: How to pass for loop variable to shell function in makefile
body: <p>Consider the makefile below :</p>
  
  <pre><code>CFG_DIR = /media/test/
  all:
      for list in $(CFG_DIR); do \
        echo "list is $$list"; \
        for file in $(shell ls $${list}); do \
          echo "file is $$file"; \
        done \
      done
  </code></pre>
  
  <p>When make is executed the below result is generated:</p>
  
  <pre><code>list is /media/test/
  file is Makefile
  </code></pre>
  
  <p>Instead of printing the directory listing of /media/test/ directory, directory listing of the current directory from where the make command is executed is printed. </p>
  
  <p>It seems like within the shell function $$list is being evaluated to an empty value. It would be helpful if someone can point out the correct way to access for loop variables inside shell function.</p>