-1

I am new to scripting language.

I would like to read contents of a text file using NMAKE and display it. Text file contains only single line of data.

I have referred the following links, but its not working for me: Can't figure out how to read file from nmake

Create a variable in a makefile by reading contents of another file

Here is the code snippet:

all :
.copy File1.txt
.copy File2.txt
.exec AddtnlInfo.bat  #This batch file generates INFO.TXT file
#TODO - Read INFO.TXT file, display its contents and perform copy operation

Thanks, Raja

Joseph Quinsey
  • 9,553
  • 10
  • 54
  • 77
Raja
  • 61
  • 1
  • 5

1 Answers1

0

To properly answer the question we really need to know more, such as when you want to display the contents of the file. A Makefile is not the same as writing in a scripting language - It does contain scripting language statements, but that is not the same as the purpose of a Makefile. A Makefile is to sequence the execution of statements written in another scripting language. The sequencing is to create files based on the dates and times of other files. Further Microsoft NMAKE is not the same as Make in various detailed ways (but in concept it is the same).

If the display of the contents of the file is linked to the creation of some file, then the answer is easy. If you want to display the text file every time the Makefile is executed then the solution might be very difficult. To just say Welcome to my Makefile from a file is harder than it seems. We have to know why you want to do this, so we can see if there is an alternate solution.

To display a text file is easy, as the commands in a an NMAKE script are Windows batch file commands. To display a file one uses the type filename command:

all:
     echo The file contains:
     type filename

But this is probably not what you want.

Your second link to another article is not useful as this is about generic Makefiles in a linux context and not about NMAKE on a Windows platform, and thus would be no help to you.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • Thanks Brian!!! The text file contains name/path of an XML file which is provided by another batch script. For example, TEST.MAK file contains series of statements that copies files from source to destionation, this make file executes a batch file(which inturn creates INFO.TXT that contains name of the XML file) TEST.MAK should read INFO.TXT and display the information and also copy the XML file to destination. – Raja Jan 12 '15 at 10:18
  • 1
    Your description is still not clear enough for a solution to be provided. Edit your question to supply code examples. – Brian Tompsett - 汤莱恩 Jan 12 '15 at 10:52
  • Here is the code snippet: all : .copy File1.txt .copy File2.txt .exec AddtnlInfo.bat #This batch file generates INFO.TXT file #TODO - Read INFO.TXT file, display its contents and perform copy operation – Raja Jan 12 '15 at 11:28