Search code examples
nmake

Can't figure out how to read file from nmake


I am doing something like this:

all: 
    @SET /p filecontent= < somefile.txt
    @echo %filecontent%

However the filecontent variable does not seem to hold the contents of the file somefile.txt.


Solution

  • Simply ensure somefile.txt is in acceptable nmake syntax, and then !include it. Thus:

    c:>type somefile.txt
    PASSWORD=secret
    c:>type makefile
    !INCLUDE somefile.txt
    !MESSAGE Password is [$(PASSWORD)]
    c:>nmake -nologo
    Password is [secret]