| GNU Make Manual | www.imodulo.com · 2003-04-05 | ||
| [ Software | Documentation | Contact ] |
This appendix summarizes the directives, text manipulation functions, and special variables which GNU make understands. Special Targets, Catalogue of Implicit Rules, and Summary of Options, for other summaries.
Here is a summary of the directives GNU make recognizes:
define variableendefDefine a multi-line, recursively-expanded variable. Sequences.
ifdef variableifndef variableifeq (a,b)ifeq "a" "b"ifeq 'a' 'b'ifneq (a,b)ifneq "a" "b"ifneq 'a' 'b'elseendifConditionally evaluate part of the makefile. Conditionals.
include file-include filesinclude fileInclude another makefile. Including Other Makefiles.
override variable = valueoverride variable := valueoverride variable += valueoverride variable ?= valueoverride define variableendefDefine a variable, overriding any previous definition, even one from the command line. The override Directive.
exportTell make to export all variables to child processes by default. Communicating Variables to a Sub-make.
export variableexport variable = valueexport variable := valueexport variable += valueexport variable ?= valueunexport variableTell make whether or not to export a particular variable to child processes. Communicating Variables to a Sub-make.
vpath patternpathSpecify a search path for files matching a % pattern. The vpath Directive.
vpath patternRemove all search paths previously specified for pattern.
vpathRemove all search paths previously specified in any vpath directive.
Here is a summary of the text manipulation functions (Functions):
$(subst from,to,text)Replace from with to in text. Functions for String Substitution and Analysis.
$(patsubst pattern,replacement,text)Replace words matching pattern with replacement in text. Functions for String Substitution and Analysis.
$(strip string)Remove excess whitespace characters from string. Functions for String Substitution and Analysis.
$(findstring find,text)Locate find in text. Functions for String Substitution and Analysis.
$(filter pattern...,text)Select words in text that match one of the pattern words. Functions for String Substitution and Analysis.
$(filter-out pattern...,text)Select words in text that do not match any of the pattern words. Functions for String Substitution and Analysis.
$(sort list)Sort the words in list lexicographically, removing duplicates. Functions for String Substitution and Analysis.
$(dir names...)Extract the directory part of each file name. Functions for File Names.
$(notdir names...)Extract the non-directory part of each file name. Functions for File Names.
$(suffix names...)Extract the suffix (the last . and following characters) of each file name. Functions for File Names.
$(basename names...)Extract the base name (name without suffix) of each file name. Functions for File Names.
$(addsuffix suffix,names...)Append suffix to each word in names. Functions for File Names.
$(addprefix prefix,names...)Prepend prefix to each word in names. Functions for File Names.
$(join list1,list2)Join two parallel lists of words. Functions for File Names.
$(word n,text)Extract the nth word (one-origin) of text. Functions for File Names.
$(words text)Count the number of words in text. Functions for File Names.
$(wordlist s,e,text)Returns the list of words in text from s to e. Functions for File Names.
$(firstword names...)Extract the first word of names. Functions for File Names.
$(wildcard pattern...)Find file names matching a shell file name pattern (not a % pattern). The Function wildcard.
$(error text...)When this function is evaluated, make generates a fatal error with the message text. Functions That Control Make.
$(warning text...)When this function is evaluated, make generates a warning with the message text. Functions That Control Make.
$(shell command)Execute a shell command and return its output. The shell Function.
$(origin variable)Return a string describing how the make variable variable was defined. The origin Function.
$(foreach var,words,text)Evaluate text with var bound to each word in words, and concatenate the results. The foreach Function.
$(call var,param,...)Evaluate the variable var replacing any references to $(1), $(2) with the first, second, etc. param values. The call Function.
Here is a summary of the automatic variables. 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 member named is used (Archives).
$^$+The names of all the prerequisites, with spaces between them. For prerequisites which are archive members, only the member named is used (Archives). The value of $^ omits duplicate prerequisites, while $+ retains them and preserves their order.
$*The stem with which an implicit rule matches (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:
MAKEFILESMakefiles to be read on every invocation of make. The Variable MAKEFILES.
VPATHDirectory search path for files not found in the current directory. VPATH Search Path for All Prerequisites.
SHELLThe name of the system default command interpreter, usually /bin/sh. You can set SHELL in the makefile to change the shell used to run commands. Command Execution.
MAKESHELLOn MS-DOS only, the name of the command interpreter that is to be used by make. This value takes precedence over the value of SHELL. MAKESHELL variable.
MAKEThe name with which make was invoked. Using this variable in commands has special meaning. How the MAKE Variable Works.
MAKELEVELThe number of levels of recursion (sub-makes). Variables/Recursion.
MAKEFLAGSThe flags given to make. You can set this in the environment or a makefile to set flags. Communicating Options to a Sub-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.
MAKECMDGOALSThe targets given to make on the command line. Setting this variable has no effect on the operation of make. Arguments to Specify the Goals.
CURDIRSet 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 of make. Recursive Use of make.
SUFFIXESThe default list of suffixes before make reads any makefiles.
.LIBPATTERNSDefines the naming of the libraries make searches for, and their order. Directory Search for Link Libraries.
| © Free Software Foundation, Inc. |