| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
6.14 Other Special Variables
GNU make supports some variables that have special properties.
MAKEFILE_LISTContains the name of each makefile that is parsed by
make, in the order in which it was parsed. The name is appended just beforemakebegins 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 usedinclude, however, the last word will be the just-included makefile.If a makefile named
Makefilehas 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_GOALSets the default goal to be used if no targets were specified on the command line (see section Arguments to Specify the Goals). The
.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
.DEFAULT_GOALis invalid and will result in an error.MAKE_RESTARTSThis variable is set only if this instance of
makehas restarted (see section 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 theMAKELEVELvariable). You should not set, modify, or export this variable..RECIPEPREFIXThe first character of the value of this variable is used as the character make assumes is introducing a recipe line. If the variable is empty (as it is by default) that character is the standard tab character. For example, this is a valid makefile:
.RECIPEPREFIX = > all: > @echo Hello, world
The value of
.RECIPEPREFIXcan be changed multiple times; once set it stays in effect for all rules parsed until it is modified..VARIABLESExpands to a list of the names of all global variables defined so far. This includes variables which have empty values, as well as built-in variables (see section Variables Used by Implicit Rules), but does not include any variables which are only defined in a target-specific context. Note that any value you assign to this variable will be ignored; it will always return its special value.
.FEATURESExpands to a list of special features supported by this version of
make. Possible values include, but are not limited to:- ‘archives’
Supports
ar(archive) files using special file name syntax. See section Usingmaketo Update Archive Files.- ‘check-symlink’
Supports the
-L(--check-symlink-times) flag. See section Summary of Options.- ‘else-if’
Supports “else if” non-nested conditionals. See section Syntax of Conditionals.
- ‘jobserver’
Supports “job server” enhanced parallel builds. See section Parallel Execution.
- ‘oneshell’
Supports the
.ONESHELLspecial target. See section Using One Shell.- ‘order-only’
Supports order-only prerequisites. See section Types of Prerequisites.
- ‘second-expansion’
Supports secondary expansion of prerequisite lists.
- ‘shortest-stem’
Uses the “shortest stem” method of choosing which pattern, of multiple applicable options, will be used. See section How Patterns Match.
- ‘target-specific’
Supports target-specific and pattern-specific variable assignments. See section Target-specific Variable Values.
- ‘undefine’
Supports the
undefinedirective. See section Undefining Variables.- ‘guile’
Has GNU Guile available as an embedded extension language. See section GNU Guile Integration.
- ‘load’
Supports dynamically loadable objects for creating custom extensions. See section Loading Dynamic Objects.
.INCLUDE_DIRSExpands to a list of directories that
makesearches for included makefiles (see section Including Other Makefiles).
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on October 10, 2013 using texi2html 5.0.
