Question

I can use @if exist to test a file does exist or not, but did not find the document via Google. For example, in my makefile for nmake ;

clean: 
    @if exist $(BIN_DIR) rmdir /S /Q $(BIN_DIR)
    @if exist $(OBJ_DIR) rmdir /S /Q $(OBJ_DIR)
Was it helpful?

Solution

You won't find any documentation regarding "@if exist" in nmake documentation. These are plain shell commands.

So just open a cmd window and at the prompt enter "help if". By the way the "@" sign suppresses the echo in a shell script.

Thats's why most of .bat scripts start with "@echo off".

OTHER TIPS

You can find nmake documentation here (I'm surprised you did not find it):

VS 2012:

http://msdn.microsoft.com/en-us/library/dd9y37ha.aspx

VS 2010:

http://msdn.microsoft.com/en-us/library/dd9y37ha(v=vs.100).aspx

VS 2008:

http://msdn.microsoft.com/en-us/library/dd9y37ha(v=vs.90).aspx

Earlier versions are also available but nmake has not changed much.

Variables that are accessed using the $(VARNAME) syntax are either environment variables, or variables declared inside the makefile itself.

Here's a really simple makefile that declares a variable, and the single rule (ALL) ouputs the PATH (from the environment) then the locally-declared variable.

MY_VAR=12345
ALL:
  @echo $(PATH)   $(MY_VAR)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top