How do I check if file exists in Makefile so I can delete it?

前端 未结 12 2167
心在旅途
心在旅途 2020-12-02 07:40

In the clean section of my Makefile I am trying to check if the file exists before deleting permanently. I use this code but I receive errors.

What\'s w

12条回答
  •  旧时难觅i
    2020-12-02 08:01

    I was trying:

    [ -f $(PROGRAM) ] && cp -f $(PROGRAM) $(INSTALLDIR)
    

    And the positive case worked but my ubuntu bash shell calls this TRUE and breaks on the copy:

    [ -f  ] && cp -f  /home/user/proto/../bin/
    cp: missing destination file operand after '/home/user/proto/../bin/'
    

    After getting this error, I google how to check if a file exists in make, and this is the answer...

提交回复
热议问题