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

前端 未结 12 1664
遇见更好的自我
遇见更好的自我 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:17

    $(OBJDIR):
        mkdir $@
    

    Which also works for multiple directories, e.g..

    OBJDIRS := $(sort $(dir $(OBJECTS)))
    
    $(OBJDIRS):
        mkdir $@
    

    Adding $(OBJDIR) as the first target works well.

提交回复
热议问题