make: Quick Reference

 
 Appendix A Quick Reference
 **************************
 
 This appendix summarizes the directives, text manipulation functions,
 and special variables which GNU 'make' understands.  SeeSpecial
 Targets, SeeCatalogue of Built-In Rules Catalogue of Rules, and
 SeeSummary of Options Options Summary, 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.
      SeeMulti-Line.
 
 'undefine VARIABLE'
      Undefining variables.
      SeeUndefine Directive.
 
 '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.
      SeeConditionals.
 
 'include FILE'
 '-include FILE'
 'sinclude FILE'
      Include another makefile.
      SeeIncluding Other Makefiles Include.
 
 'override VARIABLE-ASSIGNMENT'
      Define a variable, overriding any previous definition, even one
      from the command line.
      SeeThe 'override' Directive Override Directive.
 
 'export'
      Tell 'make' to export all variables to child processes by default.
      SeeCommunicating Variables to a Sub-'make' Variables/Recursion.
 
 'export VARIABLE'
 'export VARIABLE-ASSIGNMENT'
 'unexport VARIABLE'
      Tell 'make' whether or not to export a particular variable to child
      processes.
      SeeCommunicating Variables to a Sub-'make' Variables/Recursion.
 
 'private VARIABLE-ASSIGNMENT'
      Do not allow this variable assignment to be inherited by
      prerequisites.
      SeeSuppressing Inheritance.
 
 'vpath PATTERN PATH'
      Specify a search path for files matching a '%' pattern.
      SeeThe 'vpath' Directive Selective Search.
 
 '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 (SeeFunctions):
 
 '$(subst FROM,TO,TEXT)'
      Replace FROM with TO in TEXT.
      SeeFunctions for String Substitution and Analysis Text
      Functions.
 
 '$(patsubst PATTERN,REPLACEMENT,TEXT)'
      Replace words matching PATTERN with REPLACEMENT in TEXT.
      SeeFunctions for String Substitution and Analysis Text
      Functions.
 
 '$(strip STRING)'
      Remove excess whitespace characters from STRING.
      SeeFunctions for String Substitution and Analysis Text
      Functions.
 
 '$(findstring FIND,TEXT)'
      Locate FIND in TEXT.
      SeeFunctions for String Substitution and Analysis Text
      Functions.
 
 '$(filter PATTERN...,TEXT)'
      Select words in TEXT that match one of the PATTERN words.
      SeeFunctions for String Substitution and Analysis Text
      Functions.
 
 '$(filter-out PATTERN...,TEXT)'
      Select words in TEXT that _do not_ match any of the PATTERN words.
      SeeFunctions for String Substitution and Analysis Text
      Functions.
 
 '$(sort LIST)'
      Sort the words in LIST lexicographically, removing duplicates.
      SeeFunctions for String Substitution and Analysis Text
      Functions.
 
 '$(word N,TEXT)'
      Extract the Nth word (one-origin) of TEXT.
      SeeFunctions for String Substitution and Analysis Text
      Functions.
 
 '$(words TEXT)'
      Count the number of words in TEXT.
      SeeFunctions for String Substitution and Analysis Text
      Functions.
 
 '$(wordlist S,E,TEXT)'
      Returns the list of words in TEXT from S to E.
      SeeFunctions for String Substitution and Analysis Text
      Functions.
 
 '$(firstword NAMES...)'
      Extract the first word of NAMES.
      SeeFunctions for String Substitution and Analysis Text
      Functions.
 
 '$(lastword NAMES...)'
      Extract the last word of NAMES.
      SeeFunctions for String Substitution and Analysis Text
      Functions.
 
 '$(dir NAMES...)'
      Extract the directory part of each file name.
      SeeFunctions for File Names File Name Functions.
 
 '$(notdir NAMES...)'
      Extract the non-directory part of each file name.
      SeeFunctions for File Names File Name Functions.
 
 '$(suffix NAMES...)'
      Extract the suffix (the last '.' and following characters) of each
      file name.
      SeeFunctions for File Names File Name Functions.
 
 '$(basename NAMES...)'
      Extract the base name (name without suffix) of each file name.
      SeeFunctions for File Names File Name Functions.
 
 '$(addsuffix SUFFIX,NAMES...)'
      Append SUFFIX to each word in NAMES.
      SeeFunctions for File Names File Name Functions.
 
 '$(addprefix PREFIX,NAMES...)'
      Prepend PREFIX to each word in NAMES.
      SeeFunctions for File Names File Name Functions.
 
 '$(join LIST1,LIST2)'
      Join two parallel lists of words.
      SeeFunctions for File Names File Name Functions.
 
 '$(wildcard PATTERN...)'
      Find file names matching a shell file name pattern (_not_ a '%'
      pattern).
      SeeThe Function 'wildcard' Wildcard Function.
 
 '$(realpath NAMES...)'
      For each file name in NAMES, expand to an absolute name that does
      not contain any '.', '..', nor symlinks.
      SeeFunctions for File Names File Name Functions.
 
 '$(abspath NAMES...)'
      For each file name in NAMES, expand to an absolute name that does
      not contain any '.' or '..' components, but preserves symlinks.
      SeeFunctions for File Names File Name Functions.
 
 '$(error TEXT...)'
      When this function is evaluated, 'make' generates a fatal error
      with the message TEXT.
      SeeFunctions That Control Make Make Control Functions.
 
 '$(warning TEXT...)'
      When this function is evaluated, 'make' generates a warning with
      the message TEXT.
      SeeFunctions That Control Make Make Control Functions.
 
 '$(shell COMMAND)'
      Execute a shell command and return its output.
      SeeThe 'shell' Function Shell Function.
 
 '$(origin VARIABLE)'
      Return a string describing how the 'make' variable VARIABLE was
      defined.
      SeeThe 'origin' Function Origin Function.
 
 '$(flavor VARIABLE)'
      Return a string describing the flavor of the 'make' variable
      VARIABLE.
      SeeThe 'flavor' Function Flavor Function.
 
 '$(foreach VAR,WORDS,TEXT)'
      Evaluate TEXT with VAR bound to each word in WORDS, and concatenate
      the results.
      SeeThe 'foreach' Function Foreach 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.
      SeeFunctions for Conditionals Conditional Functions.
 
 '$(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.
      SeeFunctions for Conditionals Conditional Functions.
 
 '$(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.
      SeeFunctions for Conditionals Conditional Functions.
 
 '$(call VAR,PARAM,...)'
      Evaluate the variable VAR replacing any references to '$(1)',
      '$(2)' with the first, second, etc. PARAM values.
      SeeThe 'call' Function Call Function.
 
 '$(eval TEXT)'
      Evaluate TEXT then read the results as makefile commands.  Expands
      to the empty string.
      SeeThe 'eval' Function Eval Function.
 
 '$(file OP FILENAME,TEXT)'
      Expand the arguments, then open the file FILENAME using mode OP and
      write TEXT to that file.
      SeeThe 'file' Function File Function.
 
 '$(value VAR)'
      Evaluates to the contents of the variable VAR, with no expansion
      performed on it.
      SeeThe 'value' Function Value Function.
 
    Here is a summary of the automatic variables.  SeeAutomatic
 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 (SeeArchives).
 
 '$^'
 '$+'
      The names of all the prerequisites, with spaces between them.  For
      prerequisites which are archive members, only the named member is
      used (SeeArchives).  The value of '$^' omits duplicate
      prerequisites, while '$+' retains them and preserves their order.
 
 '$*'
      The stem with which an implicit rule matches (SeeHow Patterns
      Match Pattern 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'.
      SeeThe Variable 'MAKEFILES' MAKEFILES Variable.
 
 'VPATH'
 
      Directory search path for files not found in the current directory.
      See'VPATH' Search Path for All Prerequisites General Search.
 
 '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.  SeeRecipe Execution Execution.  The
      'SHELL' variable is handled specially when importing from and
      exporting to the environment.  SeeChoosing 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 of
      'SHELL'.  SeeMAKESHELL variable Execution.
 
 'MAKE'
 
      The name with which 'make' was invoked.  Using this variable in
      recipes has special meaning.  SeeHow the 'MAKE' Variable Works
      MAKE Variable.
 
 '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).
      SeeVariables/Recursion.
 
 'MAKEFLAGS'
 
      The flags given to 'make'.  You can set this in the environment or
      a makefile to set flags.
      SeeCommunicating Options to a Sub-'make' Options/Recursion.
 
      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 recursive 'make''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 set 'make' command-line flags.  GNU 'make' never
      sets this variable itself.  This variable is only needed if you'd
      like to set GNU 'make'-specific flags in a POSIX-compliant
      makefile.  This variable will be seen by GNU 'make' and ignored by
      other 'make' implementations.  It's not needed if you only use GNU
      'make'; just use 'MAKEFLAGS' directly.  SeeCommunicating Options
      to a Sub-'make' Options/Recursion.
 
 'MAKECMDGOALS'
 
      The targets given to 'make' on the command line.  Setting this
      variable has no effect on the operation of 'make'.
      SeeArguments to Specify the Goals Goals.
 
 'CURDIR'
 
      Set to the absolute 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'.
      SeeRecursive Use of 'make' Recursion.
 
 'SUFFIXES'
 
      The default list of suffixes before 'make' reads any makefiles.
 
 '.LIBPATTERNS'
      Defines the naming of the libraries 'make' searches for, and their
      order.
      SeeDirectory Search for Link Libraries Libraries/Search.