我试图将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
Makefile Windows - 删除目录(如果存在)
的片段导致它是这样的:
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仍然会抛出错误并停止。
我该如何做这项工作?