make: Quick Reference
1
1 Appendix A Quick Reference
1 **************************
1
1 This appendix summarizes the directives, text manipulation functions,
11 and special variables which GNU 'make' understands. ⇒Special
Targets, ⇒Catalogue of Built-In Rules Catalogue of Rules, and
1 ⇒Summary of Options Options Summary, for other summaries.
1
1 Here is a summary of the directives GNU 'make' recognizes:
1
1 'define VARIABLE'
1 'define VARIABLE ='
1 'define VARIABLE :='
1 'define VARIABLE ::='
1 'define VARIABLE +='
1 'define VARIABLE ?='
1 'endef'
1 Define multi-line variables.
1 ⇒Multi-Line.
1
1 'undefine VARIABLE'
1 Undefining variables.
1 ⇒Undefine Directive.
1
1 'ifdef VARIABLE'
1 'ifndef VARIABLE'
1 'ifeq (A,B)'
1 'ifeq "A" "B"'
1 'ifeq 'A' 'B''
1 'ifneq (A,B)'
1 'ifneq "A" "B"'
1 'ifneq 'A' 'B''
1 'else'
1 'endif'
1 Conditionally evaluate part of the makefile.
1 ⇒Conditionals.
1
1 'include FILE'
1 '-include FILE'
1 'sinclude FILE'
1 Include another makefile.
1 ⇒Including Other Makefiles Include.
1
1 'override VARIABLE-ASSIGNMENT'
1 Define a variable, overriding any previous definition, even one
1 from the command line.
1 ⇒The 'override' Directive Override Directive.
1
1 'export'
1 Tell 'make' to export all variables to child processes by default.
1 ⇒Communicating Variables to a Sub-'make' Variables/Recursion.
1
1 'export VARIABLE'
1 'export VARIABLE-ASSIGNMENT'
1 'unexport VARIABLE'
1 Tell 'make' whether or not to export a particular variable to child
1 processes.
1 ⇒Communicating Variables to a Sub-'make' Variables/Recursion.
1
1 'private VARIABLE-ASSIGNMENT'
1 Do not allow this variable assignment to be inherited by
1 prerequisites.
1 ⇒Suppressing Inheritance.
1
1 'vpath PATTERN PATH'
1 Specify a search path for files matching a '%' pattern.
1 ⇒The 'vpath' Directive Selective Search.
1
1 'vpath PATTERN'
1 Remove all search paths previously specified for PATTERN.
1
1 'vpath'
1 Remove all search paths previously specified in any 'vpath'
1 directive.
1
1 Here is a summary of the built-in functions (⇒Functions):
1
1 '$(subst FROM,TO,TEXT)'
1 Replace FROM with TO in TEXT.
11 ⇒Functions for String Substitution and Analysis Text
Functions.
1
1 '$(patsubst PATTERN,REPLACEMENT,TEXT)'
1 Replace words matching PATTERN with REPLACEMENT in TEXT.
11 ⇒Functions for String Substitution and Analysis Text
Functions.
1
1 '$(strip STRING)'
1 Remove excess whitespace characters from STRING.
11 ⇒Functions for String Substitution and Analysis Text
Functions.
1
1 '$(findstring FIND,TEXT)'
1 Locate FIND in TEXT.
11 ⇒Functions for String Substitution and Analysis Text
Functions.
1
1 '$(filter PATTERN...,TEXT)'
1 Select words in TEXT that match one of the PATTERN words.
11 ⇒Functions for String Substitution and Analysis Text
Functions.
1
1 '$(filter-out PATTERN...,TEXT)'
1 Select words in TEXT that _do not_ match any of the PATTERN words.
11 ⇒Functions for String Substitution and Analysis Text
Functions.
1
1 '$(sort LIST)'
1 Sort the words in LIST lexicographically, removing duplicates.
11 ⇒Functions for String Substitution and Analysis Text
Functions.
1
1 '$(word N,TEXT)'
1 Extract the Nth word (one-origin) of TEXT.
11 ⇒Functions for String Substitution and Analysis Text
Functions.
1
1 '$(words TEXT)'
1 Count the number of words in TEXT.
11 ⇒Functions for String Substitution and Analysis Text
Functions.
1
1 '$(wordlist S,E,TEXT)'
1 Returns the list of words in TEXT from S to E.
11 ⇒Functions for String Substitution and Analysis Text
Functions.
1
1 '$(firstword NAMES...)'
1 Extract the first word of NAMES.
11 ⇒Functions for String Substitution and Analysis Text
Functions.
1
1 '$(lastword NAMES...)'
1 Extract the last word of NAMES.
11 ⇒Functions for String Substitution and Analysis Text
Functions.
1
1 '$(dir NAMES...)'
1 Extract the directory part of each file name.
1 ⇒Functions for File Names File Name Functions.
1
1 '$(notdir NAMES...)'
1 Extract the non-directory part of each file name.
1 ⇒Functions for File Names File Name Functions.
1
1 '$(suffix NAMES...)'
1 Extract the suffix (the last '.' and following characters) of each
1 file name.
1 ⇒Functions for File Names File Name Functions.
1
1 '$(basename NAMES...)'
1 Extract the base name (name without suffix) of each file name.
1 ⇒Functions for File Names File Name Functions.
1
1 '$(addsuffix SUFFIX,NAMES...)'
1 Append SUFFIX to each word in NAMES.
1 ⇒Functions for File Names File Name Functions.
1
1 '$(addprefix PREFIX,NAMES...)'
1 Prepend PREFIX to each word in NAMES.
1 ⇒Functions for File Names File Name Functions.
1
1 '$(join LIST1,LIST2)'
1 Join two parallel lists of words.
1 ⇒Functions for File Names File Name Functions.
1
1 '$(wildcard PATTERN...)'
1 Find file names matching a shell file name pattern (_not_ a '%'
1 pattern).
1 ⇒The Function 'wildcard' Wildcard Function.
1
1 '$(realpath NAMES...)'
1 For each file name in NAMES, expand to an absolute name that does
1 not contain any '.', '..', nor symlinks.
1 ⇒Functions for File Names File Name Functions.
1
1 '$(abspath NAMES...)'
1 For each file name in NAMES, expand to an absolute name that does
1 not contain any '.' or '..' components, but preserves symlinks.
1 ⇒Functions for File Names File Name Functions.
1
1 '$(error TEXT...)'
1 When this function is evaluated, 'make' generates a fatal error
1 with the message TEXT.
1 ⇒Functions That Control Make Make Control Functions.
1
1 '$(warning TEXT...)'
1 When this function is evaluated, 'make' generates a warning with
1 the message TEXT.
1 ⇒Functions That Control Make Make Control Functions.
1
1 '$(shell COMMAND)'
1 Execute a shell command and return its output.
1 ⇒The 'shell' Function Shell Function.
1
1 '$(origin VARIABLE)'
1 Return a string describing how the 'make' variable VARIABLE was
1 defined.
1 ⇒The 'origin' Function Origin Function.
1
1 '$(flavor VARIABLE)'
1 Return a string describing the flavor of the 'make' variable
1 VARIABLE.
1 ⇒The 'flavor' Function Flavor Function.
1
1 '$(foreach VAR,WORDS,TEXT)'
1 Evaluate TEXT with VAR bound to each word in WORDS, and concatenate
1 the results.
1 ⇒The 'foreach' Function Foreach Function.
1
1 '$(if CONDITION,THEN-PART[,ELSE-PART])'
1 Evaluate the condition CONDITION; if it's non-empty substitute the
1 expansion of the THEN-PART otherwise substitute the expansion of
1 the ELSE-PART.
1 ⇒Functions for Conditionals Conditional Functions.
1
1 '$(or CONDITION1[,CONDITION2[,CONDITION3...]])'
1 Evaluate each condition CONDITIONN one at a time; substitute the
1 first non-empty expansion. If all expansions are empty, substitute
1 the empty string.
1 ⇒Functions for Conditionals Conditional Functions.
1
1 '$(and CONDITION1[,CONDITION2[,CONDITION3...]])'
1 Evaluate each condition CONDITIONN one at a time; if any expansion
1 results in the empty string substitute the empty string. If all
1 expansions result in a non-empty string, substitute the expansion
1 of the last CONDITION.
1 ⇒Functions for Conditionals Conditional Functions.
1
1 '$(call VAR,PARAM,...)'
1 Evaluate the variable VAR replacing any references to '$(1)',
1 '$(2)' with the first, second, etc. PARAM values.
1 ⇒The 'call' Function Call Function.
1
1 '$(eval TEXT)'
1 Evaluate TEXT then read the results as makefile commands. Expands
1 to the empty string.
1 ⇒The 'eval' Function Eval Function.
1
1 '$(file OP FILENAME,TEXT)'
1 Expand the arguments, then open the file FILENAME using mode OP and
1 write TEXT to that file.
1 ⇒The 'file' Function File Function.
1
1 '$(value VAR)'
1 Evaluates to the contents of the variable VAR, with no expansion
1 performed on it.
1 ⇒The 'value' Function Value Function.
1
11 Here is a summary of the automatic variables. ⇒Automatic
Variables, for full information.
1
1 '$@'
1 The file name of the target.
1
1 '$%'
1 The target member name, when the target is an archive member.
1
1 '$<'
1 The name of the first prerequisite.
1
1 '$?'
1 The names of all the prerequisites that are newer than the target,
1 with spaces between them. For prerequisites which are archive
1 members, only the named member is used (⇒Archives).
1
1 '$^'
1 '$+'
1 The names of all the prerequisites, with spaces between them. For
1 prerequisites which are archive members, only the named member is
1 used (⇒Archives). The value of '$^' omits duplicate
1 prerequisites, while '$+' retains them and preserves their order.
1
1 '$*'
11 The stem with which an implicit rule matches (⇒How Patterns
Match Pattern Match.).
1
1 '$(@D)'
1 '$(@F)'
1 The directory part and the file-within-directory part of '$@'.
1
1 '$(*D)'
1 '$(*F)'
1 The directory part and the file-within-directory part of '$*'.
1
1 '$(%D)'
1 '$(%F)'
1 The directory part and the file-within-directory part of '$%'.
1
1 '$(<D)'
1 '$(<F)'
1 The directory part and the file-within-directory part of '$<'.
1
1 '$(^D)'
1 '$(^F)'
1 The directory part and the file-within-directory part of '$^'.
1
1 '$(+D)'
1 '$(+F)'
1 The directory part and the file-within-directory part of '$+'.
1
1 '$(?D)'
1 '$(?F)'
1 The directory part and the file-within-directory part of '$?'.
1
1 These variables are used specially by GNU 'make':
1
1 'MAKEFILES'
1
1 Makefiles to be read on every invocation of 'make'.
1 ⇒The Variable 'MAKEFILES' MAKEFILES Variable.
1
1 'VPATH'
1
1 Directory search path for files not found in the current directory.
1 ⇒'VPATH' Search Path for All Prerequisites General Search.
1
1 'SHELL'
1
1 The name of the system default command interpreter, usually
1 '/bin/sh'. You can set 'SHELL' in the makefile to change the shell
1 used to run recipes. ⇒Recipe Execution Execution. The
1 'SHELL' variable is handled specially when importing from and
1 exporting to the environment. ⇒Choosing the Shell.
1
1 'MAKESHELL'
1
1 On MS-DOS only, the name of the command interpreter that is to be
1 used by 'make'. This value takes precedence over the value of
1 'SHELL'. ⇒MAKESHELL variable Execution.
1
1 'MAKE'
1
1 The name with which 'make' was invoked. Using this variable in
11 recipes has special meaning. ⇒How the 'MAKE' Variable Works
MAKE Variable.
1
1 'MAKE_VERSION'
1
1 The built-in variable 'MAKE_VERSION' expands to the version number
1 of the GNU 'make' program.
1
1 'MAKE_HOST'
1
1 The built-in variable 'MAKE_HOST' expands to a string representing
1 the host that GNU 'make' was built to run on.
1
1 'MAKELEVEL'
1
1 The number of levels of recursion (sub-'make's).
1 ⇒Variables/Recursion.
1
1 'MAKEFLAGS'
1
1 The flags given to 'make'. You can set this in the environment or
1 a makefile to set flags.
1 ⇒Communicating Options to a Sub-'make' Options/Recursion.
1
1 It is _never_ appropriate to use 'MAKEFLAGS' directly in a recipe
1 line: its contents may not be quoted correctly for use in the
1 shell. Always allow recursive 'make''s to obtain these values
1 through the environment from its parent.
1
1 'GNUMAKEFLAGS'
1
1 Other flags parsed by 'make'. You can set this in the environment
1 or a makefile to set 'make' command-line flags. GNU 'make' never
1 sets this variable itself. This variable is only needed if you'd
1 like to set GNU 'make'-specific flags in a POSIX-compliant
1 makefile. This variable will be seen by GNU 'make' and ignored by
1 other 'make' implementations. It's not needed if you only use GNU
11 'make'; just use 'MAKEFLAGS' directly. ⇒Communicating Options
to a Sub-'make' Options/Recursion.
1
1 'MAKECMDGOALS'
1
1 The targets given to 'make' on the command line. Setting this
1 variable has no effect on the operation of 'make'.
1 ⇒Arguments to Specify the Goals Goals.
1
1 'CURDIR'
1
1 Set to the absolute pathname of the current working directory
1 (after all '-C' options are processed, if any). Setting this
1 variable has no effect on the operation of 'make'.
1 ⇒Recursive Use of 'make' Recursion.
1
1 'SUFFIXES'
1
1 The default list of suffixes before 'make' reads any makefiles.
1
1 '.LIBPATTERNS'
1 Defines the naming of the libraries 'make' searches for, and their
1 order.
1 ⇒Directory Search for Link Libraries Libraries/Search.
1