Test whether a directory exists inside a makefile

前端 未结 7 1441
-上瘾入骨i
-上瘾入骨i 2020-12-23 09:11

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.b         


        
7条回答
  •  滥情空心
    2020-12-23 09:41

    Make commands, if a shell command, must be in one line, or be on multiple lines using a backslash for line extension. So, this approach will work:

    foo.bak: foo.bar
        echo "foo"
        if [ -d "~/Dropbox" ]; then echo "Dir exists"; fi
    

    Or

    foo.bak: foo.bar
        echo "foo"
        if [ -d "~/Dropbox" ]; then \
            echo "Dir exists"; \
        fi
    

提交回复
热议问题