Makefile Windows - 删除目录(如果存在)

时间:2015-10-24 14:01:59

标签: if-statement makefile directory exists rmdir

我正在尝试将Makefile移植到Windows(使用GNU Make)。我在删除目录时遇到问题。我发现了关于如何有条件地删除目录的问题(Delete a directory and its files using command line but don't throw error if it doesn't exist),但是我在尝试使用该解决方案时遇到错误,大致翻译为The use of ""doc\html"" is syntactically impermissible in this context

引起它的片段是这样的:

if exists "doc\html\" rmdir /Q /S doc\html

我也试过

cmd /c if exists "doc\html" cmd /c rmdir /Q /S doc\html

cmd /c if exists "doc\html\" cmd /c rmdir /Q /S doc\html

我也试过rmdir /Q /S doc\html 2>nul。这有点儿。错误被重定向,但Make仍会抛出错误并停止。

我该如何做到这一点?

1 个答案:

答案 0 :(得分:3)

命令为exist而不是exists。在我链接的帖子中有一个拼写错误...