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