make: Special Variables

1 
1 6.14 Other Special Variables
1 ============================
1 
1 GNU 'make' supports some variables that have special properties.
1 
1 'MAKEFILE_LIST'
1      Contains the name of each makefile that is parsed by 'make', in the
1      order in which it was parsed.  The name is appended just before
1      'make' begins to parse the makefile.  Thus, if the first thing a
1      makefile does is examine the last word in this variable, it will be
1      the name of the current makefile.  Once the current makefile has
1      used 'include', however, the last word will be the just-included
1      makefile.
1 
1      If a makefile named 'Makefile' has this content:
1 
1           name1 := $(lastword $(MAKEFILE_LIST))
1 
1           include inc.mk
1 
1           name2 := $(lastword $(MAKEFILE_LIST))
1 
1           all:
1                   @echo name1 = $(name1)
1                   @echo name2 = $(name2)
1 
1      then you would expect to see this output:
1 
1           name1 = Makefile
1           name2 = inc.mk
1 
1 '.DEFAULT_GOAL'
1      Sets the default goal to be used if no targets were specified on
1      the command line (⇒Arguments to Specify the Goals Goals.).
1      The '.DEFAULT_GOAL' variable allows you to discover the current
1      default goal, restart the default goal selection algorithm by
1      clearing its value, or to explicitly set the default goal.  The
1      following example illustrates these cases:
1 
1           # Query the default goal.
1           ifeq ($(.DEFAULT_GOAL),)
1             $(warning no default goal is set)
1           endif
1 
1           .PHONY: foo
1           foo: ; @echo $@
1 
1           $(warning default goal is $(.DEFAULT_GOAL))
1 
1           # Reset the default goal.
1           .DEFAULT_GOAL :=
1 
1           .PHONY: bar
1           bar: ; @echo $@
1 
1           $(warning default goal is $(.DEFAULT_GOAL))
1 
1           # Set our own.
1           .DEFAULT_GOAL := foo
1 
1      This makefile prints:
1 
1           no default goal is set
1           default goal is foo
1           default goal is bar
1           foo
1 
1      Note that assigning more than one target name to '.DEFAULT_GOAL' is
1      invalid and will result in an error.
1 
1 'MAKE_RESTARTS'
1      This variable is set only if this instance of 'make' has restarted
1      (⇒How Makefiles Are Remade Remaking Makefiles.): it will
1      contain the number of times this instance has restarted.  Note this
1      is not the same as recursion (counted by the 'MAKELEVEL' variable).
1      You should not set, modify, or export this variable.
1 
1 'MAKE_TERMOUT'
1 'MAKE_TERMERR'
1      When 'make' starts it will check whether stdout and stderr will
1      show their output on a terminal.  If so, it will set 'MAKE_TERMOUT'
1      and 'MAKE_TERMERR', respectively, to the name of the terminal
1      device (or 'true' if this cannot be determined).  If set these
1      variables will be marked for export.  These variables will not be
1      changed by 'make' and they will not be modified if already set.
1 
1      These values can be used (particularly in combination with output
11      synchronization (⇒Output During Parallel Execution Parallel
      Output.) to determine whether 'make' itself is writing to a
1      terminal; they can be tested to decide whether to force recipe
1      commands to generate colorized output for example.
1 
1      If you invoke a sub-'make' and redirect its stdout or stderr it is
1      your responsibility to reset or unexport these variables as well,
1      if your makefiles rely on them.
1 
1 '.RECIPEPREFIX'
1      The first character of the value of this variable is used as the
1      character make assumes is introducing a recipe line.  If the
1      variable is empty (as it is by default) that character is the
1      standard tab character.  For example, this is a valid makefile:
1 
1           .RECIPEPREFIX = >
1           all:
1           > @echo Hello, world
1 
1      The value of '.RECIPEPREFIX' can be changed multiple times; once
1      set it stays in effect for all rules parsed until it is modified.
1 
1 '.VARIABLES'
1      Expands to a list of the _names_ of all global variables defined so
1      far.  This includes variables which have empty values, as well as
11      built-in variables (⇒Variables Used by Implicit Rules
      Implicit Variables.), but does not include any variables which are
1      only defined in a target-specific context.  Note that any value you
1      assign to this variable will be ignored; it will always return its
1      special value.
1 
1 '.FEATURES'
1      Expands to a list of special features supported by this version of
1      'make'.  Possible values include, but are not limited to:
1 
1      'archives'
1           Supports 'ar' (archive) files using special file name syntax.
1           ⇒Using 'make' to Update Archive Files Archives.
1 
1      'check-symlink'
11           Supports the '-L' ('--check-symlink-times') flag.  ⇒
           Summary of Options Options Summary.
1 
1      'else-if'
11           Supports "else if" non-nested conditionals.  ⇒Syntax of
           Conditionals Conditional Syntax.
1 
1      'jobserver'
11           Supports "job server" enhanced parallel builds.  ⇒
           Parallel Execution Parallel.
1 
1      'oneshell'
11           Supports the '.ONESHELL' special target.  ⇒Using One
           Shell One Shell.
1 
1      'order-only'
11           Supports order-only prerequisites.  ⇒Types of
           Prerequisites Prerequisite Types.
1 
1      'second-expansion'
1           Supports secondary expansion of prerequisite lists.
1 
1      'shortest-stem'
1           Uses the "shortest stem" method of choosing which pattern, of
11           multiple applicable options, will be used.  ⇒How Patterns
           Match Pattern Match.
1 
1      'target-specific'
1           Supports target-specific and pattern-specific variable
11           assignments.  ⇒Target-specific Variable Values
           Target-specific.
1 
1      'undefine'
11           Supports the 'undefine' directive.  ⇒Undefine
           Directive.
1 
1      'guile'
1           Has GNU Guile available as an embedded extension language.
1           ⇒GNU Guile Integration Guile Integration.
1 
1      'load'
1           Supports dynamically loadable objects for creating custom
1           extensions.  ⇒Loading Dynamic Objects Loading Objects.
1 
1 '.INCLUDE_DIRS'
1      Expands to a list of directories that 'make' searches for included
1      makefiles (⇒Including Other Makefiles Include.).
1