home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 4 / FreshFish_May-June1994.bin / bbs / gnu / make-3.70-bin.lha / info / make.info-2 < prev    next >
Encoding:
GNU Info File  |  1994-02-21  |  48.8 KB  |  1,222 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.45, last updated 14 December 1993, of `The GNU
  9. Make Manual', for `make', Version 3.70 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: Rule Syntax,  Next: Wildcards,  Prev: Rule Example,  Up: Rules
  30.  
  31. Rule Syntax
  32. ===========
  33.  
  34.    In general, a rule looks like this:
  35.  
  36.      TARGETS : DEPENDENCIES
  37.              COMMAND
  38.              ...
  39.  
  40. or like this:
  41.  
  42.      TARGETS : DEPENDENCIES ; COMMAND
  43.              COMMAND
  44.              ...
  45.  
  46.    The TARGETS are file names, separated by spaces.  Wildcard
  47. characters may be used (*note Using Wildcard Characters in File Names:
  48. Wildcards.) and a name of the form `A(M)' represents member M in
  49. archive file A (*note Archive Members as Targets: Archive Members.).
  50. Usually there is only one target per rule, but occasionally there is a
  51. reason to have more (*note Multiple Targets in a Rule: Multiple
  52. Targets.).
  53.  
  54.    The COMMAND lines start with a tab character.  The first command may
  55. appear on the line after the dependencies, with a tab character, or may
  56. appear on the same line, with a semicolon.  Either way, the effect is
  57. the same.  *Note Writing the Commands in Rules: Commands.
  58.  
  59.    Because dollar signs are used to start variable references, if you
  60. really want a dollar sign in a rule you must write two of them, `$$'
  61. (*note How to Use Variables: Using Variables.).  You may split a long
  62. line by inserting a backslash followed by a newline, but this is not
  63. required, as `make' places no limit on the length of a line in a
  64. makefile.
  65.  
  66.    A rule tells `make' two things: when the targets are out of date,
  67. and how to update them when necessary.
  68.  
  69.    The criterion for being out of date is specified in terms of the
  70. DEPENDENCIES, which consist of file names separated by spaces.
  71. (Wildcards and archive members (*note Archives::.) are allowed here
  72. too.) A target is out of date if it does not exist or if it is older
  73. than any of the dependencies (by comparison of last-modification
  74. times).  The idea is that the contents of the target file are computed
  75. based on information in the dependencies, so if any of the dependencies
  76. changes, the contents of the existing target file are no longer
  77. necessarily valid.
  78.  
  79.    How to update is specified by COMMANDS.  These are lines to be
  80. executed by the shell (normally `sh'), but with some extra features
  81. (*note Writing the Commands in Rules: Commands.).
  82.  
  83. 
  84. File: make.info,  Node: Wildcards,  Next: Directory Search,  Prev: Rule Syntax,  Up: Rules
  85.  
  86. Using Wildcard Characters in File Names
  87. =======================================
  88.  
  89.    A single file name can specify many files using "wildcard
  90. characters".  The wildcard characters in `make' are `*', `?' and
  91. `[...]', the same as in the Bourne shell.  For example, `*.c' specifies
  92. a list of all the files (in the working directory) whose names end in
  93. `.c'.
  94.  
  95.    The character `~' at the beginning of a file name also has special
  96. significance.  If alone, or followed by a slash, it represents your home
  97. directory.  For example `~/bin' expands to `/home/you/bin'.  If the `~'
  98. is followed by a word, the string represents the home directory of the
  99. user named by that word.  For example `~john/bin' expands to
  100. `/home/john/bin'.
  101.  
  102.    Wildcard expansion happens automatically in targets, in dependencies,
  103. and in commands (where the shell does the expansion).  In other
  104. contexts, wildcard expansion happens only if you request it explicitly
  105. with the `wildcard' function.
  106.  
  107.    The special significance of a wildcard character can be turned off by
  108. preceding it with a backslash.  Thus, `foo\*bar' would refer to a
  109. specific file whose name consists of `foo', an asterisk, and `bar'.
  110.  
  111. * Menu:
  112.  
  113. * Wildcard Examples::           Several examples
  114. * Wildcard Pitfall::            Problems to avoid.
  115. * Wildcard Function::           How to cause wildcard expansion where
  116.                                   it does not normally take place.
  117.  
  118. 
  119. File: make.info,  Node: Wildcard Examples,  Next: Wildcard Pitfall,  Up: Wildcards
  120.  
  121. Wildcard Examples
  122. -----------------
  123.  
  124.    Wildcards can be used in the commands of a rule, where they are
  125. expanded by the shell.  For example, here is a rule to delete all the
  126. object files:
  127.  
  128.      clean:
  129.              rm -f *.o
  130.  
  131.    Wildcards are also useful in the dependencies of a rule.  With the
  132. following rule in the makefile, `make print' will print all the `.c'
  133. files that have changed since the last time you printed them:
  134.  
  135.      print: *.c
  136.              lpr -p $?
  137.              touch print
  138.  
  139. This rule uses `print' as an empty target file; see *Note Empty Target
  140. Files to Record Events: Empty Targets.  (The automatic variable `$?' is
  141. used to print only those files that have changed; see *Note Automatic
  142. Variables: Automatic.)
  143.  
  144.    Wildcard expansion does not happen when you define a variable.
  145. Thus, if you write this:
  146.  
  147.      objects = *.o
  148.  
  149. then the value of the variable `objects' is the actual string `*.o'.
  150. However, if you use the value of `objects' in a target, dependency or
  151. command, wildcard expansion will take place at that time.  To set
  152. `objects' to the expansion, instead use:
  153.  
  154.      objects := $(wildcard *.o)
  155.  
  156. *Note Wildcard Function::.
  157.  
  158. 
  159. File: make.info,  Node: Wildcard Pitfall,  Next: Wildcard Function,  Prev: Wildcard Examples,  Up: Wildcards
  160.  
  161. Pitfalls of Using Wildcards
  162. ---------------------------
  163.  
  164.    Now here is an example of a naive way of using wildcard expansion,
  165. that does not do what you would intend.  Suppose you would like to say
  166. that the executable file `foo' is made from all the object files in the
  167. directory, and you write this:
  168.  
  169.      objects = *.o
  170.      
  171.      foo : $(objects)
  172.              cc -o foo $(CFLAGS) $(objects)
  173.  
  174. The value of `objects' is the actual string `*.o'.  Wildcard expansion
  175. happens in the rule for `foo', so that each *existing* `.o' file
  176. becomes a dependency of `foo' and will be recompiled if necessary.
  177.  
  178.    But what if you delete all the `.o' files?  When a wildcard matches
  179. no files, it is left as it is, so then `foo' will depend on the
  180. oddly-named file `*.o'.  Since so such file is likely to exist, `make'
  181. will give you an error saying it cannot figure out how to make `*.o'.
  182. This is not what you want!
  183.  
  184.    Actually it is possible to obtain the desired result with wildcard
  185. expansion, but you need more sophisticated techniques, including the
  186. `wildcard' function and string substitution.  *Note The Function
  187. `wildcard': Wildcard Function.
  188.  
  189. 
  190. File: make.info,  Node: Wildcard Function,  Prev: Wildcard Pitfall,  Up: Wildcards
  191.  
  192. The Function `wildcard'
  193. -----------------------
  194.  
  195.    Wildcard expansion happens automatically in rules.  But wildcard
  196. expansion does not normally take place when a variable is set, or
  197. inside the arguments of a function.  If you want to do wildcard
  198. expansion in such places, you need to use the `wildcard' function, like
  199. this:
  200.  
  201.      $(wildcard PATTERN...)
  202.  
  203. This string, used anywhere in a makefile, is replaced by a
  204. space-separated list of names of existing files that match one of the
  205. given file name patterns.  If no existing file name matches a pattern,
  206. then that pattern is omitted from the output of the `wildcard'
  207. function.  Note that this is different from how unmatched wildcards
  208. behave in rules, where they are used verbatim rather than ignored
  209. (*note Wildcard Pitfall::.).
  210.  
  211.    One use of the `wildcard' function is to get a list of all the C
  212. source files in a directory, like this:
  213.  
  214.      $(wildcard *.c)
  215.  
  216.    We can change the list of C source files into a list of object files
  217. by replacing the `.o' suffix with `.c' in the result, like this:
  218.  
  219.      $(patsubst %.c,%.o,$(wildcard *.c))
  220.  
  221. (Here we have used another function, `patsubst'.  *Note Functions for
  222. String Substitution and Analysis: Text Functions.)
  223.  
  224.    Thus, a makefile to compile all C source files in the directory and
  225. then link them together could be written as follows:
  226.  
  227.      objects := $(patsubst %.c,%.o,$(wildcard *.c))
  228.      
  229.      foo : $(objects)
  230.              cc -o foo $(objects)
  231.  
  232. (This takes advantage of the implicit rule for compiling C programs, so
  233. there is no need to write explicit rules for compiling the files.
  234. *Note The Two Flavors of Variables: Flavors, for an explanation of
  235. `:=', which is a variant of `='.)
  236.  
  237. 
  238. File: make.info,  Node: Directory Search,  Next: Phony Targets,  Prev: Wildcards,  Up: Rules
  239.  
  240. Searching Directories for Dependencies
  241. ======================================
  242.  
  243.    For large systems, it is often desirable to put sources in a separate
  244. directory from the binaries.  The "directory search" features of `make'
  245. facilitate this by searching several directories automatically to find
  246. a dependency.  When you redistribute the files among directories, you
  247. do not need to change the individual rules, just the search paths.
  248.  
  249. * Menu:
  250.  
  251. * General Search::              Specifying a search path that applies
  252.                                   to every dependency.
  253. * Selective Search::            Specifying a search path
  254.                                   for a specified class of names.
  255. * Commands/Search::             How to write shell commands that work together
  256.                                   with search paths.
  257. * Implicit/Search::             How search paths affect implicit rules.
  258. * Libraries/Search::            Directory search for link libraries.
  259.  
  260. 
  261. File: make.info,  Node: General Search,  Next: Selective Search,  Up: Directory Search
  262.  
  263. `VPATH': Search Path for All Dependencies
  264. -----------------------------------------
  265.  
  266.    The value of the `make' variable `VPATH' specifies a list of
  267. directories that `make' should search.  Most often, the directories are
  268. expected to contain dependency files that are not in the current
  269. directory; however, `VPATH' specifies a search list that `make' applies
  270. for all files, including files which are targets of rules.
  271.  
  272.    Thus, if a file that is listed as a target or dependency does not
  273. exist in the current directory, `make' searches the directories listed
  274. in `VPATH' for a file with that name.  If a file is found in one of
  275. them, that file becomes the dependency.  Rules may then specify the
  276. names of source files in the dependencies as if they all existed in the
  277. current directory.  *Note Writing Shell Commands with Directory Search:
  278. Commands/Search.
  279.  
  280.    In the `VPATH' variable, directory names are separated by colons.
  281. The order in which directories are listed is the order followed by
  282. `make' in its search.
  283.  
  284.    For example,
  285.  
  286.      VPATH = src:../headers
  287.  
  288. specifies a path containing two directories, `src' and `../headers',
  289. which `make' searches in that order.
  290.  
  291.    With this value of `VPATH', the following rule,
  292.  
  293.      foo.o : foo.c
  294.  
  295. is interpreted as if it were written like this:
  296.  
  297.      foo.o : src/foo.c
  298.  
  299. assuming the file `foo.c' does not exist in the current directory but
  300. is found in the directory `src'.
  301.  
  302. 
  303. File: make.info,  Node: Selective Search,  Next: Commands/Search,  Prev: General Search,  Up: Directory Search
  304.  
  305. The `vpath' Directive
  306. ---------------------
  307.  
  308.    Similar to the `VPATH' variable but more selective is the `vpath'
  309. directive (note lower case), which allows you to specify a search path
  310. for a particular class of file names, those that match a particular
  311. pattern.  Thus you can supply certain search directories for one class
  312. of file names and other directories (or none) for other file names.
  313.  
  314.    There are three forms of the `vpath' directive:
  315.  
  316. `vpath PATTERN DIRECTORIES'
  317.      Specify the search path DIRECTORIES for file names that match
  318.      PATTERN.
  319.  
  320.      The search path, DIRECTORIES, is a colon-separated list of
  321.      directories to be searched, just like the search path used in the
  322.      `VPATH' variable.
  323.  
  324. `vpath PATTERN'
  325.      Clear out the search path associated with PATTERN.
  326.  
  327. `vpath'
  328.      Clear all search paths previously specified with `vpath'
  329.      directives.
  330.  
  331.    A `vpath' pattern is a string containing a `%' character.  The
  332. string must match the file name of a dependency that is being searched
  333. for, the `%' character matching any sequence of zero or more characters
  334. (as in pattern rules; *note Defining and Redefining Pattern Rules:
  335. Pattern Rules.).  For example, `%.h' matches files that end in `.h'.
  336. (If there is no `%', the pattern must match the dependency exactly,
  337. which is not useful very often.)
  338.  
  339.    `%' characters in a `vpath' directive's pattern can be quoted with
  340. preceding backslashes (`\').  Backslashes that would otherwise quote
  341. `%' characters can be quoted with more backslashes.  Backslashes that
  342. quote `%' characters or other backslashes are removed from the pattern
  343. before it is compared to file names.  Backslashes that are not in
  344. danger of quoting `%' characters go unmolested.
  345.  
  346.    When a dependency fails to exist in the current directory, if the
  347. PATTERN in a `vpath' directive matches the name of the dependency file,
  348. then the DIRECTORIES in that directive are searched just like (and
  349. before) the directories in the `VPATH' variable.
  350.  
  351.    For example,
  352.  
  353.      vpath %.h ../headers
  354.  
  355. tells `make' to look for any dependency whose name ends in `.h' in the
  356. directory `../headers' if the file is not found in the current
  357. directory.
  358.  
  359.    If several `vpath' patterns match the dependency file's name, then
  360. `make' processes each matching `vpath' directive one by one, searching
  361. all the directories mentioned in each directive.  `make' handles
  362. multiple `vpath' directives in the order in which they appear in the
  363. makefile; multiple directives with the same pattern are independent of
  364. each other.
  365.  
  366.    Thus,
  367.  
  368.      vpath %.c foo
  369.      vpath %   blish
  370.      vpath %.c bar
  371.  
  372. will look for a file ending in `.c' in `foo', then `blish', then `bar',
  373. while
  374.  
  375.      vpath %.c foo:bar
  376.      vpath %   blish
  377.  
  378. will look for a file ending in `.c' in `foo', then `bar', then `blish'.
  379.  
  380. 
  381. File: make.info,  Node: Commands/Search,  Next: Implicit/Search,  Prev: Selective Search,  Up: Directory Search
  382.  
  383. Writing Shell Commands with Directory Search
  384. --------------------------------------------
  385.  
  386.    When a dependency is found in another directory through directory
  387. search, this cannot change the commands of the rule; they will execute
  388. as written.  Therefore, you must write the commands with care so that
  389. they will look for the dependency in the directory where `make' finds
  390. it.
  391.  
  392.    This is done with the "automatic variables" such as `$^' (*note
  393. Automatic Variables: Automatic.).  For instance, the value of `$^' is a
  394. list of all the dependencies of the rule, including the names of the
  395. directories in which they were found, and the value of `$@' is the
  396. target.  Thus:
  397.  
  398.      foo.o : foo.c
  399.              cc -c $(CFLAGS) $^ -o $@
  400.  
  401. (The variable `CFLAGS' exists so you can specify flags for C
  402. compilation by implicit rules; we use it here for consistency so it will
  403. affect all C compilations uniformly; *note Variables Used by Implicit
  404. Rules: Implicit Variables..)
  405.  
  406.    Often the dependencies include header files as well, which you do not
  407. want to mention in the commands.  The automatic variable `$<' is just
  408. the first dependency:
  409.  
  410.      VPATH = src:../headers
  411.      foo.o : foo.c defs.h hack.h
  412.              cc -c $(CFLAGS) $< -o $@
  413.  
  414. 
  415. File: make.info,  Node: Implicit/Search,  Next: Libraries/Search,  Prev: Commands/Search,  Up: Directory Search
  416.  
  417. Directory Search and Implicit Rules
  418. -----------------------------------
  419.  
  420.    The search through the directories specified in `VPATH' or with
  421. `vpath' also happens during consideration of implicit rules (*note
  422. Using Implicit Rules: Implicit Rules.).
  423.  
  424.    For example, when a file `foo.o' has no explicit rule, `make'
  425. considers implicit rules, such as the built-in rule to compile `foo.c'
  426. if that file exists.  If such a file is lacking in the current
  427. directory, the appropriate directories are searched for it.  If `foo.c'
  428. exists (or is mentioned in the makefile) in any of the directories, the
  429. implicit rule for C compilation is applied.
  430.  
  431.    The commands of implicit rules normally use automatic variables as a
  432. matter of necessity; consequently they will use the file names found by
  433. directory search with no extra effort.
  434.  
  435. 
  436. File: make.info,  Node: Libraries/Search,  Prev: Implicit/Search,  Up: Directory Search
  437.  
  438. Directory Search for Link Libraries
  439. -----------------------------------
  440.  
  441.    Directory search applies in a special way to libraries used with the
  442. linker.  This special feature comes into play when you write a
  443. dependency whose name is of the form `-lNAME'.  (You can tell something
  444. strange is going on here because the dependency is normally the name of
  445. a file, and the *file name* of the library looks like `libNAME.a', not
  446. like `-lNAME'.)
  447.  
  448.    When a dependency's name has the form `-lNAME', `make' handles it
  449. specially by searching for the file `libNAME.a' in the current
  450. directory, in directories specified by matching `vpath' search paths
  451. and the `VPATH' search path, and then in the directories `/lib',
  452. `/usr/lib', and `PREFIX/lib' (normally `/usr/local/lib').
  453.  
  454.    For example,
  455.  
  456.      foo : foo.c -lcurses
  457.              cc $^ -o $@
  458.  
  459. would cause the command `cc foo.c /usr/lib/libcurses.a -o foo' to be
  460. executed when `foo' is older than `foo.c' or than
  461. `/usr/lib/libcurses.a'.
  462.  
  463. 
  464. File: make.info,  Node: Phony Targets,  Next: Force Targets,  Prev: Directory Search,  Up: Rules
  465.  
  466. Phony Targets
  467. =============
  468.  
  469.    A phony target is one that is not really the name of a file.  It is
  470. just a name for some commands to be executed when you make an explicit
  471. request.  There are two reasons to use a phony target: to avoid a
  472. conflict with a file of the same name, and to improve performance.
  473.  
  474.    If you write a rule whose commands will not create the target file,
  475. the commands will be executed every time the target comes up for
  476. remaking.  Here is an example:
  477.  
  478.      clean:
  479.              rm *.o temp
  480.  
  481. Because the `rm' command does not create a file named `clean', probably
  482. no such file will ever exist.  Therefore, the `rm' command will be
  483. executed every time you say `make clean'.
  484.  
  485.    The phony target will cease to work if anything ever does create a
  486. file named `clean' in this directory.  Since it has no dependencies, the
  487. file `clean' would inevitably be considered up to date, and its
  488. commands would not be executed.  To avoid this problem, you can
  489. explicitly declare the target to be phony, using the special target
  490. `.PHONY' (*note Special Built-in Target Names: Special Targets.) as
  491. follows:
  492.  
  493.      .PHONY : clean
  494.  
  495. Once this is done, `make clean' will run the commands regardless of
  496. whether there is a file named `clean'.
  497.  
  498.    Since it knows that phony targets do not name actual files that
  499. could be remade from other files, `make' skips the implicit rule search
  500. for phony targets (*note Implicit Rules::.).  This is why declaring a
  501. target phony is good for performance, even if you are not worried about
  502. the actual file existing.
  503.  
  504.    Thus, you first write the line that states that `clean' is a phony
  505. target, then you write the rule, like this:
  506.  
  507.      .PHONY: clean
  508.      clean:
  509.              rm *.o temp
  510.  
  511.    A phony target should not be a dependency of a real target file; if
  512. it is, its commands are run every time `make' goes to update that file.
  513. As long as a phony target is never a dependency of a real target, the
  514. phony target commands will be executed only when the phony target is a
  515. specified goal (*note Arguments to Specify the Goals: Goals.).
  516.  
  517.    Phony targets can have dependencies.  When one directory contains
  518. multiple programs, it is most convenient to describe all of the
  519. programs in one makefile `./Makefile'.  Since the target remade by
  520. default will be the first one in the makefile, it is common to make
  521. this a phony target named `all' and give it, as dependencies, all the
  522. individual programs.  For example:
  523.  
  524.      all : prog1 prog2 prog3
  525.      .PHONY : all
  526.      
  527.      prog1 : prog1.o utils.o
  528.              cc -o prog1 prog1.o utils.o
  529.      
  530.      prog2 : prog2.o
  531.              cc -o prog2 prog2.o
  532.      
  533.      prog3 : prog3.o sort.o utils.o
  534.              cc -o prog3 prog3.o sort.o utils.o
  535.  
  536. Now you can say just `make' to remake all three programs, or specify as
  537. arguments the ones to remake (as in `make prog1 prog3').
  538.  
  539.    When one phony target is a dependency of another, it serves as a
  540. subroutine of the other.  For example, here `make cleanall' will delete
  541. the object files, the difference files, and the file `program':
  542.  
  543.      .PHONY: cleanall cleanobj cleandiff
  544.      
  545.      cleanall : cleanobj cleandiff
  546.              rm program
  547.      
  548.      cleanobj :
  549.              rm *.o
  550.      
  551.      cleandiff :
  552.              rm *.diff
  553.  
  554. 
  555. File: make.info,  Node: Force Targets,  Next: Empty Targets,  Prev: Phony Targets,  Up: Rules
  556.  
  557. Rules without Commands or Dependencies
  558. ======================================
  559.  
  560.    If a rule has no dependencies or commands, and the target of the rule
  561. is a nonexistent file, then `make' imagines this target to have been
  562. updated whenever its rule is run.  This implies that all targets
  563. depending on this one will always have their commands run.
  564.  
  565.    An example will illustrate this:
  566.  
  567.      clean: FORCE
  568.              rm $(objects)
  569.      FORCE:
  570.  
  571.    Here the target `FORCE' satisfies the special conditions, so the
  572. target `clean' that depends on it is forced to run its commands.  There
  573. is nothing special about the name `FORCE', but that is one name
  574. commonly used this way.
  575.  
  576.    As you can see, using `FORCE' this way has the same results as using
  577. `.PHONY: clean'.
  578.  
  579.    Using `.PHONY' is more explicit and more efficient.  However, other
  580. versions of `make' do not support `.PHONY'; thus `FORCE' appears in
  581. many makefiles.  *Note Phony Targets::.
  582.  
  583. 
  584. File: make.info,  Node: Empty Targets,  Next: Special Targets,  Prev: Force Targets,  Up: Rules
  585.  
  586. Empty Target Files to Record Events
  587. ===================================
  588.  
  589.    The "empty target" is a variant of the phony target; it is used to
  590. hold commands for an action that you request explicitly from time to
  591. time.  Unlike a phony target, this target file can really exist; but
  592. the file's contents do not matter, and usually are empty.
  593.  
  594.    The purpose of the empty target file is to record, with its
  595. last-modification time, when the rule's commands were last executed.  It
  596. does so because one of the commands is a `touch' command to update the
  597. target file.
  598.  
  599.    The empty target file must have some dependencies.  When you ask to
  600. remake the empty target, the commands are executed if any dependency is
  601. more recent than the target; in other words, if a dependency has
  602. changed since the last time you remade the target.  Here is an example:
  603.  
  604.      print: foo.c bar.c
  605.              lpr -p $?
  606.              touch print
  607.  
  608. With this rule, `make print' will execute the `lpr' command if either
  609. source file has changed since the last `make print'.  The automatic
  610. variable `$?' is used to print only those files that have changed
  611. (*note Automatic Variables: Automatic.).
  612.  
  613. 
  614. File: make.info,  Node: Special Targets,  Next: Multiple Targets,  Prev: Empty Targets,  Up: Rules
  615.  
  616. Special Built-in Target Names
  617. =============================
  618.  
  619.    Certain names have special meanings if they appear as targets.
  620.  
  621. `.PHONY'
  622.      The dependencies of the special target `.PHONY' are considered to
  623.      be phony targets.  When it is time to consider such a target,
  624.      `make' will run its commands unconditionally, regardless of
  625.      whether a file with that name exists or what its last-modification
  626.      time is.  *Note Phony Targets: Phony Targets.
  627.  
  628. `.SUFFIXES'
  629.      The dependencies of the special target `.SUFFIXES' are the list of
  630.      suffixes to be used in checking for suffix rules.  *Note
  631.      Old-Fashioned Suffix Rules: Suffix Rules.
  632.  
  633. `.DEFAULT'
  634.      The commands specified for `.DEFAULT' are used for any target for
  635.      which no rules are found (either explicit rules or implicit rules).
  636.      *Note Last Resort::.  If `.DEFAULT' commands are specified, every
  637.      file mentioned as a dependency, but not as a target in a rule,
  638.      will have these commands executed on its behalf.  *Note Implicit
  639.      Rule Search Algorithm: Search Algorithm.
  640.  
  641. `.PRECIOUS'
  642.      The targets which `.PRECIOUS' depends on are given the following
  643.      special treatment: if `make' is killed or interrupted during the
  644.      execution of their commands, the target is not deleted.  *Note
  645.      Interrupting or Killing `make': Interrupts.  Also, if the target
  646.      is an intermediate file, it will not be deleted after it is no
  647.      longer needed, as is normally done.  *Note Chains of Implicit
  648.      Rules: Chained Rules.
  649.  
  650.      You can also list the target pattern of an implicit rule (such as
  651.      `%.o') as a dependency file of the special target `.PRECIOUS' to
  652.      preserve intermediate files created by rules whose target patterns
  653.      match that file's name.
  654.  
  655. `.IGNORE'
  656.      Simply by being mentioned as a target, `.IGNORE' says to ignore
  657.      errors in execution of commands.  The dependencies and commands for
  658.      `.IGNORE' are not meaningful.
  659.  
  660.      `.IGNORE' exists for historical compatibility.  Since `.IGNORE'
  661.      affects every command in the makefile, it is not very useful; we
  662.      recommend you use the more selective ways to ignore errors in
  663.      specific commands.  *Note Errors in Commands: Errors.
  664.  
  665. `.SILENT'
  666.      Simply by being mentioned as a target, `.SILENT' says not to print
  667.      commands before executing them.  The dependencies and commands for
  668.      `.SILENT' are not meaningful.
  669.  
  670.      `.SILENT' exists for historical compatibility.  We recommend you
  671.      use the more selective ways to silence specific commands.  *Note
  672.      Command Echoing: Echoing.  If you want to silence all commands for
  673.      a particular run of `make', use the `-s' or `--silent' option
  674.      (*note Options Summary::.).
  675.  
  676. `.EXPORT_ALL_VARIABLES'
  677.      Simply by being mentioned as a target, this tells `make' to export
  678.      all variables to child processes by default.  *Note Communicating
  679.      Variables to a Sub-`make': Variables/Recursion.
  680.  
  681.    Any defined implicit rule suffix also counts as a special target if
  682. it appears as a target, and so does the concatenation of two suffixes,
  683. such as `.c.o'.  These targets are suffix rules, an obsolete way of
  684. defining implicit rules (but a way still widely used).  In principle,
  685. any target name could be special in this way if you break it in two and
  686. add both pieces to the suffix list.  In practice, suffixes normally
  687. begin with `.', so these special target names also begin with `.'.
  688. *Note Old-Fashioned Suffix Rules: Suffix Rules.
  689.  
  690. 
  691. File: make.info,  Node: Multiple Targets,  Next: Multiple Rules,  Prev: Special Targets,  Up: Rules
  692.  
  693. Multiple Targets in a Rule
  694. ==========================
  695.  
  696.    A rule with multiple targets is equivalent to writing many rules,
  697. each with one target, and all identical aside from that.  The same
  698. commands apply to all the targets, but their effects may vary because
  699. you can substitute the actual target name into the command using `$@'.
  700. The rule contributes the same dependencies to all the targets also.
  701.  
  702.    This is useful in two cases.
  703.  
  704.    * You want just dependencies, no commands.  For example:
  705.  
  706.           kbd.o command.o files.o: command.h
  707.  
  708.      gives an additional dependency to each of the three object files
  709.      mentioned.
  710.  
  711.    * Similar commands work for all the targets.  The commands do not
  712.      need to be absolutely identical, since the automatic variable `$@'
  713.      can be used to substitute the particular target to be remade into
  714.      the commands (*note Automatic Variables: Automatic.).  For example:
  715.  
  716.           bigoutput littleoutput : text.g
  717.                   generate text.g -$(subst output,,$@) > $@
  718.  
  719.      is equivalent to
  720.  
  721.           bigoutput : text.g
  722.                   generate text.g -big > bigoutput
  723.           littleoutput : text.g
  724.                   generate text.g -little > littleoutput
  725.  
  726.      Here we assume the hypothetical program `generate' makes two types
  727.      of output, one if given `-big' and one if given `-little'.  *Note
  728.      Functions for String Substitution and Analysis: Text Functions,
  729.      for an explanation of the `subst' function.
  730.  
  731.    Suppose you would like to vary the dependencies according to the
  732. target, much as the variable `$@' allows you to vary the commands.  You
  733. cannot do this with multiple targets in an ordinary rule, but you can
  734. do it with a "static pattern rule".  *Note Static Pattern Rules: Static
  735. Pattern.
  736.  
  737. 
  738. File: make.info,  Node: Multiple Rules,  Next: Static Pattern,  Prev: Multiple Targets,  Up: Rules
  739.  
  740. Multiple Rules for One Target
  741. =============================
  742.  
  743.    One file can be the target of several rules.  All the dependencies
  744. mentioned in all the rules are merged into one list of dependencies for
  745. the target.  If the target is older than any dependency from any rule,
  746. the commands are executed.
  747.  
  748.    There can only be one set of commands to be executed for a file.  If
  749. more than one rule gives commands for the same file, `make' uses the
  750. last set given and prints an error message.  (As a special case, if the
  751. file's name begins with a dot, no error message is printed.  This odd
  752. behavior is only for compatibility with other implementations of
  753. `make'.) There is no reason to write your makefiles this way; that is
  754. why `make' gives you an error message.
  755.  
  756.    An extra rule with just dependencies can be used to give a few extra
  757. dependencies to many files at once.  For example, one usually has a
  758. variable named `objects' containing a list of all the compiler output
  759. files in the system being made.  An easy way to say that all of them
  760. must be recompiled if `config.h' changes is to write the following:
  761.  
  762.      objects = foo.o bar.o
  763.      foo.o : defs.h
  764.      bar.o : defs.h test.h
  765.      $(objects) : config.h
  766.  
  767.    This could be inserted or taken out without changing the rules that
  768. really specify how to make the object files, making it a convenient
  769. form to use if you wish to add the additional dependency intermittently.
  770.  
  771.    Another wrinkle is that the additional dependencies could be
  772. specified with a variable that you set with a command argument to `make'
  773. (*note Overriding Variables: Overriding.).  For example,
  774.  
  775.      extradeps=
  776.      $(objects) : $(extradeps)
  777.  
  778. means that the command `make extradeps=foo.h' will consider `foo.h' as
  779. a dependency of each object file, but plain `make' will not.
  780.  
  781.    If none of the explicit rules for a target has commands, then `make'
  782. searches for an applicable implicit rule to find some commands *note
  783. Using Implicit Rules: Implicit Rules.).
  784.  
  785. 
  786. File: make.info,  Node: Static Pattern,  Next: Double-Colon,  Prev: Multiple Rules,  Up: Rules
  787.  
  788. Static Pattern Rules
  789. ====================
  790.  
  791.    "Static pattern rules" are rules which specify multiple targets and
  792. construct the dependency names for each target based on the target name.
  793. They are more general than ordinary rules with multiple targets because
  794. the targets do not have to have identical dependencies.  Their
  795. dependencies must be *analogous*, but not necessarily *identical*.
  796.  
  797. * Menu:
  798.  
  799. * Static Usage::                The syntax of static pattern rules.
  800. * Static versus Implicit::      When are they better than implicit rules?
  801.  
  802. 
  803. File: make.info,  Node: Static Usage,  Next: Static versus Implicit,  Up: Static Pattern
  804.  
  805. Syntax of Static Pattern Rules
  806. ------------------------------
  807.  
  808.    Here is the syntax of a static pattern rule:
  809.  
  810.      TARGETS ...: TARGET-PATTERN: DEP-PATTERNS ...
  811.              COMMANDS
  812.              ...
  813.  
  814. The TARGETS list specifies the targets that the rule applies to.  The
  815. targets can contain wildcard characters, just like the targets of
  816. ordinary rules (*note Using Wildcard Characters in File Names:
  817. Wildcards.).
  818.  
  819.    The TARGET-PATTERN and DEP-PATTERNS say how to compute the
  820. dependencies of each target.  Each target is matched against the
  821. TARGET-PATTERN to extract a part of the target name, called the "stem".
  822. This stem is substituted into each of the DEP-PATTERNS to make the
  823. dependency names (one from each DEP-PATTERN).
  824.  
  825.    Each pattern normally contains the character `%' just once.  When the
  826. TARGET-PATTERN matches a target, the `%' can match any part of the
  827. target name; this part is called the "stem".  The rest of the pattern
  828. must match exactly.  For example, the target `foo.o' matches the
  829. pattern `%.o', with `foo' as the stem.  The targets `foo.c' and
  830. `foo.out' do not match that pattern.
  831.  
  832.    The dependency names for each target are made by substituting the
  833. stem for the `%' in each dependency pattern.  For example, if one
  834. dependency pattern is `%.c', then substitution of the stem `foo' gives
  835. the dependency name `foo.c'.  It is legitimate to write a dependency
  836. pattern that does not contain `%'; then this dependency is the same for
  837. all targets.
  838.  
  839.    `%' characters in pattern rules can be quoted with preceding
  840. backslashes (`\').  Backslashes that would otherwise quote `%'
  841. characters can be quoted with more backslashes.  Backslashes that quote
  842. `%' characters or other backslashes are removed from the pattern before
  843. it is compared to file names or has a stem substituted into it.
  844. Backslashes that are not in danger of quoting `%' characters go
  845. unmolested.  For example, the pattern `the\%weird\\%pattern\\' has
  846. `the%weird\' preceding the operative `%' character, and `pattern\\'
  847. following it.  The final two backslashes are left alone because they
  848. cannot affect any `%' character.
  849.  
  850.    Here is an example, which compiles each of `foo.o' and `bar.o' from
  851. the corresponding `.c' file:
  852.  
  853.      objects = foo.o bar.o
  854.      
  855.      $(objects): %.o: %.c
  856.              $(CC) -c $(CFLAGS) $< -o $@
  857.  
  858. Here `$<' is the automatic variable that holds the name of the
  859. dependency and `$@' is the automatic variable that holds the name of
  860. the target; see *Note Automatic Variables: Automatic.
  861.  
  862.    Each target specified must match the target pattern; a warning is
  863. issued for each target that does not.  If you have a list of files,
  864. only some of which will match the pattern, you can use the `filter'
  865. function to remove nonmatching file names (*note Functions for String
  866. Substitution and Analysis: Text Functions.):
  867.  
  868.      files = foo.elc bar.o lose.o
  869.      
  870.      $(filter %.o,$(files)): %.o: %.c
  871.              $(CC) -c $(CFLAGS) $< -o $@
  872.      $(filter %.elc,$(files)): %.elc: %.el
  873.              emacs -f batch-byte-compile $<
  874.  
  875. In this example the result of `$(filter %.o,$(files))' is `bar.o
  876. lose.o', and the first static pattern rule causes each of these object
  877. files to be updated by compiling the corresponding C source file.  The
  878. result of `$(filter %.elc,$(files))' is `foo.elc', so that file is made
  879. from `foo.el'.
  880.  
  881.    Another example shows how to use `$*' in static pattern rules:
  882.  
  883.      bigoutput littleoutput : %output : text.g
  884.              generate text.g -$* > $@
  885.  
  886. When the `generate' command is run, `$*' will expand to the stem,
  887. either `big' or `little'.
  888.  
  889. 
  890. File: make.info,  Node: Static versus Implicit,  Prev: Static Usage,  Up: Static Pattern
  891.  
  892. Static Pattern Rules versus Implicit Rules
  893. ------------------------------------------
  894.  
  895.    A static pattern rule has much in common with an implicit rule
  896. defined as a pattern rule (*note Defining and Redefining Pattern Rules:
  897. Pattern Rules.).  Both have a pattern for the target and patterns for
  898. constructing the names of dependencies.  The difference is in how
  899. `make' decides *when* the rule applies.
  900.  
  901.    An implicit rule *can* apply to any target that matches its pattern,
  902. but it *does* apply only when the target has no commands otherwise
  903. specified, and only when the dependencies can be found.  If more than
  904. one implicit rule appears applicable, only one applies; the choice
  905. depends on the order of rules.
  906.  
  907.    By contrast, a static pattern rule applies to the precise list of
  908. targets that you specify in the rule.  It cannot apply to any other
  909. target and it invariably does apply to each of the targets specified.
  910. If two conflicting rules apply, and both have commands, that's an error.
  911.  
  912.    The static pattern rule can be better than an implicit rule for these
  913. reasons:
  914.  
  915.    * You may wish to override the usual implicit rule for a few files
  916.      whose names cannot be categorized syntactically but can be given
  917.      in an explicit list.
  918.  
  919.    * If you cannot be sure of the precise contents of the directories
  920.      you are using, you may not be sure which other irrelevant files
  921.      might lead `make' to use the wrong implicit rule.  The choice
  922.      might depend on the order in which the implicit rule search is
  923.      done.  With static pattern rules, there is no uncertainty: each
  924.      rule applies to precisely the targets specified.
  925.  
  926. 
  927. File: make.info,  Node: Double-Colon,  Next: Automatic Dependencies,  Prev: Static Pattern,  Up: Rules
  928.  
  929. Double-Colon Rules
  930. ==================
  931.  
  932.    "Double-colon" rules are rules written with `::' instead of `:'
  933. after the target names.  They are handled differently from ordinary
  934. rules when the same target appears in more than one rule.
  935.  
  936.    When a target appears in multiple rules, all the rules must be the
  937. same type: all ordinary, or all double-colon.  If they are
  938. double-colon, each of them is independent of the others.  Each
  939. double-colon rule's commands are executed if the target is older than
  940. any dependencies of that rule.  This can result in executing none, any,
  941. or all of the double-colon rules.
  942.  
  943.    Double-colon rules with the same target are in fact completely
  944. separate from one another.  Each double-colon rule is processed
  945. individually, just as rules with different targets are processed.
  946.  
  947.    The double-colon rules for a target are executed in the order they
  948. appear in the makefile.  However, the cases where double-colon rules
  949. really make sense are those where the order of executing the commands
  950. would not matter.
  951.  
  952.    Double-colon rules are somewhat obscure and not often very useful;
  953. they provide a mechanism for cases in which the method used to update a
  954. target differs depending on which dependency files caused the update,
  955. and such cases are rare.
  956.  
  957.    Each double-colon rule should specify commands; if it does not, an
  958. implicit rule will be used if one applies.  *Note Using Implicit Rules:
  959. Implicit Rules.
  960.  
  961. 
  962. File: make.info,  Node: Automatic Dependencies,  Prev: Double-Colon,  Up: Rules
  963.  
  964. Generating Dependencies Automatically
  965. =====================================
  966.  
  967.    In the makefile for a program, many of the rules you need to write
  968. often say only that some object file depends on some header file.  For
  969. example, if `main.c' uses `defs.h' via an `#include', you would write:
  970.  
  971.      main.o: defs.h
  972.  
  973. You need this rule so that `make' knows that it must remake `main.o'
  974. whenever `defs.h' changes.  You can see that for a large program you
  975. would have to write dozens of such rules in your makefile.  And, you
  976. must always be very careful to update the makefile every time you add
  977. or remove an `#include'.
  978.  
  979.    To avoid this hassle, most modern C compilers can write these rules
  980. for you, by looking at the `#include' lines in the source files.
  981. Usually this is done with the `-M' option to the compiler.  For
  982. example, the command:
  983.  
  984.      cc -M main.c
  985.  
  986. generates the output:
  987.  
  988.      main.o : main.c defs.h
  989.  
  990. Thus you no longer have to write all those rules yourself.  The
  991. compiler will do it for you.
  992.  
  993.    With old `make' programs, it was traditional practice to use this
  994. compiler feature to generate dependencies on demand with a command like
  995. `make depend'.  That command would create a file `depend' containing
  996. all the automatically-generated dependencies; then the makefile could
  997. use `include' to read them in (*note Include::.).
  998.  
  999.    In GNU `make', the feature of remaking makefiles makes this practice
  1000. obsolete--you need never tell `make' explicitly to regenerate the
  1001. dependencies, because it always regenerates any makefile that is out of
  1002. date.  *Note Remaking Makefiles::.
  1003.  
  1004.    The practice we recommend for automatic dependency generation is to
  1005. have one makefile corresponding to each source file.  For each source
  1006. file `NAME.c' there is a makefile `NAME.d' which lists what files the
  1007. object file `NAME.o' depends on.  That way only the source files that
  1008. have changed need to be rescanned to produce the new dependencies.
  1009.  
  1010.    Here is the pattern rule to generate a file of dependencies (i.e., a
  1011. makefile) called `NAME.d' from a C source file called `NAME.c':
  1012.  
  1013.      %.d: %.c
  1014.              $(SHELL) -ec '$(CC) -M $(CPPFLAGS) $< | sed '\''s/$*.o/& $@/g'\'' > $@'
  1015.  
  1016. *Note Pattern Rules::, for information on defining pattern rules.  The
  1017. `-e' flag to the shell makes it exit immediately if the `$(CC)' command
  1018. fails (exits with a nonzero status).  Normally the shell exits with the
  1019. status of the last command in the pipeline (`sed' in this case), so
  1020. `make' would not notice a nonzero status from the compiler.
  1021.  
  1022.    The purpose of the `sed' command is to translate (for example):
  1023.  
  1024.      main.o : main.c defs.h
  1025.  
  1026. into:
  1027.  
  1028.      main.o main.d : main.c defs.h
  1029.  
  1030. This makes each `.d' file depend on all the source and header files
  1031. that the corresponding `.o' file depends on.  `make' then knows it must
  1032. regenerate the dependencies whenever any of the source or header files
  1033. changes.
  1034.  
  1035.    Once you've defined the rule to remake the `.d' files, you then use
  1036. the `include' directive to read them all in.  *Note Include::.  For
  1037. example:
  1038.  
  1039.      sources = foo.c bar.c
  1040.      
  1041.      include $(sources:.c=.d)
  1042.  
  1043. (This example uses a substitution variable reference to translate the
  1044. list of source files `foo.c bar.c' into a list of dependency makefiles,
  1045. `foo.d bar.d'.  *Note Substitution Refs::, for full information on
  1046. substitution references.)  Since the `.d' files are makefiles like any
  1047. others, `make' will remake them as necessary with no further work from
  1048. you.  *Note Remaking Makefiles::.
  1049.  
  1050. 
  1051. File: make.info,  Node: Commands,  Next: Using Variables,  Prev: Rules,  Up: Top
  1052.  
  1053. Writing the Commands in Rules
  1054. *****************************
  1055.  
  1056.    The commands of a rule consist of shell command lines to be executed
  1057. one by one.  Each command line must start with a tab, except that the
  1058. first command line may be attached to the target-and-dependencies line
  1059. with a semicolon in between.  Blank lines and lines of just comments
  1060. may appear among the command lines; they are ignored.
  1061.  
  1062.    Users use many different shell programs, but commands in makefiles
  1063. are always interpreted by `/bin/sh' unless the makefile specifies
  1064. otherwise.  *Note Command Execution: Execution.
  1065.  
  1066.    The shell that is in use determines whether comments can be written
  1067. on command lines, and what syntax they use.  When the shell is
  1068. `/bin/sh', a `#' starts a comment that extends to the end of the line.
  1069. The `#' does not have to be at the beginning of a line.  Text on a line
  1070. before a `#' is not part of the comment.
  1071.  
  1072. * Menu:
  1073.  
  1074. * Echoing::                     How to control when commands are echoed.
  1075. * Execution::                   How commands are executed.
  1076. * Parallel::                    How commands can be executed in parallel.
  1077. * Errors::                      What happens after a command execution error.
  1078. * Interrupts::                  What happens when a command is interrupted.
  1079. * Recursion::                   Invoking `make' from makefiles.
  1080. * Sequences::                   Defining canned sequences of commands.
  1081. * Empty Commands::              Defining useful, do-nothing commands.
  1082.  
  1083. 
  1084. File: make.info,  Node: Echoing,  Next: Execution,  Up: Commands
  1085.  
  1086. Command Echoing
  1087. ===============
  1088.  
  1089.    Normally `make' prints each command line before it is executed.  We
  1090. call this "echoing" because it gives the appearance that you are typing
  1091. the commands yourself.
  1092.  
  1093.    When a line starts with `@', the echoing of that line is suppressed.
  1094. The `@' is discarded before the command is passed to the shell.
  1095. Typically you would use this for a command whose only effect is to print
  1096. something, such as an `echo' command to indicate progress through the
  1097. makefile:
  1098.  
  1099.      @echo About to make distribution files
  1100.  
  1101.    When `make' is given the flag `-n' or `--just-print', echoing is all
  1102. that happens, no execution.  *Note Summary of Options: Options Summary.
  1103. In this case and only this case, even the commands starting with `@'
  1104. are printed.  This flag is useful for finding out which commands `make'
  1105. thinks are necessary without actually doing them.
  1106.  
  1107.    The `-s' or `--silent' flag to `make' prevents all echoing, as if
  1108. all commands started with `@'.  A rule in the makefile for the special
  1109. target `.SILENT' has the same effect (*note Special Built-in Target
  1110. Names: Special Targets.).  `.SILENT' is essentially obsolete since `@'
  1111. is more flexible.
  1112.  
  1113. 
  1114. File: make.info,  Node: Execution,  Next: Parallel,  Prev: Echoing,  Up: Commands
  1115.  
  1116. Command Execution
  1117. =================
  1118.  
  1119.    When it is time to execute commands to update a target, they are
  1120. executed by making a new subshell for each line.  (In practice, `make'
  1121. may take shortcuts that do not affect the results.)
  1122.  
  1123.    *Please note:* this implies that shell commands such as `cd' that
  1124. set variables local to each process will not affect the following
  1125. command lines.  If you want to use `cd' to affect the next command, put
  1126. the two on a single line with a semicolon between them.  Then `make'
  1127. will consider them a single command and pass them, together, to a shell
  1128. which will execute them in sequence.  For example:
  1129.  
  1130.      foo : bar/lose
  1131.              cd bar; gobble lose > ../foo
  1132.  
  1133.    If you would like to split a single shell command into multiple
  1134. lines of text, you must use a backslash at the end of all but the last
  1135. subline.  Such a sequence of lines is combined into a single line, by
  1136. deleting the backslash-newline sequences, before passing it to the
  1137. shell.  Thus, the following is equivalent to the preceding example:
  1138.  
  1139.      foo : bar/lose
  1140.              cd bar;  \
  1141.              gobble lose > ../foo
  1142.  
  1143.    The program used as the shell is taken from the variable `SHELL'.
  1144. By default, the program `/bin/sh' is used.
  1145.  
  1146.    Unlike most variables, the variable `SHELL' is never set from the
  1147. environment.  This is because the `SHELL' environment variable is used
  1148. to specify your personal choice of shell program for interactive use.
  1149. It would be very bad for personal choices like this to affect the
  1150. functioning of makefiles.  *Note Variables from the Environment:
  1151. Environment.
  1152.  
  1153. 
  1154. File: make.info,  Node: Parallel,  Next: Errors,  Prev: Execution,  Up: Commands
  1155.  
  1156. Parallel Execution
  1157. ==================
  1158.  
  1159.    GNU `make' knows how to execute several commands at once.  Normally,
  1160. `make' will execute only one command at a time, waiting for it to
  1161. finish before executing the next.  However, the `-j' or `--jobs' option
  1162. tells `make' to execute many commands simultaneously.
  1163.  
  1164.    If the `-j' option is followed by an integer, this is the number of
  1165. commands to execute at once; this is called the number of "job slots".
  1166. If there is nothing looking like an integer after the `-j' option,
  1167. there is no limit on the number of job slots.  The default number of job
  1168. slots is one, which means serial execution (one thing at a time).
  1169.  
  1170.    One unpleasant consequence of running several commands
  1171. simultaneously is that output from all of the commands comes when the
  1172. commands send it, so messages from different commands may be
  1173. interspersed.
  1174.  
  1175.    Another problem is that two processes cannot both take input from the
  1176. same device; so to make sure that only one command tries to take input
  1177. from the terminal at once, `make' will invalidate the standard input
  1178. streams of all but one running command.  This means that attempting to
  1179. read from standard input will usually be a fatal error (a `Broken pipe'
  1180. signal) for most child processes if there are several.
  1181.  
  1182.    It is unpredictable which command will have a valid standard input
  1183. stream (which will come from the terminal, or wherever you redirect the
  1184. standard input of `make').  The first command run will always get it
  1185. first, and the first command started after that one finishes will get
  1186. it next, and so on.
  1187.  
  1188.    We will change how this aspect of `make' works if we find a better
  1189. alternative.  In the mean time, you should not rely on any command using
  1190. standard input at all if you are using the parallel execution feature;
  1191. but if you are not using this feature, then standard input works
  1192. normally in all commands.
  1193.  
  1194.    If a command fails (is killed by a signal or exits with a nonzero
  1195. status), and errors are not ignored for that command (*note Errors in
  1196. Commands: Errors.), the remaining command lines to remake the same
  1197. target will not be run.  If a command fails and the `-k' or
  1198. `--keep-going' option was not given (*note Summary of Options: Options
  1199. Summary.), `make' aborts execution.  If make terminates for any reason
  1200. (including a signal) with child processes running, it waits for them to
  1201. finish before actually exiting.
  1202.  
  1203.    When the system is heavily loaded, you will probably want to run
  1204. fewer jobs than when it is lightly loaded.  You can use the `-l' option
  1205. to tell `make' to limit the number of jobs to run at once, based on the
  1206. load average.  The `-l' or `--max-load' option is followed by a
  1207. floating-point number.  For example,
  1208.  
  1209.      -l 2.5
  1210.  
  1211. will not let `make' start more than one job if the load average is
  1212. above 2.5.  The `-l' option with no following number removes the load
  1213. limit, if one was given with a previous `-l' option.
  1214.  
  1215.    More precisely, when `make' goes to start up a job, and it already
  1216. has at least one job running, it checks the current load average; if it
  1217. is not lower than the limit given with `-l', `make' waits until the load
  1218. average goes below that limit, or until all the other jobs finish.
  1219.  
  1220.    By default, there is no load limit.
  1221.  
  1222.