Contents|Index|Previous|Next
How the MAKE variable works

Recursive make commands should always use the variable, MAKE, not the explicit command name, ‘make’, as shown in the following example.

subsystem:
        cd subdir; $(MAKE)

The value of this variable is the file name with which make was invoked. If this file name was ‘/bin/make’, then the command executed is ‘cd subdir; /bin/make’. If you use a special version of make to run the top-level makefile, the same special version will be executed for recursive invocations. As a special feature, using the variable, MAKE, in the commands of a rule alters the effects of the ‘-t’ (‘--touch’), ‘-n’ (‘--just-print’), or ‘-q’ (‘--question’) options. Using the MAKE variable has the same effect as using a ‘+’ character at the beginning of the command line. See Instead of executing the commands.

Consider the command ‘make -t’ for example. (The ‘-t’ option marks targets as up to date without actually running any commands; see Instead of executing the commands.) Following the usual definition of ‘-t’, a ‘make -t’ command would create a file named ‘subsystem’ and do nothing else.

What you really want it to do is run ‘cd subdir; make -t’ although that would require executing the command, and ‘-t’ says not to execute commands.

The special feature makes this do what you want: whenever a com-mand line of a rule contains the variable, MAKE, the flags ‘-t’, ‘-n’ and ‘-q’ do not apply to that line. Command lines containing MAKE are executed normally despite the presence of a flag that causes most commands not to be run. The usual MAKEFLAGS mechanism passes the flags to the sub-make (see Communicating options to a sub-make), so that your request to touch the files, or print the commands, is propagated to the subsystem.


Top|Contents|Index|Previous|Next