test我的 Makefile 中既有一个目标,又有一个test在我的项目中调用的目录。在 GNU Make 中,我可以像这样声明它是假的:
.PHONY: all compile test clean docs static
Run Code Online (Sandbox Code Playgroud)
是否可以在 NMake 中做同样的事情?根据http://www.bell-labs.com/project/nmake/tutorial/s6.html,我需要做
test: .VIRTUAL
Run Code Online (Sandbox Code Playgroud)
但它不起作用:
F:\SomePath>nmake test /f msvc.mk
Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
NMAKE : fatal error U1073: don't know how to make '.VIRTUAL'
Stop.
Run Code Online (Sandbox Code Playgroud)
对于那些在 nmake 中寻找解决此缺席 .PHONY 的方法的人:
您可以引入一个肯定是伪目标的目标(即选择一个不匹配任何现有文件/目录的名称)并使其依赖于您的意思是 .PHONY。例如:
test: .phony
dir /b
.phony:
Run Code Online (Sandbox Code Playgroud)
这是输出:
D:\Temp\nmake-phony>nmake
Microsoft (R) Program Maintenance Utility Version 12.00.21005.1
Copyright (C) Microsoft Corporation. All rights reserved.
dir /b
Makefile
test
Run Code Online (Sandbox Code Playgroud)