This appendix summarizes the directives, text manipulation functions,
and special variables which GNU make understands.
See Special Targets, Catalogue of Implicit Rules,
and Summary of Options,
for other summaries.
Here is a summary of the directives GNU make recognizes:
define variable
endef
ifdef variable
ifndef variable
ifeq (a,b)
ifeq "a" "b"
ifeq 'a' 'b'
ifneq (a,b)
ifneq "a" "b"
ifneq 'a' 'b'
else
endif
include file
-include file
sinclude file
override variable = value
override variable := value
override variable += value
override variable ?= value
override define variable
endef
override Directive.
export
make to export all variables to child processes by default.make.
export variable
export variable = value
export variable := value
export variable += value
export variable ?= value
unexport variable
make whether or not to export a particular variable to child
processes.make.
vpath pattern path
% pattern.vpath Directive.
vpath pattern
vpath
vpath
directive.
Here is a summary of the text manipulation functions (see Functions):
$(subst from,to,text)
$(patsubst pattern,replacement,text)
$(strip string)
$(findstring find,text)
$(filter pattern...,text)
$(filter-out pattern...,text)
$(sort list)
$(dir names...)
$(notdir names...)
$(suffix names...)
. and following characters) of each file name.$(basename names...)
$(addsuffix suffix,names...)
$(addprefix prefix,names...)
$(join list1,list2)
$(word n,text)
$(words text)
$(wordlist s,e,text)
$(firstword names...)
$(wildcard pattern...)
% pattern).wildcard.
$(error text...)
make generates a fatal error
with the message text.$(warning text...)
make generates a warning with
the message text.$(shell command)
shell Function.
$(origin variable)
make variable variable was
defined.origin Function.
$(foreach var,words,text)
foreach Function.
$(call var,param,...)
$(1),
$(2) with the first, second, etc. param values.call Function.
Here is a summary of the automatic variables. See Automatic Variables, for full information.
$@
$%
$<
$?
$^
$+
$^ omits duplicate
prerequisites, while $+ retains them and preserves their order.
$*
$(@D)
$(@F)
$@.
$(*D)
$(*F)
$*.
$(%D)
$(%F)
$%.
$(<D)
$(<F)
$<.
$(^D)
$(^F)
$^.
$(+D)
$(+F)
$+.
$(?D)
$(?F)
$?.
These variables are used specially by GNU make:
MAKEFILES
make.MAKEFILES.
VPATH
VPATH Search Path for All Prerequisites.
SHELL
/bin/sh.
You can set SHELL in the makefile to change the shell used to run
commands. See Command Execution.
MAKESHELL
make. This value takes precedence over the value of
SHELL. See MAKESHELL variable.
MAKE
make was invoked.
Using this variable in commands has special meaning.
See How the MAKE Variable Works.
MAKELEVEL
makes).MAKEFLAGS
make. You can set this in the environment or
a makefile to set flags.make.
It is never appropriate to use MAKEFLAGS directly on a
command line: its contents may not be quoted correctly for use in the
shell. Always allow recursive make's to obtain these values
through the environment from its parent.
MAKECMDGOALS
make on the command line. Setting this
variable has no effect on the operation of make.CURDIR
-C options are processed, if any). Setting this variable has no
effect on the operation of make.make.
SUFFIXES
make reads any makefiles.
.LIBPATTERNS
make searches for, and their
order.