如何防止“目录已经存在错误”在makefile中使用mkdir时 [英] how to prevent "directory already exists error" in a makefile when using mkdir

查看:1524
本文介绍了如何防止“目录已经存在错误”在makefile中使用mkdir时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的makefile中生成一个目录,尽管我可以很容易地忽略它,但我不希望得到目录已存在的错误。

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.

我主要使用mingw / msys,但是想要在其他shell /系统上工作的东西。

I mainly use mingw/msys but would like something that works across other shells/systems too.

我尝试过这个,但是没有任何想法? / p>

I tried this but it didn't work, any ideas?

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


推荐答案

只需使用:

mkdir -p $(OBJDIR)

如果目录存在,mkdir的-p选项将阻止错误消息。

The -p option to mkdir prevents the error message if the directory exists.

这篇关于如何防止“目录已经存在错误”在makefile中使用mkdir时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆