Test whether a directory exists inside a makefile

前端 未结 7 1442
-上瘾入骨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:45

    Try this:

    .PHONY: all
    something:
        echo "hi"
    all:
        test -d "Documents" && something
    

    This will execute the commands under something only if Documents exists.

    In order to address the problem noted in the comments, you can make a variable like this:

    PATH_TEST = ~/SomeDirectory
    
    test -d $(PATH_TEST) && something
    

提交回复
热议问题