Just to add to Jack Kellyโs sentence, you can run a test for existence in the CMD.EXE shell. NMake also includes the ability to create a temporary .cmd file and execute it.
Here is an example (n) of the makefile syntax that I use for the purpose of "check-syntax". It checks the syntax in a single C # source file, in a multi-file project, performing compilation.
check-syntax : <<flymake-build.cmd $(CS_SOURCE) SETLOCAL ENABLEDELAYEDEXPANSION set errorlevel= for %%I in (%*) do if NOT x%%I == x$(FLYMAKE_ORIGINAL) ( set filesToBuild=!filesToBuild! %%I ) $(_CSC) /t:module $(LIBSREF) $(FLYMAKE_CHECK) !filesToBuild! ENDLOCAL && exit /b %errorlevel% <<
"flymake-build.cmd" is the name of the temporary cmd file being created. Double angular brackets ( << ) indicate the beginning and end of the content that is included in the temporary file before it starts.
The things after the file name in the first line are the arguments passed to the .cmd file. In this example, the arguments are the contents of a makefile called CS_SOURCE . In my case, this is just a list of file names in the project. File make variables will also be expanded in the text for the temporary file. You can see that I am referring to the compiler ( _CSC ) and some other characters.
Inside the .cmd code, you can do for loops if statements, whatever you like. This is a regular .cmd file.
If you want nmake to respond to errors (for example, interrupted the build) generated by the commands in the .cmd file, then you need to use the exit /b approach to complete cmd.
I found the documentation for this in a dark corner somewhere, so I decided to share it here for a general explanation. ( EDIT : here is the link .)
source share