NMAKE Macros Cannot Expand to Multiple Command LinesLast reviewed: February 28, 1995Article ID: Q70146 |
The information in this article applies to:
SUMMARYNMAKE does not support using a macro to substitute for more than one command line in a makefile. An attempt to use a macro in this way fails when NMAKE treats the macro expansion as one long concatenated command line.
MORE INFORMATIONA makefile can contain many description blocks, each of which contain the same sequence of commands. Therefore, it would be useful to use a macro instead of the multiple commands shared between description blocks. For example, your makefile might somewhat resemble to sample makefile below. The macro in that makefile is designed to expand to the commands CLS (clear screen) and DIR (directory). However, when this makefile runs, the DIR command does not run because the command line passed to the system is as follows:
CLS <cr/lf> DIRwhere <cr/lf> denotes a carriage return and a line feed character. One method that effectively avoids repeating many command sequences in your makefile involved creating a batch file that contains the commands. The makefile calls the batch file when these commands are required. In addition, in OS/2, you can specify more than one command on a line by separating the commands with an ampersand (&) character. Under Windows NT, you can execute multiple commands by separating them with a &&.
Sample Makefile# This makefile attempts to clear the screen and request a directory # listing by expanding one macro. However, the DIR command is not # executed. CMDS = CLS ^ DIRshowdir: $(CMDS)In order to achieve this on Windows NT, use
Sample Makefile# # This works on Windows NT # CMDS = CLS && DIR showdir: $(CMDS) |
Additional reference words: kbinf kbinf 1.10 1.20 1.30 1.40 1.50
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |