NMake .PHONY analogue

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

Is it possible to do the same in NMake? According to, I need to do

test: .VIRTUAL

but it doesn't work:

F:\SomePath>nmake test /f

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'


  • I think this is what you are looking for:


    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.

    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.

    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:

    Tutorial: A Little Help With Alcatel-Lucent nmake

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