How to avoid “No such file or directory” Error for `make clean` Makefile target

后端 未结 5 2064
野的像风
野的像风 2021-01-04 00:28

I have a Makefile that defines a .PHONY clean target for cleaning up .o files and executables, that target looks like:

...
.PHONY : clean
clean:
    rm $(add         


        
5条回答
  •  忘掉有多难
    2021-01-04 00:56

    I've given up with rm. The following command will remove files and dirs.

    find . -delete
    

    To remove only files or only dirs, there is the -type option:

    # remove only files
    find . -type f -delete
    
    
    # remove only dirs
    find . -type d -delete
    

    Actually, I've create a little script (based on that snippet) named bomb that removes files without complaining: https://github.com/lingtalfi/bomb

提交回复
热议问题