Cheeso
Cheeso

Reputation: 192577

nmake: can a batch file run as part of a make command block, affect the environment of the nmake.exe process?

I think in nmake if I do this:

 example :
        set value=77
        echo %%value%%

The result will display 77 on the console.

Is there a way for me to invoke a .cmd or .bat file that will affect the environment of the nmake.exe process? Suppose I put the statement set value=77 in a file called "setvalue.cmd". Then change the makefile to this:

 example :
        setvalue
        echo %%value%%

I get:

%value%

Alternatively, if there's a way to set a macro within a command block, that would also work. Or, a way to set the value of a macro from a batch file, even outside a command block.

Upvotes: 3

Views: 2390

Answers (2)

bobbogo
bobbogo

Reputation: 15493

You can create an nmake snippet during makefile pre-processing, and read that in. Assuming batch.cmd outputs valid nmake syntax, then

!if [batch.cmd >makefile.auto]
!error *** Could not create makefile.auto
!endif
!include makefile.auto

You should ensure batch.cmd sets %errorlevel% appropriately (e.g., exit /b 22).

makefile.auto can contain anything, but you would probably want stuff like value=77. A couple of points:

  • Dereference value using nmake syntax ($(value))
  • You can pass parameters to batch.cmd if necessary ([batch.cmd $(OBJECTS) >makefile.auto])

Upvotes: 5

Cheeso
Cheeso

Reputation: 192577

No, I don't think so.

Upvotes: -2

Related Questions