The -n Option of Make Command Does Not Work

The make command provides the -n parameter for debugging makefiles. When make is run with the -n parameter, it only prints the commands that would be executed, but does not actually execute them.

The -n Option of Make Command Does Not Work

For example, with the following makefile, running make all -n

The -n Option of Make Command Does Not Work

will print the commands to be executed but will not actually execute them.

However, if the command contains a + sign or uses ${MAKE}, then the -n option will not take effect. The make tool will still execute that command.

1. Makefile with + Sign

For example, if the command in the makefile starts with a + sign.

The -n Option of Make Command Does Not Work

At this point, when running make -n, the echo command is still executed.

The -n Option of Make Command Does Not Work

2. Makefile with ${MAKE}

For example, in the following makefile, the make command is used to execute another makefile within the all target, but the make command is replaced with the variable MAKE.

The -n Option of Make Command Does Not Work

Running make -n

The -n Option of Make Command Does Not Work

reveals that the command make -f a.make all is executed.

Training Information

The -n Option of Make Command Does Not Work

You can also directly click the URL to access

http://gk.chinaaet.com

The -n Option of Make Command Does Not Work

The -n Option of Make Command Does Not Work

The -n Option of Make Command Does Not Work

Leave a Comment