[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Appendix A Quick Reference
This appendix summarizes the directives, text manipulation functions,
and special variables which GNU make
understands.
See section Special Built-in Target Names, Catalogue of Implicit Rules,
and Summary of Options,
for other summaries.
Here is a summary of the directives GNU make
recognizes:
define variable
define variable =
define variable :=
define variable ::=
define variable +=
define variable ?=
endef
Define multi-line variables.
See section Defining Multi-Line Variables.undefine variable
Undefining variables.
See section Undefining Variables.ifdef variable
ifndef variable
ifeq (a,b)
ifeq "a" "b"
ifeq 'a' 'b'
ifneq (a,b)
ifneq "a" "b"
ifneq 'a' 'b'
else
endif
Conditionally evaluate part of the makefile.
See section Conditional Parts of Makefiles.include file
-include file
sinclude file
Include another makefile.
See section Including Other Makefiles.override variable-assignment
Define a variable, overriding any previous definition, even one from the command line.
See section Theoverride
Directive.export
Tell
make
to export all variables to child processes by default.
See section Communicating Variables to a Sub-make
.export variable
export variable-assignment
unexport variable
Tell
make
whether or not to export a particular variable to child processes.
See section Communicating Variables to a Sub-make
.private variable-assignment
Do not allow this variable assignment to be inherited by prerequisites.
See section Suppressing Inheritance.vpath pattern path
Specify a search path for files matching a ‘%’ pattern.
See section Thevpath
Directive.vpath pattern
Remove all search paths previously specified for pattern.
vpath
Remove all search paths previously specified in any
vpath
directive.
Here is a summary of the built-in functions (see section Functions for Transforming Text):
$(subst from,to,text)
Replace from with to in text.
See section Functions for String Substitution and Analysis.$(patsubst pattern,replacement,text)
Replace words matching pattern with replacement in text.
See section Functions for String Substitution and Analysis.$(strip string)
Remove excess whitespace characters from string.
See section Functions for String Substitution and Analysis.$(findstring find,text)
Locate find in text.
See section Functions for String Substitution and Analysis.$(filter pattern…,text)
Select words in text that match one of the pattern words.
See section Functions for String Substitution and Analysis.$(filter-out pattern…,text)
Select words in text that do not match any of the pattern words.
See section Functions for String Substitution and Analysis.$(sort list)
Sort the words in list lexicographically, removing duplicates.
See section Functions for String Substitution and Analysis.$(word n,text)
Extract the nth word (one-origin) of text.
See section Functions for String Substitution and Analysis.$(words text)
Count the number of words in text.
See section Functions for String Substitution and Analysis.$(wordlist s,e,text)
Returns the list of words in text from s to e.
See section Functions for String Substitution and Analysis.$(firstword names…)
Extract the first word of names.
See section Functions for String Substitution and Analysis.$(lastword names…)
Extract the last word of names.
See section Functions for String Substitution and Analysis.$(dir names…)
Extract the directory part of each file name.
See section Functions for File Names.$(notdir names…)
Extract the non-directory part of each file name.
See section Functions for File Names.$(suffix names…)
Extract the suffix (the last ‘.’ and following characters) of each file name.
See section Functions for File Names.$(basename names…)
Extract the base name (name without suffix) of each file name.
See section Functions for File Names.$(addsuffix suffix,names…)
Append suffix to each word in names.
See section Functions for File Names.$(addprefix prefix,names…)
Prepend prefix to each word in names.
See section Functions for File Names.$(join list1,list2)
Join two parallel lists of words.
See section Functions for File Names.$(wildcard pattern…)
Find file names matching a shell file name pattern (not a ‘%’ pattern).
See section The Functionwildcard
.$(realpath names…)
For each file name in names, expand to an absolute name that does not contain any
.
,..
, nor symlinks.
See section Functions for File Names.$(abspath names…)
For each file name in names, expand to an absolute name that does not contain any
.
or..
components, but preserves symlinks.
See section Functions for File Names.$(error text…)
When this function is evaluated,
make
generates a fatal error with the message text.
See section Functions That Control Make.$(warning text…)
When this function is evaluated,
make
generates a warning with the message text.
See section Functions That Control Make.$(shell command)
Execute a shell command and return its output.
See section Theshell
Function.$(origin variable)
Return a string describing how the
make
variable variable was defined.
See section Theorigin
Function.$(flavor variable)
Return a string describing the flavor of the
make
variable variable.
See section Theflavor
Function.$(foreach var,words,text)
Evaluate text with var bound to each word in words, and concatenate the results.
See section Theforeach
Function.$(if condition,then-part[,else-part])
Evaluate the condition condition; if it’s non-empty substitute the expansion of the then-part otherwise substitute the expansion of the else-part.
See section Functions for Conditionals.$(or condition1[,condition2[,condition3…]])
Evaluate each condition conditionN one at a time; substitute the first non-empty expansion. If all expansions are empty, substitute the empty string.
See section Functions for Conditionals.$(and condition1[,condition2[,condition3…]])
Evaluate each condition conditionN one at a time; if any expansion results in the empty string substitute the empty string. If all expansions result in a non-empty string, substitute the expansion of the last condition.
See section Functions for Conditionals.$(call var,param,…)
Evaluate the variable var replacing any references to
$(1)
,$(2)
with the first, second, etc. param values.
See section Thecall
Function.$(eval text)
Evaluate text then read the results as makefile commands. Expands to the empty string.
See section Theeval
Function.$(file op filename,text)
Expand the arguments, then open the file filename using mode op and write text to that file.
See section Thefile
Function.$(value var)
Evaluates to the contents of the variable var, with no expansion performed on it.
See section Thevalue
Function.
Here is a summary of the automatic variables. See section Automatic Variables, for full information.
$@
The file name of the target.
$%
The target member name, when the target is an archive member.
$<
The name of the first prerequisite.
$?
The names of all the prerequisites that are newer than the target, with spaces between them. For prerequisites which are archive members, only the named member is used (see section Using
make
to Update Archive Files).$^
$+
The names of all the prerequisites, with spaces between them. For prerequisites which are archive members, only the named member is used (see section Using
make
to Update Archive Files). The value of$^
omits duplicate prerequisites, while$+
retains them and preserves their order.$*
The stem with which an implicit rule matches (see section How Patterns Match).
$(@D)
$(@F)
The directory part and the file-within-directory part of
$@
.$(*D)
$(*F)
The directory part and the file-within-directory part of
$*
.$(%D)
$(%F)
The directory part and the file-within-directory part of
$%
.$(<D)
$(<F)
The directory part and the file-within-directory part of
$<
.$(^D)
$(^F)
The directory part and the file-within-directory part of
$^
.$(+D)
$(+F)
The directory part and the file-within-directory part of
$+
.$(?D)
$(?F)
The directory part and the file-within-directory part of
$?
.
These variables are used specially by GNU make
:
MAKEFILES
-
Makefiles to be read on every invocation of
make
.
See section The VariableMAKEFILES
. VPATH
-
Directory search path for files not found in the current directory.
See sectionVPATH
Search Path for All Prerequisites. SHELL
-
The name of the system default command interpreter, usually ‘/bin/sh’. You can set
SHELL
in the makefile to change the shell used to run recipes. See section Recipe Execution. TheSHELL
variable is handled specially when importing from and exporting to the environment. See section Choosing the Shell. MAKESHELL
-
On MS-DOS only, the name of the command interpreter that is to be used by
make
. This value takes precedence over the value ofSHELL
. See section MAKESHELL variable. MAKE
-
The name with which
make
was invoked. Using this variable in recipes has special meaning. See section How theMAKE
Variable Works. MAKE_VERSION
-
The built-in variable ‘MAKE_VERSION’ expands to the version number of the GNU
make
program. MAKE_HOST
-
The built-in variable ‘MAKE_HOST’ expands to a string representing the host that GNU
make
was built to run on. MAKELEVEL
-
The number of levels of recursion (sub-
make
s).
See section Communicating Variables to a Sub-make
. MAKEFLAGS
-
The flags given to
make
. You can set this in the environment or a makefile to set flags.
See section Communicating Options to a Sub-make
.It is never appropriate to use
MAKEFLAGS
directly in a recipe line: its contents may not be quoted correctly for use in the shell. Always allow recursivemake
’s to obtain these values through the environment from its parent. GNUMAKEFLAGS
-
Other flags parsed by
make
. You can set this in the environment or a makefile to setmake
command-line flags. GNUmake
never sets this variable itself. This variable is only needed if you’d like to set GNUmake
-specific flags in a POSIX-compliant makefile. This variable will be seen by GNUmake
and ignored by othermake
implementations. It’s not needed if you only use GNUmake
; just useMAKEFLAGS
directly. See section Communicating Options to a Sub-make
. MAKECMDGOALS
-
The targets given to
make
on the command line. Setting this variable has no effect on the operation ofmake
.
See section Arguments to Specify the Goals. CURDIR
-
Set to the pathname of the current working directory (after all
-C
options are processed, if any). Setting this variable has no effect on the operation ofmake
.
See section Recursive Use ofmake
. SUFFIXES
-
The default list of suffixes before
make
reads any makefiles. .LIBPATTERNS
Defines the naming of the libraries
make
searches for, and their order.
See section Directory Search for Link Libraries.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on October 10, 2013 using texi2html 5.0.