make supports some variables that have special properties.
make, in the order in which it was parsed. The name is appended just before
makebegins to parse the makefile. Thus, if the first thing a makefile does is examine the last word in this variable, it will be the name of the current makefile. Once the current makefile has used
include, however, the last word will be the just-included makefile.
If a makefile named
Makefile has this content:
name1 := $(lastword $(MAKEFILE_LIST)) include inc.mk name2 := $(lastword $(MAKEFILE_LIST)) all: @echo name1 = $(name1) @echo name2 = $(name2)
then you would expect to see this output:
name1 = Makefile name2 = inc.mk
.DEFAULT_GOALvariable allows you to discover the current default goal, restart the default goal selection algorithm by clearing its value, or to explicitly set the default goal. The following example illustrates these cases:
# Query the default goal. ifeq ($(.DEFAULT_GOAL),) $(warning no default goal is set) endif .PHONY: foo foo: ; @echo $@ $(warning default goal is $(.DEFAULT_GOAL)) # Reset the default goal. .DEFAULT_GOAL := .PHONY: bar bar: ; @echo $@ $(warning default goal is $(.DEFAULT_GOAL)) # Set our own. .DEFAULT_GOAL := foo
This makefile prints:
no default goal is set default goal is foo default goal is bar foo
Note that assigning more than one target name to
invalid and will result in an error.
makehas restarted (see How Makefiles Are Remade): it will contain the number of times this instance has restarted. Note this is not the same as recursion (counted by the
MAKELEVELvariable). You should not set, modify, or export this variable.
.RECIPEPREFIX = > all: > @echo Hello, world
The value of
.RECIPEPREFIX can be changed multiple times; once set
it stays in effect for all rules parsed until it is modified.
make. Possible values include, but are not limited to:
ar(archive) files using special file name syntax. See Using
maketo Update Archive Files.
--check-symlink-times) flag. See Summary of Options.
.ONESHELLspecial target. See Using One Shell.
undefinedirective. See Undefine Directive.
makesearches for included makefiles (see Including Other Makefiles).