views:

79

answers:

2

I have a legacy MS NMAKE Makefile I need to fix a few bugs in.

There are some very long command lines I wish to debug that are being executed using the following NMAKE trick

dep:
    cmd @<<tmpfilename
cmd_args..
<<

When changing the line to

dep:
    echo cmd @<<tmpfilename
cmd_args..
<<

NMAKE complains that the line is too long.

Is there any other trick I can apply in order to view the command line NMAKE is actually executing?

+1  A: 

Normal unix make supports "make -n" to show the commands it would run, for nmake it is "make /n". However, make usually also tries to be smart and will run rules that update dependencies first in any case, even for "-n", so you might try

#dep:
my_test_rule:
    cmd @<<tmpfilename
cmd_args..
<<

and then run "nmake /n my_test_rule" for your debugging.

hlovdal
A: 

In order to keep the temporary file that keeps your command line append the KEEP keyword after the final <<. For example

dep:
    echo cmd @<<tmpfilename
cmd_args..
<<KEEP

In this case after issuing nmake dep a file named tmpfilename will remain, and hold the arguments list cmd_args.

See sample makefile 2 in this MS kd article. This and this (warning:PDF) are explanation of the KEEP and NOKEEP keyword, but I'm not sure if they were written specifically for MS NMAKE.

Elazar Leibovich