gpt4 book ai didi

makefile - 使用 mkdir 时如何防止 makefile 中出现 "directory already exists error"

转载 作者:行者123 更新时间:2023-12-03 04:43:33 25 4
gpt4 key购买 nike

我需要在我的 makefile 中生成一个目录,并且我不想一遍又一遍地收到“目录已存在错误”,即使我可以轻松忽略它。

我主要使用 mingw/msys,但也希望能在其他 shell/系统上工作。

我尝试过,但没有成功,有什么想法吗?

ifeq (,$(findstring $(OBJDIR),$(wildcard $(OBJDIR) )))
-mkdir $(OBJDIR)
endif

最佳答案

在 UNIX 上只需使用这个:

mkdir -p $(OBJDIR)

如果目录存在,mkdir 的 -p 选项可防止出现错误消息。

关于makefile - 使用 mkdir 时如何防止 makefile 中出现 "directory already exists error",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/99132/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com