Next: , Previous: MAKEFILE_LIST Variable, Up: Makefiles


3.6 Other Special Variables

GNU make also supports other special variables. Unless otherwise documented here, these values lose their special properties if they are set by a makefile or on the command line.

.DEFAULT_GOAL
Sets the default goal to be used if no targets were specified on the command line (see Arguments to Specify the Goals). The .DEFAULT_GOAL variable 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_GOAL is illegal and will result in an error.


MAKE_RESTARTS
This variable is set only if this instance of make has 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 MAKELEVEL variable). You should not set, modify, or export this variable.


.VARIABLES
Expands 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 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.


.FEATURES
Expands to a list of special features supported by this version of make. Possible values include:
`archives'
Supports ar (archive) files using special filename syntax. See Using make to Update Archive Files.
`check-symlink'
Supports the -L (--check-symlink-times) flag. See Summary of Options.
`else-if'
Supports “else if” non-nested conditionals. See Syntax of Conditionals.
`jobserver'
Supports “job server” enhanced parallel builds. See Parallel Execution.
`second-expansion'
Supports secondary expansion of prerequisite lists.
`order-only'
Supports order-only prerequisites. See Types of Prerequisites.
`target-specific'
Supports target-specific and pattern-specific variable assignments. See Target-specific Variable Values.


.INCLUDE_DIRS
Expands to a list of directories that make searches for included makefiles (see Including Other Makefiles).