本文介绍了NMake .PHONY类似物的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Makefile中有一个目标test,在我的项目中有一个名为test的目录.在GNU Make中,我可以这样声明它是假的:

I have both a target test in my Makefile and a directory called test in my project. In GNU Make I can declare it to be phony like this:

.PHONY: all compile test clean docs static

是否可以在NMake中执行相同的操作?根据 http://www.bell-labs.com/project/nmake /tutorial/s6.html ,我需要做

Is it possible to do the same in NMake? According to http://www.bell-labs.com/project/nmake/tutorial/s6.html, I need to do

test: .VIRTUAL

但它不起作用:

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.

推荐答案

我认为这是您要寻找的:

I think this is what you are looking for:

http://msdn.microsoft. com/en-us/library/7sb2acw1%28v = VS.71%29.aspx

伪目标是在依赖关系行中代替文件名使用的标签.它被解释为不存在的文件,因此已过期. NMAKE假定伪目标的时间戳是其所有依赖项中的最新时间戳.如果没有依赖项,则假定为当前时间.如果将伪目标用作目标,则始终执行其命令.用作依赖项的伪目标还必须在另一个依赖项中显示为目标.但是,该依赖项不需要具有命令块.

A pseudotarget is a label used in place of a filename in a dependency line. It is interpreted as a file that does not exist, and so is out-of-date. NMAKE assumes a pseudotarget's timestamp is the most recent of all its dependents. If it has no dependents, the current time is assumed. If a pseudotarget is used as a target, its commands are always executed. A pseudotarget used as a dependent must also appear as a target in another dependency. However, that dependency does not need to have a commands block.

伪目标名称遵循目标的文件名语法规则.但是,如果名称没有扩展名(即不包含句点),则它可以超过文件名的8个字符的限制,并且最长可以为256个字符.

Pseudotarget names follow the filename syntax rules for targets. However, if the name does not have an extension (that is, does not contain a period), it can exceed the 8-character limit for filenames and can be up to 256 characters long.

如果我正确理解,您在nmake中没有.PHONY(Microsoft,那里有很多nmake口味).并且您发布的链接顶部指出:

If i understand it correctly you don't have a .PHONY in nmake (Microsoft's, there are many nmake flavors out there). And the link you posted states that on top:

也许您可以打一个测试,再打另一个测试?

Maybe you could call one test and the other one tests?

这篇关于NMake .PHONY类似物的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-28 16:56