title: Test whether a directory exists inside a makefile
body: <p>In his <a href="https://stackoverflow.com/a/59839/671013">answer</a> @Grundlefleck explains how to check whether a directory exists or not. I tried some to use this inside a <code>makefile</code> as follow:</p>
  
  <pre><code>foo.bak: foo.bar
      echo "foo"
      if [ -d "~/Dropbox" ]; then
          echo "Dir exists"
      fi
  </code></pre>
  
  <p>Running <code>make foo.bak</code> (given that <code>foo.bar</code> exists) yields the following error:</p>
  
  <pre><code>echo "foo"
  foo
  if [ -d "~/Dropbox" ]; then
  /bin/sh: -c: line 1: syntax error: unexpected end of file
  make: *** [foo.bak] Error 2
  </code></pre>
  
  <p>The workaround I made was to have a standalone bash script where the test is implemented and I called the script from the <code>makefile</code>. This, however, sounds very cumbersome. Is there a nicer way to check whether a directory exists from within a <code>makefile</code>?</p>