how to prevent “directory already exists error” in a makefile when using mkdir

前端 未结 12 1671
遇见更好的自我
遇见更好的自我 2020-12-04 06:44

I need to generate a directory in my makefile and I would like to not get the \"directory already exists error\" over and over even though I can easily ignore it.

I

12条回答
  •  遥遥无期
    2020-12-04 07:04

    A little simpler than Lars' answer:

    something_needs_directory_xxx : xxx/..
    

    and generic rule:

    %/.. : ;@mkdir -p $(@D)
    

    No touch-files to clean up or make .PRECIOUS :-)

    If you want to see another little generic gmake trick, or if you're interested in non-recursive make with minimal scaffolding, you might care to check out Two more cheap gmake tricks and the other make-related posts in that blog.

提交回复
热议问题