Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

nmake

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.

like image 929
Cheeso Avatar asked Nov 24 '25 00:11

Cheeso


1 Answers

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])
like image 193
bobbogo Avatar answered Nov 27 '25 22:11

bobbogo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!