home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / GCC / GCC258_3.LHA / gcc / info / make.info-4 < prev    next >
Encoding:
GNU Info File  |  1993-12-07  |  46.4 KB  |  1,210 lines

  1. This is Info file make.info, produced by Makeinfo-1.54 from the input
  2. file ./make.texinfo.
  3.  
  4.    This file documents the GNU Make utility, which determines
  5. automatically which pieces of a large program need to be recompiled,
  6. and issues the commands to recompile them.
  7.  
  8.    This is Edition 0.43, last updated 26 July 1993, of `The GNU Make
  9. Manual', for `make', Version 3.68 Beta.
  10.  
  11.    Copyright (C) 1988, '89, '90, '91, '92, '93 Free Software
  12. Foundation, Inc.
  13.  
  14.    Permission is granted to make and distribute verbatim copies of this
  15. manual provided the copyright notice and this permission notice are
  16. preserved on all copies.
  17.  
  18.    Permission is granted to copy and distribute modified versions of
  19. this manual under the conditions for verbatim copying, provided that
  20. the entire resulting derived work is distributed under the terms of a
  21. permission notice identical to this one.
  22.  
  23.    Permission is granted to copy and distribute translations of this
  24. manual into another language, under the above conditions for modified
  25. versions, except that this permission notice may be stated in a
  26. translation approved by the Free Software Foundation.
  27.  
  28. 
  29. File: make.info,  Node: Conditional Example,  Next: Conditional Syntax,  Up: Conditionals
  30.  
  31. Example of a Conditional
  32. ========================
  33.  
  34.    The following example of a conditional tells `make' to use one set
  35. of libraries if the `CC' variable is `gcc', and a different set of
  36. libraries otherwise.  It works by controlling which of two command
  37. lines will be used as the command for a rule.  The result is that
  38. `CC=gcc' as an argument to `make' changes not only which compiler is
  39. used but also which libraries are linked.
  40.  
  41.      libs_for_gcc = -lgnu
  42.      normal_libs =
  43.      
  44.      foo: $(objects)
  45.      ifeq ($(CC),gcc)
  46.              $(CC) -o foo $(objects) $(libs_for_gcc)
  47.      else
  48.              $(CC) -o foo $(objects) $(normal_libs)
  49.      endif
  50.  
  51.    This conditional uses three directives: one `ifeq', one `else' and
  52. one `endif'.
  53.  
  54.    The `ifeq' directive begins the conditional, and specifies the
  55. condition.  It contains two arguments, separated by a comma and
  56. surrounded by parentheses.  Variable substitution is performed on both
  57. arguments and then they are compared.  The lines of the makefile
  58. following the `ifeq' are obeyed if the two arguments match; otherwise
  59. they are ignored.
  60.  
  61.    The `else' directive causes the following lines to be obeyed if the
  62. previous conditional failed.  In the example above, this means that the
  63. second alternative linking command is used whenever the first
  64. alternative is not used.  It is optional to have an `else' in a
  65. conditional.
  66.  
  67.    The `endif' directive ends the conditional.  Every conditional must
  68. end with an `endif'.  Unconditional makefile text follows.
  69.  
  70.    As this example illustrates, conditionals work at the textual level:
  71. the lines of the conditional are treated as part of the makefile, or
  72. ignored, according to the condition.  This is why the larger syntactic
  73. units of the makefile, such as rules, may cross the beginning or the
  74. end of the conditional.
  75.  
  76.    When the variable `CC' has the value `gcc', the above example has
  77. this effect:
  78.  
  79.      foo: $(objects)
  80.              $(CC) -o foo $(objects) $(libs_for_gcc)
  81.  
  82. When the variable `CC' has any other value, the effect is this:
  83.  
  84.      foo: $(objects)
  85.              $(CC) -o foo $(objects) $(normal_libs)
  86.  
  87.    Equivalent results can be obtained in another way by
  88. conditionalizing a variable assignment and then using the variable
  89. unconditionally:
  90.  
  91.      libs_for_gcc = -lgnu
  92.      normal_libs =
  93.      
  94.      ifeq ($(CC),gcc)
  95.        libs=$(libs_for_gcc)
  96.      else
  97.        libs=$(normal_libs)
  98.      endif
  99.      
  100.      foo: $(objects)
  101.              $(CC) -o foo $(objects) $(libs)
  102.  
  103. 
  104. File: make.info,  Node: Conditional Syntax,  Next: Testing Flags,  Prev: Conditional Example,  Up: Conditionals
  105.  
  106. Syntax of Conditionals
  107. ======================
  108.  
  109.    The syntax of a simple conditional with no `else' is as follows:
  110.  
  111.      CONDITIONAL-DIRECTIVE
  112.      TEXT-IF-TRUE
  113.      endif
  114.  
  115. The TEXT-IF-TRUE may be any lines of text, to be considered as part of
  116. the makefile if the condition is true.  If the condition is false, no
  117. text is used instead.
  118.  
  119.    The syntax of a complex conditional is as follows:
  120.  
  121.      CONDITIONAL-DIRECTIVE
  122.      TEXT-IF-TRUE
  123.      else
  124.      TEXT-IF-FALSE
  125.      endif
  126.  
  127. If the condition is true, TEXT-IF-TRUE is used; otherwise,
  128. TEXT-IF-FALSE is used instead.  The TEXT-IF-FALSE can be any number of
  129. lines of text.
  130.  
  131.    The syntax of the CONDITIONAL-DIRECTIVE is the same whether the
  132. conditional is simple or complex.  There are four different directives
  133. that test different conditions.  Here is a table of them:
  134.  
  135. `ifeq (ARG1, ARG2)'
  136. `ifeq 'ARG1' 'ARG2''
  137. `ifeq "ARG1" "ARG2"'
  138. `ifeq "ARG1" 'ARG2''
  139. `ifeq 'ARG1' "ARG2"'
  140.      Expand all variable references in ARG1 and ARG2 and compare them.
  141.      If they are identical, the TEXT-IF-TRUE is effective; otherwise,
  142.      the TEXT-IF-FALSE, if any, is effective.
  143.  
  144.      Often you want to test if a variable has a non-empty value.  When
  145.      the value results from complex expansions of variables and
  146.      functions, expansions you would consider empty may actually
  147.      contain whitespace characters and thus are not seen as empty.
  148.      However, you can use the `strip' function (*note Text
  149.      Functions::.) to avoid interpreting whitespace as a non-empty
  150.      value.  For example:
  151.  
  152.           ifeq ($(strip $(foo)),)
  153.           TEXT-IF-EMPTY
  154.           endif
  155.  
  156.      will evaluate TEXT-IF-EMPTY even if the expansion of `$(foo)'
  157.      contains whitespace characters.
  158.  
  159. `ifneq (ARG1, ARG2)'
  160. `ifneq 'ARG1' 'ARG2''
  161. `ifneq "ARG1" "ARG2"'
  162. `ifneq "ARG1" 'ARG2''
  163. `ifneq 'ARG1' "ARG2"'
  164.      Expand all variable references in ARG1 and ARG2 and compare them.
  165.      If they are different, the TEXT-IF-TRUE is effective; otherwise,
  166.      the TEXT-IF-FALSE, if any, is effective.
  167.  
  168. `ifdef VARIABLE-NAME'
  169.      If the variable VARIABLE-NAME has a non-empty value, the
  170.      TEXT-IF-TRUE is effective; otherwise, the TEXT-IF-FALSE, if any,
  171.      is effective.  Variables that have never been defined have an
  172.      empty value.
  173.  
  174.      Note that `ifdef' only tests whether a variable has a value.  It
  175.      does not expand the variable to see if that value is nonempty.
  176.      Consequently, tests using `ifdef' return true for all definitions
  177.      except those like `foo ='.  To test for an empty value, use
  178.      `ifeq ($(foo),)'.  For example,
  179.  
  180.           bar =
  181.           foo = $(bar)
  182.           ifdef foo
  183.           frobozz = yes
  184.           else
  185.           frobozz = no
  186.           endif
  187.  
  188.      sets `frobozz' to `yes', while:
  189.  
  190.           foo =
  191.           ifdef foo
  192.           frobozz = yes
  193.           else
  194.           frobozz = no
  195.           endif
  196.  
  197.      sets `frobozz' to `no'.
  198.  
  199. `ifndef VARIABLE-NAME'
  200.      If the variable VARIABLE-NAME has an empty value, the TEXT-IF-TRUE
  201.      is effective; otherwise, the TEXT-IF-FALSE, if any, is effective.
  202.  
  203.    Extra spaces are allowed and ignored at the beginning of the
  204. conditional directive line, but a tab is not allowed.  (If the line
  205. begins with a tab, it will be considered a command for a rule.)  Aside
  206. from this, extra spaces or tabs may be inserted with no effect anywhere
  207. except within the directive name or within an argument.  A comment
  208. starting with `#' may appear at the end of the line.
  209.  
  210.    The other two directives that play a part in a conditional are `else'
  211. and `endif'.  Each of these directives is written as one word, with no
  212. arguments.  Extra spaces are allowed and ignored at the beginning of the
  213. line, and spaces or tabs at the end.  A comment starting with `#' may
  214. appear at the end of the line.
  215.  
  216.    Conditionals affect which lines of the makefile `make' uses.  If the
  217. condition is true, `make' reads the lines of the TEXT-IF-TRUE as part
  218. of the makefile; if the condition is false, `make' ignores those lines
  219. completely.  It follows that syntactic units of the makefile, such as
  220. rules, may safely be split across the beginning or the end of the
  221. conditional.
  222.  
  223.    `make' evaluates conditionals when it reads a makefile.
  224. Consequently, you cannot use automatic variables in the tests of
  225. conditionals because they are not defined until commands are run (*note
  226. Automatic Variables: Automatic.).
  227.  
  228.    To prevent intolerable confusion, it is not permitted to start a
  229. conditional in one makefile and end it in another.  However, you may
  230. write an `include' directive within a conditional, provided you do not
  231. attempt to terminate the conditional inside the included file.
  232.  
  233. 
  234. File: make.info,  Node: Testing Flags,  Prev: Conditional Syntax,  Up: Conditionals
  235.  
  236. Conditionals that Test Flags
  237. ============================
  238.  
  239.    You can write a conditional that tests `make' command flags such as
  240. `-t' by using the variable `MAKEFLAGS' together with the `findstring'
  241. function (*note Functions for String Substitution and Analysis: Text
  242. Functions.).  This is useful when `touch' is not enough to make a file
  243. appear up to date.
  244.  
  245.    The `findstring' function determines whether one string appears as a
  246. substring of another.  If you want to test for the `-t' flag, use `t'
  247. as the first string and the value of `MAKEFLAGS' as the other.
  248.  
  249.    For example, here is how to arrange to use `ranlib -t' to finish
  250. marking an archive file up to date:
  251.  
  252.      archive.a: ...
  253.      ifneq (,$(findstring t,$(MAKEFLAGS)))
  254.              +touch archive.a
  255.              +ranlib -t archive.a
  256.      else
  257.              ranlib archive.a
  258.      endif
  259.  
  260. The `+' prefix marks those command lines as "recursive" so that they
  261. will be executed despite use of the `-t' flag.  *Note Recursive Use of
  262. `make': Recursion.
  263.  
  264. 
  265. File: make.info,  Node: Functions,  Next: Running,  Prev: Conditionals,  Up: Top
  266.  
  267. Functions for Transforming Text
  268. *******************************
  269.  
  270.    "Functions" allow you to do text processing in the makefile to
  271. compute the files to operate on or the commands to use.  You use a
  272. function in a "function call", where you give the name of the function
  273. and some text (the "arguments") for the function to operate on.  The
  274. result of the function's processing is substituted into the makefile at
  275. the point of the call, just as a variable might be substituted.
  276.  
  277. * Menu:
  278.  
  279. * Syntax of Functions::         How to write a function call.
  280. * Text Functions::              General-purpose text manipulation functions.
  281. * Filename Functions::          Functions for manipulating file names.
  282. * Foreach Function::            Repeat some text with controlled variation.
  283. * Origin Function::             Find where a variable got its value.
  284. * Shell Function::              Substitute the output of a shell command.
  285.  
  286. 
  287. File: make.info,  Node: Syntax of Functions,  Next: Text Functions,  Up: Functions
  288.  
  289. Function Call Syntax
  290. ====================
  291.  
  292.    A function call resembles a variable reference.  It looks like this:
  293.  
  294.      $(FUNCTION ARGUMENTS)
  295.  
  296. or like this:
  297.  
  298.      ${FUNCTION ARGUMENTS}
  299.  
  300.    Here FUNCTION is a function name; one of a short list of names that
  301. are part of `make'.  There is no provision for defining new functions.
  302.  
  303.    The ARGUMENTS are the arguments of the function.  They are separated
  304. from the function name by one or more spaces or tabs, and if there is
  305. more than one argument, then they are separated by commas.  Such
  306. whitespace and commas are not part of an argument's value.  The
  307. delimiters which you use to surround the function call, whether
  308. parentheses or braces, can appear in an argument only in matching pairs;
  309. the other kind of delimiters may appear singly.  If the arguments
  310. themselves contain other function calls or variable references, it is
  311. wisest to use the same kind of delimiters for all the references; write
  312. `$(subst a,b,$(x))', not `$(subst a,b,${x})'.  This is because it is
  313. clearer, and because only one type of delimiter is matched to find the
  314. end of the reference.
  315.  
  316.    The text written for each argument is processed by substitution of
  317. variables and function calls to produce the argument value, which is
  318. the text on which the function acts.  The substitution is done in the
  319. order in which the arguments appear.
  320.  
  321.    Commas and unmatched parentheses or braces cannot appear in the text
  322. of an argument as written; leading spaces cannot appear in the text of
  323. the first argument as written.  These characters can be put into the
  324. argument value by variable substitution.  First define variables
  325. `comma' and `space' whose values are isolated comma and space
  326. characters, then substitute these variables where such characters are
  327. wanted, like this:
  328.  
  329.      comma:= ,
  330.      empty:=
  331.      space:= $(empty) $(empty)
  332.      foo:= a b c
  333.      bar:= $(subst $(space),$(comma),$(foo))
  334.      # bar is now `a,b,c'.
  335.  
  336. Here the `subst' function replaces each space with a comma, through the
  337. value of `foo', and substitutes the result.
  338.  
  339. 
  340. File: make.info,  Node: Text Functions,  Next: Filename Functions,  Prev: Syntax of Functions,  Up: Functions
  341.  
  342. Functions for String Substitution and Analysis
  343. ==============================================
  344.  
  345.    Here are some functions that operate on strings:
  346.  
  347. `$(subst FROM,TO,TEXT)'
  348.      Performs a textual replacement on the text TEXT: each occurrence
  349.      of FROM is replaced by TO.  The result is substituted for the
  350.      function call.  For example,
  351.  
  352.           $(subst ee,EE,feet on the street)
  353.  
  354.      substitutes the string `fEEt on the strEEt'.
  355.  
  356. `$(patsubst PATTERN,REPLACEMENT,TEXT)'
  357.      Finds whitespace-separated words in TEXT that match PATTERN and
  358.      replaces them with REPLACEMENT.  Here PATTERN may contain a `%'
  359.      which acts as a wildcard, matching any number of any characters
  360.      within a word.  If REPLACEMENT also contains a `%', the `%' is
  361.      replaced by the text that matched the `%' in PATTERN.
  362.  
  363.      `%' characters in `patsubst' function invocations can be quoted
  364.      with preceding backslashes (`\').  Backslashes that would
  365.      otherwise quote `%' characters can be quoted with more backslashes.
  366.      Backslashes that quote `%' characters or other backslashes are
  367.      removed from the pattern before it is compared file names or has a
  368.      stem substituted into it.  Backslashes that are not in danger of
  369.      quoting `%' characters go unmolested.  For example, the pattern
  370.      `the\%weird\\%pattern\\' has `the%weird\' preceding the operative
  371.      `%' character, and `pattern\\' following it.  The final two
  372.      backslashes are left alone because they cannot affect any `%'
  373.      character.
  374.  
  375.      Whitespace between words is folded into single space characters;
  376.      leading and trailing whitespace is discarded.
  377.  
  378.      For example,
  379.  
  380.           $(patsubst %.c,%.o,x.c.c bar.c)
  381.  
  382.      produces the value `x.c.o bar.o'.
  383.  
  384.      Substitution references (*note Substitution References:
  385.      Substitution Refs.) are a simpler way to get the effect of the
  386.      `patsubst' function:
  387.  
  388.           $(VAR:PATTERN=REPLACEMENT)
  389.  
  390.      is equivalent to
  391.  
  392.           $(patsubst PATTERN,REPLACEMENT,$(VAR))
  393.  
  394.      The second shorthand simplifies one of the most common uses of
  395.      `patsubst': replacing the suffix at the end of file names.
  396.  
  397.           $(VAR:SUFFIX=REPLACEMENT)
  398.  
  399.      is equivalent to
  400.  
  401.           $(patsubst %SUFFIX,%REPLACEMENT,$(VAR))
  402.  
  403.      For example, you might have a list of object files:
  404.  
  405.           objects = foo.o bar.o baz.o
  406.  
  407.      To get the list of corresponding source files, you could simply
  408.      write:
  409.  
  410.           $(objects:.o=.c)
  411.  
  412.      instead of using the general form:
  413.  
  414.           $(patsubst %.o,%.c,$(objects))
  415.  
  416. `$(strip STRING)'
  417.      Removes leading and trailing whitespace from STRING and replaces
  418.      each internal sequence of one or more whitespace characters with a
  419.      single space.  Thus, `$(strip a b  c )' results in `a b c'.
  420.  
  421.      The function `strip' can be very useful when used in conjunction
  422.      with conditionals.  When comparing something with the empty string
  423.      `' using `ifeq' or `ifneq', you usually want a string of just
  424.      whitespace to match the empty string (*note Conditionals::.).
  425.  
  426.      Thus, the following may fail to have the desired results:
  427.  
  428.           .PHONY: all
  429.           ifneq   "$(needs_made)" ""
  430.           all: $(needs_made)
  431.           else
  432.           all:;@echo 'Nothing to make!'
  433.           endif
  434.  
  435.      Replacing the variable reference `$(needs_made)' with the function
  436.      call `$(strip $(needs_made))' in the `ifneq' directive would make
  437.      it more robust.
  438.  
  439. `$(findstring FIND,IN)'
  440.      Searches IN for an occurrence of FIND.  If it occurs, the value is
  441.      FIND; otherwise, the value is empty.  You can use this function in
  442.      a conditional to test for the presence of a specific substring in
  443.      a given string.  Thus, the two examples,
  444.  
  445.           $(findstring a,a b c)
  446.           $(findstring a,b c)
  447.  
  448.      produce the values `a' and `' (the empty string), respectively.
  449.      *Note Testing Flags::, for a practical application of `findstring'.
  450.  
  451. `$(filter PATTERN...,TEXT)'
  452.      Removes all whitespace-separated words in TEXT that do *not* match
  453.      any of the PATTERN words, returning only matching words.  The
  454.      patterns are written using `%', just like the patterns used in the
  455.      `patsubst' function above.
  456.  
  457.      The `filter' function can be used to separate out different types
  458.      of strings (such as file names) in a variable.  For example:
  459.  
  460.           sources := foo.c bar.c baz.s ugh.h
  461.           foo: $(sources)
  462.                   cc $(filter %.c %.s,$(sources)) -o foo
  463.  
  464.      says that `foo' depends of `foo.c', `bar.c', `baz.s' and `ugh.h'
  465.      but only `foo.c', `bar.c' and `baz.s' should be specified in the
  466.      command to the compiler.
  467.  
  468. `$(filter-out PATTERN...,TEXT)'
  469.      Removes all whitespace-separated words in TEXT that *do* match the
  470.      PATTERN words, returning only the words that *do not* match.  This
  471.      is the exact opposite of the `filter' function.
  472.  
  473.      For example, given:
  474.  
  475.           objects=main1.o foo.o main2.o bar.o
  476.           mains=main1.o main2.o
  477.  
  478.      the following generates a list which contains all the object files
  479.      not in `mains':
  480.  
  481.           $(filter-out $(mains),$(objects))
  482.  
  483. `$(sort LIST)'
  484.      Sorts the words of LIST in lexical order, removing duplicate
  485.      words.  The output is a list of words separated by single spaces.
  486.      Thus,
  487.  
  488.           $(sort foo bar lose)
  489.  
  490.      returns the value `bar foo lose'.
  491.  
  492.      Incidentally, since `sort' removes duplicate words, you can use it
  493.      for this purpose even if you don't care about the sort order.
  494.  
  495.    Here is a realistic example of the use of `subst' and `patsubst'.
  496. Suppose that a makefile uses the `VPATH' variable to specify a list of
  497. directories that `make' should search for dependency files (*note
  498. `VPATH' Search Path for All Dependencies: General Search.).  This
  499. example shows how to tell the C compiler to search for header files in
  500. the same list of directories.
  501.  
  502.    The value of `VPATH' is a list of directories separated by colons,
  503. such as `src:../headers'.  First, the `subst' function is used to
  504. change the colons to spaces:
  505.  
  506.      $(subst :, ,$(VPATH))
  507.  
  508. This produces `src ../headers'.  Then `patsubst' is used to turn each
  509. directory name into a `-I' flag.  These can be added to the value of
  510. the variable `CFLAGS', which is passed automatically to the C compiler,
  511. like this:
  512.  
  513.      override CFLAGS += $(patsubst %,-I%,$(subst :, ,$(VPATH)))
  514.  
  515. The effect is to append the text `-Isrc -I../headers' to the previously
  516. given value of `CFLAGS'.  The `override' directive is used so that the
  517. new value is assigned even if the previous value of `CFLAGS' was
  518. specified with a command argument (*note The `override' Directive:
  519. Override Directive.).
  520.  
  521. 
  522. File: make.info,  Node: Filename Functions,  Next: Foreach Function,  Prev: Text Functions,  Up: Functions
  523.  
  524. Functions for File Names
  525. ========================
  526.  
  527.    Several of the built-in expansion functions relate specifically to
  528. taking apart file names or lists of file names.
  529.  
  530.    Each of the following functions performs a specific transformation
  531. on a file name.  The argument of the function is regarded as a series
  532. of file names, separated by whitespace.  (Leading and trailing
  533. whitespace is ignored.)  Each file name in the series is transformed in
  534. the same way and the results are concatenated with single spaces
  535. between them.
  536.  
  537. `$(dir NAMES...)'
  538.      Extracts the directory-part of each file name in NAMES.  The
  539.      directory-part of the file name is everything up through (and
  540.      including) the last slash in it.  If the file name contains no
  541.      slash, the directory part is the string `./'.  For example,
  542.  
  543.           $(dir src/foo.c hacks)
  544.  
  545.      produces the result `src/ ./'.
  546.  
  547. `$(notdir NAMES...)'
  548.      Extracts all but the directory-part of each file name in NAMES.
  549.      If the file name contains no slash, it is left unchanged.
  550.      Otherwise, everything through the last slash is removed from it.
  551.  
  552.      A file name that ends with a slash becomes an empty string.  This
  553.      is unfortunate, because it means that the result does not always
  554.      have the same number of whitespace-separated file names as the
  555.      argument had; but we do not see any other valid alternative.
  556.  
  557.      For example,
  558.  
  559.           $(notdir src/foo.c hacks)
  560.  
  561.      produces the result `foo.c hacks'.
  562.  
  563. `$(suffix NAMES...)'
  564.      Extracts the suffix of each file name in NAMES.  If the file name
  565.      contains a period, the suffix is everything starting with the last
  566.      period.  Otherwise, the suffix is the empty string.  This
  567.      frequently means that the result will be empty when NAMES is not,
  568.      and if NAMES contains multiple file names, the result may contain
  569.      fewer file names.
  570.  
  571.      For example,
  572.  
  573.           $(suffix src/foo.c hacks)
  574.  
  575.      produces the result `.c'.
  576.  
  577. `$(basename NAMES...)'
  578.      Extracts all but the suffix of each file name in NAMES.  If the
  579.      file name contains a period, the basename is everything starting
  580.      up to (and not including) the last period.  Otherwise, the
  581.      basename is the entire file name.  For example,
  582.  
  583.           $(basename src/foo.c hacks)
  584.  
  585.      produces the result `src/foo hacks'.
  586.  
  587. `$(addsuffix SUFFIX,NAMES...)'
  588.      The argument NAMES is regarded as a series of names, separated by
  589.      whitespace; SUFFIX is used as a unit.  The value of SUFFIX is
  590.      appended to the end of each individual name and the resulting
  591.      larger names are concatenated with single spaces between them.
  592.      For example,
  593.  
  594.           $(addsuffix .c,foo bar)
  595.  
  596.      produces the result `foo.c bar.c'.
  597.  
  598. `$(addprefix PREFIX,NAMES...)'
  599.      The argument NAMES is regarded as a series of names, separated by
  600.      whitespace; PREFIX is used as a unit.  The value of PREFIX is
  601.      prepended to the front of each individual name and the resulting
  602.      larger names are concatenated with single spaces between them.
  603.      For example,
  604.  
  605.           $(addprefix src/,foo bar)
  606.  
  607.      produces the result `src/foo src/bar'.
  608.  
  609. `$(join LIST1,LIST2)'
  610.      Concatenates the two arguments word by word: the two first words
  611.      (one from each argument) concatenated form the first word of the
  612.      result, the two second words form the second word of the result,
  613.      and so on.  So the Nth word of the result comes from the Nth word
  614.      of each argument.  If one argument has more words that the other,
  615.      the extra words are copied unchanged into the result.
  616.  
  617.      For example, `$(join a b,.c .o)' produces `a.c b.o'.
  618.  
  619.      Whitespace between the words in the lists is not preserved; it is
  620.      replaced with a single space.
  621.  
  622.      This function can merge the results of the `dir' and `notdir'
  623.      functions, to produce the original list of files which was given
  624.      to those two functions.
  625.  
  626. `$(word N,TEXT)'
  627.      Returns the Nth word of TEXT.  The legitimate values of N start
  628.      from 1.  If N is bigger than the number of words in TEXT, the
  629.      value is empty.  For example,
  630.  
  631.           $(word 2, foo bar baz)
  632.  
  633.      returns `bar'.
  634.  
  635. `$(words TEXT)'
  636.      Returns the number of words in TEXT.  Thus, the last word of TEXT
  637.      is `$(word $(words TEXT),TEXT)'.
  638.  
  639. `$(firstword NAMES...)'
  640.      The argument NAMES is regarded as a series of names, separated by
  641.      whitespace.  The value is the first name in the series.  The rest
  642.      of the names are ignored.
  643.  
  644.      For example,
  645.  
  646.           $(firstword foo bar)
  647.  
  648.      produces the result `foo'.  Although `$(firstword TEXT)' is the
  649.      same as `$(word 1,TEXT)', the `firstword' function is retained for
  650.      its simplicity.
  651.  
  652. `$(wildcard PATTERN)'
  653.      The argument PATTERN is a file name pattern, typically containing
  654.      wildcard characters (as in shell file name patterns).  The result
  655.      of `wildcard' is a space-separated list of the names of existing
  656.      files that match the pattern.  *Note Using Wildcard Characters in
  657.      File Names: Wildcards.
  658.  
  659. 
  660. File: make.info,  Node: Foreach Function,  Next: Origin Function,  Prev: Filename Functions,  Up: Functions
  661.  
  662. The `foreach' Function
  663. ======================
  664.  
  665.    The `foreach' function is very different from other functions.  It
  666. causes one piece of text to be used repeatedly, each time with a
  667. different substitution performed on it.  It resembles the `for' command
  668. in the shell `sh' and the `foreach' command in the C-shell `csh'.
  669.  
  670.    The syntax of the `foreach' function is:
  671.  
  672.      $(foreach VAR,LIST,TEXT)
  673.  
  674. The first two arguments, VAR and LIST, are expanded before anything
  675. else is done; note that the last argument, TEXT, is *not* expanded at
  676. the same time.  Then for each word of the expanded value of LIST, the
  677. variable named by the expanded value of VAR is set to that word, and
  678. TEXT is expanded.  Presumably TEXT contains references to that
  679. variable, so its expansion will be different each time.
  680.  
  681.    The result is that TEXT is expanded as many times as there are
  682. whitespace-separated words in LIST.  The multiple expansions of TEXT
  683. are concatenated, with spaces between them, to make the result of
  684. `foreach'.
  685.  
  686.    This simple example sets the variable `files' to the list of all
  687. files in the directories in the list `dirs':
  688.  
  689.      dirs := a b c d
  690.      files := $(foreach dir,$(dirs),$(wildcard $(dir)/*))
  691.  
  692.    Here TEXT is `$(wildcard $(dir)/*)'.  The first repetition finds the
  693. value `a' for `dir', so it produces the same result as `$(wildcard
  694. a/*)'; the second repetition produces the result of `$(wildcard b/*)';
  695. and the third, that of `$(wildcard c/*)'.
  696.  
  697.    This example has the same result (except for setting `dirs') as the
  698. following example:
  699.  
  700.      files := $(wildcard a/* b/* c/* d/*)
  701.  
  702.    When TEXT is complicated, you can improve readability by giving it a
  703. name, with an additional variable:
  704.  
  705.      find_files = $(wildcard $(dir)/*)
  706.      dirs := a b c d
  707.      files := $(foreach dir,$(dirs),$(find_files))
  708.  
  709. Here we use the variable `find_files' this way.  We use plain `=' to
  710. define a recursively-expanding variable, so that its value contains an
  711. actual function call to be reexpanded under the control of `foreach'; a
  712. simply-expanded variable would not do, since `wildcard' would be called
  713. only once at the time of defining `find_files'.
  714.  
  715.    The `foreach' function has no permanent effect on the variable VAR;
  716. its value and flavor after the `foreach' function call are the same as
  717. they were beforehand.  The other values which are taken from LIST are
  718. in effect only temporarily, during the execution of `foreach'.  The
  719. variable VAR is a simply-expanded variable during the execution of
  720. `foreach'.  If VAR was undefined before the `foreach' function call, it
  721. is undefined after the call.  *Note The Two Flavors of Variables:
  722. Flavors.
  723.  
  724.    You must take care when using complex variable expressions that
  725. result in variable names because many strange things are valid variable
  726. names, but are probably not what you intended.  For example,
  727.  
  728.      files := $(foreach Es escrito en espanol!,b c ch,$(find_files))
  729.  
  730. might be useful if the value of `find_files' references the variable
  731. whose name is `Es escrito en espanol!' (es un nombre bastante largo,
  732. no?), but it is more likely to be a mistake.
  733.  
  734. 
  735. File: make.info,  Node: Origin Function,  Next: Shell Function,  Prev: Foreach Function,  Up: Functions
  736.  
  737. The `origin' Function
  738. =====================
  739.  
  740.    The `origin' function is unlike most other functions in that it does
  741. not operate on the values of variables; it tells you something *about*
  742. a variable.  Specifically, it tells you where it came from.
  743.  
  744.    The syntax of the `origin' function is:
  745.  
  746.      $(origin VARIABLE)
  747.  
  748.    Note that VARIABLE is the *name* of a variable to inquire about; not
  749. a *reference* to that variable.  Therefore you would not normally use a
  750. `$' or parentheses when writing it.  (You can, however, use a variable
  751. reference in the name if you want the name not to be a constant.)
  752.  
  753.    The result of this function is a string telling you how the variable
  754. VARIABLE was defined:
  755.  
  756. `undefined'
  757.      if VARIABLE was never defined.
  758.  
  759. `default'
  760.      if VARIABLE has a default definition, as is usual with `CC' and so
  761.      on.  *Note Variables Used by Implicit Rules: Implicit Variables.
  762.      Note that if you have redefined a default variable, the `origin'
  763.      function will return the origin of the later definition.
  764.  
  765. `environment'
  766.      if VARIABLE was defined as an environment variable and the `-e'
  767.      option is *not* turned on (*note Summary of Options: Options
  768.      Summary.).
  769.  
  770. `environment override'
  771.      if VARIABLE was defined as an environment variable and the `-e'
  772.      option *is* turned on (*note Summary of Options: Options Summary.).
  773.  
  774. `file'
  775.      if VARIABLE was defined in a makefile.
  776.  
  777. `command line'
  778.      if VARIABLE was defined on the command line.
  779.  
  780. `override'
  781.      if VARIABLE was defined with an `override' directive in a makefile
  782.      (*note The `override' Directive: Override Directive.).
  783.  
  784. `automatic'
  785.      if VARIABLE is an automatic variable defined for the execution of
  786.      the commands for each rule (*note Automatic Variables: Automatic.).
  787.  
  788.    This information is primarily useful (other than for your curiosity)
  789. to determine if you want to believe the value of a variable.  For
  790. example, suppose you have a makefile `foo' that includes another
  791. makefile `bar'.  You want a variable `bletch' to be defined in `bar' if
  792. you run the command `make -f bar', even if the environment contains a
  793. definition of `bletch'.  However, if `foo' defined `bletch' before
  794. including `bar', you do not want to override that definition.  This
  795. could be done by using an `override' directive in `foo', giving that
  796. definition precedence over the later definition in `bar';
  797. unfortunately, the `override' directive would also override any command
  798. line definitions.  So, `bar' could include:
  799.  
  800.      ifdef bletch
  801.      ifeq "$(origin bletch)" "environment"
  802.      bletch = barf, gag, etc.
  803.      endif
  804.      endif
  805.  
  806. If `bletch' has been defined from the environment, this will redefine
  807. it.
  808.  
  809.    If you want to override a previous definition of `bletch' if it came
  810. from the environment, even under `-e', you could instead write:
  811.  
  812.      ifneq "$(findstring environment,$(origin bletch))" ""
  813.      bletch = barf, gag, etc.
  814.      endif
  815.  
  816.    Here the redefinition takes place if `$(origin bletch)' returns
  817. either `environment' or `environment override'.  *Note Functions for
  818. String Substitution and Analysis: Text Functions.
  819.  
  820. 
  821. File: make.info,  Node: Shell Function,  Prev: Origin Function,  Up: Functions
  822.  
  823. The `shell' Function
  824. ====================
  825.  
  826.    The `shell' function is unlike any other function except the
  827. `wildcard' function (*note The Function `wildcard': Wildcard Function.)
  828. in that it communicates with the world outside of `make'.
  829.  
  830.    The `shell' function performs the same function that backquotes
  831. (``') perform in most shells: it does "command expansion".  This means
  832. that it takes an argument that is a shell command and returns the
  833. output of the command.  The only processing `make' does on the result,
  834. before substituting it into the surrounding text, is to convert
  835. newlines to spaces.
  836.  
  837.    The commands run by calls to the `shell' function are run when the
  838. function calls are expanded.  In most cases, this is when the makefile
  839. is read in.  The exception is that function calls in the commands of
  840. the rules are expanded when the commands are run, and this applies to
  841. `shell' function calls like all others.
  842.  
  843.    Here are some examples of the use of the `shell' function:
  844.  
  845.      contents := $(shell cat foo)
  846.  
  847. sets `contents' to the contents of the file `foo', with a space (rather
  848. than a newline) separating each line.
  849.  
  850.      files := $(shell echo *.c)
  851.  
  852. sets `files' to the expansion of `*.c'.  Unless `make' is using a very
  853. strange shell, this has the same result as `$(wildcard *.c)'.
  854.  
  855. 
  856. File: make.info,  Node: Running,  Next: Implicit Rules,  Prev: Functions,  Up: Top
  857.  
  858. How to Run `make'
  859. *****************
  860.  
  861.    A makefile that says how to recompile a program can be used in more
  862. than one way.  The simplest use is to recompile every file that is out
  863. of date.  Usually, makefiles are written so that if you run `make' with
  864. no arguments, it does just that.
  865.  
  866.    But you might want to update only some of the files; you might want
  867. to use a different compiler or different compiler options; you might
  868. want just to find out which files are out of date without changing them.
  869.  
  870.    By giving arguments when you run `make', you can do any of these
  871. things and many others.
  872.  
  873. * Menu:
  874.  
  875. * Makefile Arguments::          How to specify which makefile to use.
  876. * Goals::                       How to use goal arguments to specify which
  877.                                   parts of the makefile to use.
  878. * Instead of Execution::        How to use mode flags to specify what
  879.                                   kind of thing to do with the commands
  880.                                   in the makefile other than simply
  881.                                   execute them.
  882. * Avoiding Compilation::        How to avoid recompiling certain files.
  883. * Overriding::                  How to override a variable to specify
  884.                                   an alternate compiler and other things.
  885. * Testing::                     How to proceed past some errors, to
  886.                                   test compilation.
  887. * Options Summary::             Summary of Options
  888.  
  889. 
  890. File: make.info,  Node: Makefile Arguments,  Next: Goals,  Up: Running
  891.  
  892. Arguments to Specify the Makefile
  893. =================================
  894.  
  895.    The way to specify the name of the makefile is with the `-f' or
  896. `--file' option (`--makefile' also works).  For example, `-f altmake'
  897. says to use the file `altmake' as the makefile.
  898.  
  899.    If you use the `-f' flag several times and follow each `-f' with an
  900. argument, all the specified files are used jointly as makefiles.
  901.  
  902.    If you do not use the `-f' or `--file' flag, the default is to try
  903. `GNUmakefile', `makefile', and `Makefile', in that order, and use the
  904. first of these three which exists or can be made (*note Writing
  905. Makefiles: Makefiles.).
  906.  
  907. 
  908. File: make.info,  Node: Goals,  Next: Instead of Execution,  Prev: Makefile Arguments,  Up: Running
  909.  
  910. Arguments to Specify the Goals
  911. ==============================
  912.  
  913.    The "goals" are the targets that `make' should strive ultimately to
  914. update.  Other targets are updated as well if they appear as
  915. dependencies of goals, or dependencies of dependencies of goals, etc.
  916.  
  917.    By default, the goal is the first target in the makefile (not
  918. counting targets that start with a period).  Therefore, makefiles are
  919. usually written so that the first target is for compiling the entire
  920. program or programs they describe.
  921.  
  922.    You can specify a different goal or goals with arguments to `make'.
  923. Use the name of the goal as an argument.  If you specify several goals,
  924. `make' processes each of them in turn, in the order you name them.
  925.  
  926.    Any target in the makefile may be specified as a goal (unless it
  927. starts with `-' or contains an `=', in which case it will be parsed as
  928. a switch or variable definition, respectively).  Even targets not in
  929. the makefile may be specified, if `make' can find implicit rules that
  930. say how to make them.
  931.  
  932.    One use of specifying a goal is if you want to compile only a part of
  933. the program, or only one of several programs.  Specify as a goal each
  934. file that you wish to remake.  For example, consider a directory
  935. containing several programs, with a makefile that starts like this:
  936.  
  937.      .PHONY: all
  938.      all: size nm ld ar as
  939.  
  940.    If you are working on the program `size', you might want to say
  941. `make size' so that only the files of that program are recompiled.
  942.  
  943.    Another use of specifying a goal is to make files that are not
  944. normally made.  For example, there may be a file of debugging output,
  945. or a version of the program that is compiled specially for testing,
  946. which has a rule in the makefile but is not a dependency of the default
  947. goal.
  948.  
  949.    Another use of specifying a goal is to run the commands associated
  950. with a phony target (*note Phony Targets::.) or empty target (*note
  951. Empty Target Files to Record Events: Empty Targets.).  Many makefiles
  952. contain a phony target named `clean' which deletes everything except
  953. source files.  Naturally, this is done only if you request it
  954. explicitly with `make clean'.  Here is a list of typical phony and
  955. empty target names:
  956.  
  957. `all'
  958.      Make all the top-level targets the makefile knows about.
  959.  
  960. `clean'
  961.      Delete all files that are normally created by running `make'.
  962.  
  963. `mostlyclean'
  964.      Like `clean', but may refrain from deleting a few files that people
  965.      normally don't want to recompile.  For example, the `mostlyclean'
  966.      target for GCC does not delete `libgcc.a', because recompiling it
  967.      is rarely necessary and takes a lot of time.
  968.  
  969. `distclean'
  970. `realclean'
  971. `clobber'
  972.      Any of these three might be defined to delete everything that would
  973.      not be part of a standard distribution.  For example, this would
  974.      delete configuration files or links that you would normally create
  975.      as preparation for compilation, even if the makefile itself cannot
  976.      create these files.
  977.  
  978. `install'
  979.      Copy the executable file into a directory that users typically
  980.      search for commands; copy any auxiliary files that the executable
  981.      uses into the directories where it will look for them.
  982.  
  983. `print'
  984.      Print listings of the source files that have changed.
  985.  
  986. `tar'
  987.      Create a tar file of the source files.
  988.  
  989. `shar'
  990.      Create a shell archive (shar file) of the source files.
  991.  
  992. `dist'
  993.      Create a distribution file of the source files.  This might be a
  994.      tar file, or a shar file, or a compressed version of one of the
  995.      above, or even more than one of the above.
  996.  
  997. `TAGS'
  998.      Update a tags table for this program.
  999.  
  1000. `check'
  1001. `test'
  1002.      Perform self tests on the program this makefile builds.
  1003.  
  1004. 
  1005. File: make.info,  Node: Instead of Execution,  Next: Avoiding Compilation,  Prev: Goals,  Up: Running
  1006.  
  1007. Instead of Executing the Commands
  1008. =================================
  1009.  
  1010.    The makefile tells `make' how to tell whether a target is up to date,
  1011. and how to update each target.  But updating the targets is not always
  1012. what you want.  Certain options specify other activities for `make'.
  1013.  
  1014. `-n'
  1015. `--just-print'
  1016. `--dry-run'
  1017. `--recon'
  1018.      "No-op".  The activity is to print what commands would be used to
  1019.      make the targets up to date, but not actually execute them.
  1020.  
  1021. `-t'
  1022. `--touch'
  1023.      "Touch".  The activity is to mark the targets as up to date without
  1024.      actually changing them.  In other words, `make' pretends to compile
  1025.      the targets but does not really change their contents.
  1026.  
  1027. `-q'
  1028. `--question'
  1029.      "Question".  The activity is to find out silently whether the
  1030.      targets are up to date already; but execute no commands in either
  1031.      case.  In other words, neither compilation nor output will occur.
  1032.  
  1033. `-W FILE'
  1034. `--what-if=FILE'
  1035. `--assume-new=FILE'
  1036. `--new-file=FILE'
  1037.      "What if".  Each `-W' flag is followed by a file name.  The given
  1038.      files' modification times are recorded by `make' as being the
  1039.      present time, although the actual modification times remain the
  1040.      same.  You can use the `-W' flag in conjunction with the `-n' flag
  1041.      to see what would happen if you were to modify specific files.
  1042.  
  1043.    With the `-n' flag, `make' prints the commands that it would
  1044. normally execute but does not execute them.
  1045.  
  1046.    With the `-t' flag, `make' ignores the commands in the rules and
  1047. uses (in effect) the command `touch' for each target that needs to be
  1048. remade.  The `touch' command is also printed, unless `-s' or `.SILENT'
  1049. is used.  For speed, `make' does not actually invoke the program
  1050. `touch'.  It does the work directly.
  1051.  
  1052.    With the `-q' flag, `make' prints nothing and executes no commands,
  1053. but the exit status code it returns is zero if and only if the targets
  1054. to be considered are already up to date.
  1055.  
  1056.    It is an error to use more than one of these three flags in the same
  1057. invocation of `make'.
  1058.  
  1059.    The `-n', `-t', and `-q' options do not affect command lines that
  1060. begin with `+' characters or contain the strings `$(MAKE)' or
  1061. `${MAKE}'.  Note that only the line containing the `+' character or the
  1062. strings `$(MAKE)' or `${MAKE}' is run regardless of these options.
  1063. Other lines in the same rule are not run unless they too begin with `+'
  1064. or contain `$(MAKE)' or `${MAKE}' (*Note How the `MAKE' Variable Works:
  1065. MAKE Variable.)
  1066.  
  1067.    The `-W' flag provides two features:
  1068.  
  1069.    * If you also use the `-n' or `-q' flag, you can see what `make'
  1070.      would do if you were to modify some files.
  1071.  
  1072.    * Without the `-n' or `-q' flag, when `make' is actually executing
  1073.      commands, the `-W' flag can direct `make' to act as if some files
  1074.      had been modified, without actually modifying the files.
  1075.  
  1076.    Note that the options `-p' and `-v' allow you to obtain other
  1077. information about `make' or about the makefiles in use (*note Summary
  1078. of Options: Options Summary.).
  1079.  
  1080. 
  1081. File: make.info,  Node: Avoiding Compilation,  Next: Overriding,  Prev: Instead of Execution,  Up: Running
  1082.  
  1083. Avoiding Recompilation of Some Files
  1084. ====================================
  1085.  
  1086.    Sometimes you may have changed a source file but you do not want to
  1087. recompile all the files that depend on it.  For example, suppose you
  1088. add a macro or a declaration to a header file that many other files
  1089. depend on.  Being conservative, `make' assumes that any change in the
  1090. header file requires recompilation of all dependent files, but you know
  1091. that they do not need to be recompiled and you would rather not waste
  1092. the time waiting for them to compile.
  1093.  
  1094.    If you anticipate the problem before changing the header file, you
  1095. can use the `-t' flag.  This flag tells `make' not to run the commands
  1096. in the rules, but rather to mark the target up to date by changing its
  1097. last-modification date.  You would follow this procedure:
  1098.  
  1099.   1. Use the command `make' to recompile the source files that really
  1100.      need recompilation.
  1101.  
  1102.   2. Make the changes in the header files.
  1103.  
  1104.   3. Use the command `make -t' to mark all the object files as up to
  1105.      date.  The next time you run `make', the changes in the header
  1106.      files will not cause any recompilation.
  1107.  
  1108.    If you have already changed the header file at a time when some files
  1109. do need recompilation, it is too late to do this.  Instead, you can use
  1110. the `-o FILE' flag, which marks a specified file as "old" (*note
  1111. Summary of Options: Options Summary.).  This means that the file itself
  1112. will not be remade, and nothing else will be remade on its account.
  1113. Follow this procedure:
  1114.  
  1115.   1. Recompile the source files that need compilation for reasons
  1116.      independent of the particular header file, with `make -o
  1117.      HEADERFILE'.  If several header files are involved, use a separate
  1118.      `-o' option for each header file.
  1119.  
  1120.   2. Touch all the object files with `make -t'.
  1121.  
  1122. 
  1123. File: make.info,  Node: Overriding,  Next: Testing,  Prev: Avoiding Compilation,  Up: Running
  1124.  
  1125. Overriding Variables
  1126. ====================
  1127.  
  1128.    An argument that contains `=' specifies the value of a variable:
  1129. `V=X' sets the value of the variable V to X.  If you specify a value in
  1130. this way, all ordinary assignments of the same variable in the makefile
  1131. are ignored; we say they have been "overridden" by the command line
  1132. argument.
  1133.  
  1134.    The most common way to use this facility is to pass extra flags to
  1135. compilers.  For example, in a properly written makefile, the variable
  1136. `CFLAGS' is included in each command that runs the C compiler, so a
  1137. file `foo.c' would be compiled something like this:
  1138.  
  1139.      cc -c $(CFLAGS) foo.c
  1140.  
  1141.    Thus, whatever value you set for `CFLAGS' affects each compilation
  1142. that occurs.  The makefile probably specifies the usual value for
  1143. `CFLAGS', like this:
  1144.  
  1145.      CFLAGS=-g
  1146.  
  1147.    Each time you run `make', you can override this value if you wish.
  1148. For example, if you say `make CFLAGS='-g -O'', each C compilation will
  1149. be done with `cc -c -g -O'.  (This illustrates how you can use quoting
  1150. in the shell to enclose spaces and other special characters in the
  1151. value of a variable when you override it.)
  1152.  
  1153.    The variable `CFLAGS' is only one of many standard variables that
  1154. exist just so that you can change them this way.  *Note Variables Used
  1155. by Implicit Rules: Implicit Variables, for a complete list.
  1156.  
  1157.    You can also program the makefile to look at additional variables of
  1158. your own, giving the user the ability to control other aspects of how
  1159. the makefile works by changing the variables.
  1160.  
  1161.    When you override a variable with a command argument, you can define
  1162. either a recursively-expanded variable or a simply-expanded variable.
  1163. The examples shown above make a recursively-expanded variable; to make a
  1164. simply-expanded variable, write `:=' instead of `='.  But, unless you
  1165. want to include a variable reference or function call in the *value*
  1166. that you specify, it makes no difference which kind of variable you
  1167. create.
  1168.  
  1169.    There is one way that the makefile can change a variable that you
  1170. have overridden.  This is to use the `override' directive, which is a
  1171. line that looks like this: `override VARIABLE = VALUE' (*note The
  1172. `override' Directive: Override Directive.).
  1173.  
  1174. 
  1175. File: make.info,  Node: Testing,  Next: Options Summary,  Prev: Overriding,  Up: Running
  1176.  
  1177. Testing the Compilation of a Program
  1178. ====================================
  1179.  
  1180.    Normally, when an error happens in executing a shell command, `make'
  1181. gives up immediately, returning a nonzero status.  No further commands
  1182. are executed for any target.  The error implies that the goal cannot be
  1183. correctly remade, and `make' reports this as soon as it knows.
  1184.  
  1185.    When you are compiling a program that you have just changed, this is
  1186. not what you want.  Instead, you would rather that `make' try compiling
  1187. every file that can be tried, to show you as many compilation errors as
  1188. possible.
  1189.  
  1190.    On these occasions, you should use the `-k' or `--keep-going' flag.
  1191. This tells `make' to continue to consider the other dependencies of the
  1192. pending targets, remaking them if necessary, before it gives up and
  1193. returns nonzero status.  For example, after an error in compiling one
  1194. object file, `make -k' will continue compiling other object files even
  1195. though it already knows that linking them will be impossible.  In
  1196. addition to continuing after failed shell commands, `make -k' will
  1197. continue as much as possible after discovering that it does not know
  1198. how to make a target or dependency file.  This will always cause an
  1199. error message, but without `-k', it is a fatal error (*note Summary of
  1200. Options: Options Summary.).
  1201.  
  1202.    The usual behavior of `make' assumes that your purpose is to get the
  1203. goals up to date; once `make' learns that this is impossible, it might
  1204. as well report the failure immediately.  The `-k' flag says that the
  1205. real purpose is to test as much as possible of the changes made in the
  1206. program, perhaps to find several independent problems so that you can
  1207. correct them all before the next attempt to compile.  This is why Emacs'
  1208. `M-x compile' command passes the `-k' flag by default.
  1209.  
  1210.