home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / gnu / info / make.info-6 (.txt) < prev    next >
GNU Info File  |  1994-11-12  |  49KB  |  877 lines

  1. This is Info file make.info, produced by Makeinfo-1.55 from the input
  2. file ./make.texinfo.
  3.    This file documents the GNU Make utility, which determines
  4. automatically which pieces of a large program need to be recompiled,
  5. and issues the commands to recompile them.
  6.    This is Edition 0.47, last updated 1 November 1994, of `The GNU Make
  7. Manual', for `make', Version 3.72 Beta.
  8.    Copyright (C) 1988, '89, '90, '91, '92, '93, '94 Free Software
  9. Foundation, Inc.
  10.    Permission is granted to make and distribute verbatim copies of this
  11. manual provided the copyright notice and this permission notice are
  12. preserved on all copies.
  13.    Permission is granted to copy and distribute modified versions of
  14. this manual under the conditions for verbatim copying, provided that
  15. the entire resulting derived work is distributed under the terms of a
  16. permission notice identical to this one.
  17.    Permission is granted to copy and distribute translations of this
  18. manual into another language, under the above conditions for modified
  19. versions, except that this permission notice may be stated in a
  20. translation approved by the Free Software Foundation.
  21. File: make.info,  Node: Match-Anything Rules,  Next: Canceling Rules,  Prev: Pattern Match,  Up: Pattern Rules
  22. Match-Anything Pattern Rules
  23. ----------------------------
  24.    When a pattern rule's target is just `%', it matches any file name
  25. whatever.  We call these rules "match-anything" rules.  They are very
  26. useful, but it can take a lot of time for `make' to think about them,
  27. because it must consider every such rule for each file name listed
  28. either as a target or as a dependency.
  29.    Suppose the makefile mentions `foo.c'.  For this target, `make'
  30. would have to consider making it by linking an object file `foo.c.o',
  31. or by C compilation-and-linking in one step from `foo.c.c', or by
  32. Pascal compilation-and-linking from `foo.c.p', and many other
  33. possibilities.
  34.    We know these possibilities are ridiculous since `foo.c' is a C
  35. source file, not an executable.  If `make' did consider these
  36. possibilities, it would ultimately reject them, because files such as
  37. `foo.c.o' and `foo.c.p' would not exist.  But these possibilities are so
  38. numerous that `make' would run very slowly if it had to consider them.
  39.    To gain speed, we have put various constraints on the way `make'
  40. considers match-anything rules.  There are two different constraints
  41. that can be applied, and each time you define a match-anything rule you
  42. must choose one or the other for that rule.
  43.    One choice is to mark the match-anything rule as "terminal" by
  44. defining it with a double colon.  When a rule is terminal, it does not
  45. apply unless its dependencies actually exist.  Dependencies that could
  46. be made with other implicit rules are not good enough.  In other words,
  47. no further chaining is allowed beyond a terminal rule.
  48.    For example, the built-in implicit rules for extracting sources from
  49. RCS and SCCS files are terminal; as a result, if the file `foo.c,v' does
  50. not exist, `make' will not even consider trying to make it as an
  51. intermediate file from `foo.c,v.o' or from `RCS/SCCS/s.foo.c,v'.  RCS
  52. and SCCS files are generally ultimate source files, which should not be
  53. remade from any other files; therefore, `make' can save time by not
  54. looking for ways to remake them.
  55.    If you do not mark the match-anything rule as terminal, then it is
  56. nonterminal.  A nonterminal match-anything rule cannot apply to a file
  57. name that indicates a specific type of data.  A file name indicates a
  58. specific type of data if some non-match-anything implicit rule target
  59. matches it.
  60.    For example, the file name `foo.c' matches the target for the pattern
  61. rule `%.c : %.y' (the rule to run Yacc).  Regardless of whether this
  62. rule is actually applicable (which happens only if there is a file
  63. `foo.y'), the fact that its target matches is enough to prevent
  64. consideration of any nonterminal match-anything rules for the file
  65. `foo.c'.  Thus, `make' will not even consider trying to make `foo.c' as
  66. an executable file from `foo.c.o', `foo.c.c', `foo.c.p', etc.
  67.    The motivation for this constraint is that nonterminal match-anything
  68. rules are used for making files containing specific types of data (such
  69. as executable files) and a file name with a recognized suffix indicates
  70. some other specific type of data (such as a C source file).
  71.    Special built-in dummy pattern rules are provided solely to recognize
  72. certain file names so that nonterminal match-anything rules will not be
  73. considered.  These dummy rules have no dependencies and no commands, and
  74. they are ignored for all other purposes.  For example, the built-in
  75. implicit rule
  76.      %.p :
  77. exists to make sure that Pascal source files such as `foo.p' match a
  78. specific target pattern and thereby prevent time from being wasted
  79. looking for `foo.p.o' or `foo.p.c'.
  80.    Dummy pattern rules such as the one for `%.p' are made for every
  81. suffix listed as valid for use in suffix rules (*note Old-Fashioned
  82. Suffix Rules: Suffix Rules.).
  83. File: make.info,  Node: Canceling Rules,  Prev: Match-Anything Rules,  Up: Pattern Rules
  84. Canceling Implicit Rules
  85. ------------------------
  86.    You can override a built-in implicit rule (or one you have defined
  87. yourself) by defining a new pattern rule with the same target and
  88. dependencies, but different commands.  When the new rule is defined, the
  89. built-in one is replaced.  The new rule's position in the sequence of
  90. implicit rules is determined by where you write the new rule.
  91.    You can cancel a built-in implicit rule by defining a pattern rule
  92. with the same target and dependencies, but no commands.  For example,
  93. the following would cancel the rule that runs the assembler:
  94.      %.o : %.s
  95. File: make.info,  Node: Last Resort,  Next: Suffix Rules,  Prev: Pattern Rules,  Up: Implicit Rules
  96. Defining Last-Resort Default Rules
  97. ==================================
  98.    You can define a last-resort implicit rule by writing a terminal
  99. match-anything pattern rule with no dependencies (*note Match-Anything
  100. Rules::.).  This is just like any other pattern rule; the only thing
  101. special about it is that it will match any target.  So such a rule's
  102. commands are used for all targets and dependencies that have no commands
  103. of their own and for which no other implicit rule applies.
  104.    For example, when testing a makefile, you might not care if the
  105. source files contain real data, only that they exist.  Then you might
  106. do this:
  107.      %::
  108.              touch $@
  109. to cause all the source files needed (as dependencies) to be created
  110. automatically.
  111.    You can instead define commands to be used for targets for which
  112. there are no rules at all, even ones which don't specify commands.  You
  113. do this by writing a rule for the target `.DEFAULT'.  Such a rule's
  114. commands are used for all dependencies which do not appear as targets in
  115. any explicit rule, and for which no implicit rule applies.  Naturally,
  116. there is no `.DEFAULT' rule unless you write one.
  117.    If you use `.DEFAULT' with no commands or dependencies:
  118.      .DEFAULT:
  119. the commands previously stored for `.DEFAULT' are cleared.  Then `make'
  120. acts as if you had never defined `.DEFAULT' at all.
  121.    If you do not want a target to get the commands from a match-anything
  122. pattern rule or `.DEFAULT', but you also do not want any commands to be
  123. run for the target, you can give it empty commands (*note Defining
  124. Empty Commands: Empty Commands.).
  125.    You can use a last-resort rule to override part of another makefile.
  126. *Note Overriding Part of Another Makefile: Overriding Makefiles.
  127. File: make.info,  Node: Suffix Rules,  Next: Search Algorithm,  Prev: Last Resort,  Up: Implicit Rules
  128. Old-Fashioned Suffix Rules
  129. ==========================
  130.    "Suffix rules" are the old-fashioned way of defining implicit rules
  131. for `make'.  Suffix rules are obsolete because pattern rules are more
  132. general and clearer.  They are supported in GNU `make' for
  133. compatibility with old makefiles.  They come in two kinds:
  134. "double-suffix" and "single-suffix".
  135.    A double-suffix rule is defined by a pair of suffixes: the target
  136. suffix and the source suffix.  It matches any file whose name ends with
  137. the target suffix.  The corresponding implicit dependency is made by
  138. replacing the target suffix with the