(make.info)MAKE Variable

Next: Variables/Recursion Up: Recursion

How the `MAKE' Variable Works

   Recursive `make' commands should always use the variable `MAKE', not
the explicit command name `make', as shown here:

             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.

   Also, any arguments that define variable values are added to `MAKE',
so the sub-`make' gets them too.  Thus, if you do `make CFLAGS=-O', so
that all C compilations will be optimized, the sub-`make' is run with
`cd subdir; /bin/make CFLAGS=-O'.

   The `MAKE' variable actually just refers to two other variables
which contain these special values.  In fact, `MAKE' is always defined
the file name with which `make' was invoked (such as `/bin/make',
above).  The variable `MAKEOVERRIDES' contains definitions for the
variables defined on the command line; in the above example, its value
is `CFLAGS=-O'.  If you *do not* want these variable definitions done
in all recursive `make' invocations, you can redefine the
`MAKEOVERRIDES' variable to remove them.  You do this in any of the
normal ways for defining variables: in a makefile (Note: Setting
Variables.); on the command line with an argument like
`MAKEOVERRIDES=' (Note: Overriding Variables.); or with an
environment variable (*note Variables from the Environment:

   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') option.  Using the `MAKE' variable has the same
effect as using a `+' character at the beginning of the command line.
Note: Instead of Executing the Commands.

   Consider the command `make -t' in the above example.  (The `-t'
option marks targets as up to date without actually running any
commands; see Note: Instead of Execution.)  Following the usual
definition of `-t', a `make -t' command in the example would create a
file named `subsystem' and do nothing else.  What you really want it to
do is run `cd subdir; make -t'; but that would require executing the
command, and `-t' says not to execute commands.

   The special feature makes this do what you want: whenever a command
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' (*note Communicating Options to a Sub-`make':
Options/Recursion.), so your request to touch the files, or print the
commands, is propagated to the subsystem.

automatically generated by info2www