home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 4 / FreshFish_May-June1994.bin / bbs / gnu / make-3.70-bin.lha / info / make.info-5 < prev    next >
Encoding:
GNU Info File  |  1994-02-21  |  47.9 KB  |  1,171 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: Options Summary,  Prev: Testing,  Up: Running
  30.  
  31. Summary of Options
  32. ==================
  33.  
  34.    Here is a table of all the options `make' understands:
  35.  
  36. `-b'
  37. `-m'
  38.      These options are ignored for compatibility with other versions of
  39.      `make'.
  40.  
  41. `-C DIR'
  42. `--directory=DIR'
  43.      Change to directory DIR before reading the makefiles.  If multiple
  44.      `-C' options are specified, each is interpreted relative to the
  45.      previous one: `-C / -C etc' is equivalent to `-C /etc'.  This is
  46.      typically used with recursive invocations of `make' (*note
  47.      Recursive Use of `make': Recursion.).
  48.  
  49. `-d'
  50. `--debug'
  51.      Print debugging information in addition to normal processing.  The
  52.      debugging information says which files are being considered for
  53.      remaking, which file-times are being compared and with what
  54.      results, which files actually need to be remade, which implicit
  55.      rules are considered and which are applied--everything interesting
  56.      about how `make' decides what to do.
  57.  
  58. `-e'
  59. `--environment-overrides'
  60.      Give variables taken from the environment precedence over
  61.      variables from makefiles.  *Note Variables from the Environment:
  62.      Environment.
  63.  
  64. `-f FILE'
  65. `--file=FILE'
  66. `--makefile=FILE'
  67.      Read the file named FILE as a makefile.  *Note Writing Makefiles:
  68.      Makefiles.
  69.  
  70. `-h'
  71. `--help'
  72.      Remind you of the options that `make' understands and then exit.
  73.  
  74. `-i'
  75. `--ignore-errors'
  76.      Ignore all errors in commands executed to remake files.  *Note
  77.      Errors in Commands: Errors.
  78.  
  79. `-I DIR'
  80. `--include-dir=DIR'
  81.      Specifies a directory DIR to search for included makefiles.  *Note
  82.      Including Other Makefiles: Include.  If several `-I' options are
  83.      used to specify several directories, the directories are searched
  84.      in the order specified.
  85.  
  86. `-j [JOBS]'
  87. `--jobs=[JOBS]'
  88.      Specifies the number of jobs (commands) to run simultaneously.
  89.      With no argument, `make' runs as many jobs simultaneously as
  90.      possible.  If there is more than one `-j' option, the last one is
  91.      effective.  *Note Parallel Execution: Parallel, for more
  92.      information on how commands are run.
  93.  
  94. `-k'
  95. `--keep-going'
  96.      Continue as much as possible after an error.  While the target that
  97.      failed, and those that depend on it, cannot be remade, the other
  98.      dependencies of these targets can be processed all the same.
  99.      *Note Testing the Compilation of a Program: Testing.
  100.  
  101. `-l [LOAD]'
  102. `--load-average[=LOAD]'
  103. `--max-load[=LOAD]'
  104.      Specifies that no new jobs (commands) should be started if there
  105.      are other jobs running and the load average is at least LOAD (a
  106.      floating-point number).  With no argument, removes a previous load
  107.      limit.  *Note Parallel Execution: Parallel.
  108.  
  109. `-n'
  110. `--just-print'
  111. `--dry-run'
  112. `--recon'
  113.      Print the commands that would be executed, but do not execute them.
  114.      *Note Instead of Executing the Commands: Instead of Execution.
  115.  
  116. `-o FILE'
  117. `--old-file=FILE'
  118. `--assume-old=FILE'
  119.      Do not remake the file FILE even if it is older than its
  120.      dependencies, and do not remake anything on account of changes in
  121.      FILE.  Essentially the file is treated as very old and its rules
  122.      are ignored.  *Note Avoiding Recompilation of Some Files: Avoiding
  123.      Compilation.
  124.  
  125. `-p'
  126. `--print-data-base'
  127.      Print the data base (rules and variable values) that results from
  128.      reading the makefiles; then execute as usual or as otherwise
  129.      specified.  This also prints the version information given by the
  130.      `-v' switch (see below).  To print the data base without trying to
  131.      remake any files, use `make -p -f /dev/null'.
  132.  
  133. `-q'
  134. `--question'
  135.      "Question mode".  Do not run any commands, or print anything; just
  136.      return an exit status that is zero if the specified targets are
  137.      already up to date, nonzero otherwise.  *Note Instead of Executing
  138.      the Commands: Instead of Execution.
  139.  
  140. `-r'
  141. `--no-builtin-rules'
  142.      Eliminate use of the built-in implicit rules (*note Using Implicit
  143.      Rules: Implicit Rules.).  You can still define your own by writing
  144.      pattern rules (*note Defining and Redefining Pattern Rules:
  145.      Pattern Rules.).  The `-r' option also clears out the default list
  146.      of suffixes for suffix rules (*note Old-Fashioned Suffix Rules:
  147.      Suffix Rules.).  But you can still define your own suffixes with a
  148.      rule for `.SUFFIXES', and then define your own suffix rules.
  149.  
  150. `-s'
  151. `--silent'
  152. `--quiet'
  153.      Silent operation; do not print the commands as they are executed.
  154.      *Note Command Echoing: Echoing.
  155.  
  156. `-S'
  157. `--no-keep-going'
  158. `--stop'
  159.      Cancel the effect of the `-k' option.  This is never necessary
  160.      except in a recursive `make' where `-k' might be inherited from
  161.      the top-level `make' via `MAKEFLAGS' (*note Recursive Use of
  162.      `make': Recursion.) or if you set `-k' in `MAKEFLAGS' in your
  163.      environment.
  164.  
  165. `-t'
  166. `--touch'
  167.      Touch files (mark them up to date without really changing them)
  168.      instead of running their commands.  This is used to pretend that
  169.      the commands were done, in order to fool future invocations of
  170.      `make'.  *Note Instead of Executing the Commands: Instead of
  171.      Execution.
  172.  
  173. `-v'
  174. `--version'
  175.      Print the version of the `make' program plus a copyright, a list
  176.      of authors, and a notice that there is no warranty; then exit.
  177.  
  178. `-w'
  179. `--print-directory'
  180.      Print a message containing the working directory both before and
  181.      after executing the makefile.  This may be useful for tracking
  182.      down errors from complicated nests of recursive `make' commands.
  183.      *Note Recursive Use of `make': Recursion.  (In practice, you
  184.      rarely need to specify this option since `make' does it for you;
  185.      see *Note The `--print-directory' Option: -w Option.)
  186.  
  187. `--no-print-directory'
  188.      Disable printing of the working directory under `-w'.  This option
  189.      is useful when `-w' is turned on automatically, but you do not
  190.      want to see the extra messages.  *Note The `--print-directory'
  191.      Option: -w Option.
  192.  
  193. `-W FILE'
  194. `--what-if=FILE'
  195. `--new-file=FILE'
  196. `--assume-new=FILE'
  197.      Pretend that the target FILE has just been modified.  When used
  198.      with the `-n' flag, this shows you what would happen if you were
  199.      to modify that file.  Without `-n', it is almost the same as
  200.      running a `touch' command on the given file before running `make',
  201.      except that the modification time is changed only in the
  202.      imagination of `make'.  *Note Instead of Executing the Commands:
  203.      Instead of Execution.
  204.  
  205. `--warn-undefined-variables'
  206.      Issue a warning message whenever `make' sees a reference to an
  207.      undefined variable.  This can be helpful when you are trying to
  208.      debug makefiles which use variables in complex ways.
  209.  
  210. 
  211. File: make.info,  Node: Implicit Rules,  Next: Archives,  Prev: Running,  Up: Top
  212.  
  213. Using Implicit Rules
  214. ********************
  215.  
  216.    Certain standard ways of remaking target files are used very often.
  217. For example, one customary way to make an object file is from a C
  218. source file using the C compiler, `cc'.
  219.  
  220.    "Implicit rules" tell `make' how to use customary techniques so that
  221. you do not have to specify them in detail when you want to use them.
  222. For example, there is an implicit rule for C compilation.  File names
  223. determine which implicit rules are run.  For example, C compilation
  224. typically takes a `.c' file and makes a `.o' file.  So `make' applies
  225. the implicit rule for C compilation when it sees this combination of
  226. file name endings.
  227.  
  228.    A chain of implicit rules can apply in sequence; for example, `make'
  229. will remake a `.o' file from a `.y' file by way of a `.c' file.
  230.  
  231.    The built-in implicit rules use several variables in their commands
  232. so that, by changing the values of the variables, you can change the
  233. way the implicit rule works.  For example, the variable `CFLAGS'
  234. controls the flags given to the C compiler by the implicit rule for C
  235. compilation.
  236.  
  237.    You can define your own implicit rules by writing "pattern rules".
  238.  
  239.    "Suffix rules" are a more limited way to define implicit rules.
  240. Pattern rules are more general and clearer, but suffix rules are
  241. retained for compatibility.
  242.  
  243. * Menu:
  244.  
  245. * Using Implicit::              How to use an existing implicit rule
  246.                                   to get the commands for updating a file.
  247. * Catalogue of Rules::          A list of built-in implicit rules.
  248. * Implicit Variables::          How to change what predefined rules do.
  249. * Chained Rules::               How to use a chain of implicit rules.
  250. * Pattern Rules::               How to define new implicit rules.
  251. * Last Resort::                 How to defining commands for rules
  252.                                   which cannot find any.
  253. * Suffix Rules::                The old-fashioned style of implicit rule.
  254. * Search Algorithm::            The precise algorithm for applying
  255.                                   implicit rules.
  256.  
  257. 
  258. File: make.info,  Node: Using Implicit,  Next: Catalogue of Rules,  Up: Implicit Rules
  259.  
  260. Using Implicit Rules
  261. ====================
  262.  
  263.    To allow `make' to find a customary method for updating a target
  264. file, all you have to do is refrain from specifying commands yourself.
  265. Either write a rule with no command lines, or don't write a rule at
  266. all.  Then `make' will figure out which implicit rule to use based on
  267. which kind of source file exists or can be made.
  268.  
  269.    For example, suppose the makefile looks like this:
  270.  
  271.      foo : foo.o bar.o
  272.              cc -o foo foo.o bar.o $(CFLAGS) $(LDFLAGS)
  273.  
  274. Because you mention `foo.o' but do not give a rule for it, `make' will
  275. automatically look for an implicit rule that tells how to update it.
  276. This happens whether or not the file `foo.o' currently exists.
  277.  
  278.    If an implicit rule is found, it can supply both commands and one or
  279. more dependencies (the source files).  You would want to write a rule
  280. for `foo.o' with no command lines if you need to specify additional
  281. dependencies, such as header files, that the implicit rule cannot
  282. supply.
  283.  
  284.    Each implicit rule has a target pattern and dependency patterns.
  285. There may be many implicit rules with the same target pattern.  For
  286. example, numerous rules make `.o' files: one, from a `.c' file with the
  287. C compiler; another, from a `.p' file with the Pascal compiler; and so
  288. on.  The rule that actually applies is the one whose dependencies exist
  289. or can be made.  So, if you have a file `foo.c', `make' will run the C
  290. compiler; otherwise, if you have a file `foo.p', `make' will run the
  291. Pascal compiler; and so on.
  292.  
  293.    Of course, when you write the makefile, you know which implicit rule
  294. you want `make' to use, and you know it will choose that one because you
  295. know which possible dependency files are supposed to exist.  *Note
  296. Catalogue of Implicit Rules: Catalogue of Rules, for a catalogue of all
  297. the predefined implicit rules.
  298.  
  299.    Above, we said an implicit rule applies if the required dependencies
  300. "exist or can be made".  A file "can be made" if it is mentioned
  301. explicitly in the makefile as a target or a dependency, or if an
  302. implicit rule can be recursively found for how to make it.  When an
  303. implicit dependency is the result of another implicit rule, we say that
  304. "chaining" is occurring.  *Note Chains of Implicit Rules: Chained Rules.
  305.  
  306.    In general, `make' searches for an implicit rule for each target, and
  307. for each double-colon rule, that has no commands.  A file that is
  308. mentioned only as a dependency is considered a target whose rule
  309. specifies nothing, so implicit rule search happens for it.  *Note
  310. Implicit Rule Search Algorithm: Search Algorithm, for the details of
  311. how the search is done.
  312.  
  313.    Note that explicit dependencies do not influence implicit rule
  314. search.  For example, consider this explicit rule:
  315.  
  316.      foo.o: foo.p
  317.  
  318. The dependency on `foo.p' does not necessarily mean that `make' will
  319. remake `foo.o' according to the implicit rule to make an object file, a
  320. `.o' file, from a Pascal source file, a `.p' file.  For example, if
  321. `foo.c' also exists, the implicit rule to make an object file from a C
  322. source file is used instead, because it appears before the Pascal rule
  323. in the list of predefined implicit rules (*note Catalogue of Implicit
  324. Rules: Catalogue of Rules.).
  325.  
  326.    If you do not want an implicit rule to be used for a target that has
  327. no commands, you can give that target empty commands by writing a
  328. semicolon (*note Defining Empty Commands: Empty Commands.).
  329.  
  330. 
  331. File: make.info,  Node: Catalogue of Rules,  Next: Implicit Variables,  Prev: Using Implicit,  Up: Implicit Rules
  332.  
  333. Catalogue of Implicit Rules
  334. ===========================
  335.  
  336.    Here is a catalogue of predefined implicit rules which are always
  337. available unless the makefile explicitly overrides or cancels them.
  338. *Note Canceling Implicit Rules: Canceling Rules, for information on
  339. canceling or overriding an implicit rule.  The `-r' or
  340. `--no-builtin-rules' option cancels all predefined rules.
  341.  
  342.    Not all of these rules will always be defined, even when the `-r'
  343. option is not given.  Many of the predefined implicit rules are
  344. implemented in `make' as suffix rules, so which ones will be defined
  345. depends on the "suffix list" (the list of dependencies of the special
  346. target `.SUFFIXES').  The default suffix list is: `.out', `.a', `.ln',
  347. `.o', `.c', `.cc', `.C', `.p', `.f', `.F', `.r', `.y', `.l', `.s',
  348. `.S', `.mod', `.sym', `.def', `.h', `.info', `.dvi', `.tex', `.texinfo',
  349. `.texi', `.txinfo', `.w', `.ch' `.web', `.sh', `.elc', `.el'.  All of
  350. the implicit rules described below whose dependencies have one of these
  351. suffixes are actually suffix rules.  If you modify the suffix list, the
  352. only predefined suffix rules in effect will be those named by one or
  353. two of the suffixes that are on the list you specify; rules whose
  354. suffixes fail to be on the list are disabled.  *Note Old-Fashioned
  355. Suffix Rules: Suffix Rules, for full details on suffix rules.
  356.  
  357. Compiling C programs
  358.      `N.o' is made automatically from `N.c' with a command of the form
  359.      `$(CC) -c $(CPPFLAGS) $(CFLAGS)'.
  360.  
  361. Compiling C++ programs
  362.      `N.o' is made automatically from `N.cc' or `N.C' with a command of
  363.      the form `$(CXX) -c $(CPPFLAGS) $(CXXFLAGS)'.  We encourage you to
  364.      use the suffix `.cc' for C++ source files instead of `.C'.
  365.  
  366. Compiling Pascal programs
  367.      `N.o' is made automatically from `N.p' with the command `$(PC) -c
  368.      $(PFLAGS)'.
  369.  
  370. Compiling Fortran and Ratfor programs
  371.      `N.o' is made automatically from `N.r', `N.F' or `N.f' by running
  372.      the Fortran compiler.  The precise command used is as follows:
  373.  
  374.     `.f'
  375.           `$(FC) -c $(FFLAGS)'.
  376.  
  377.     `.F'
  378.           `$(FC) -c $(FFLAGS) $(CPPFLAGS)'.
  379.  
  380.     `.r'
  381.           `$(FC) -c $(FFLAGS) $(RFLAGS)'.
  382.  
  383. Preprocessing Fortran and Ratfor programs
  384.      `N.f' is made automatically from `N.r' or `N.F'.  This rule runs
  385.      just the preprocessor to convert a Ratfor or preprocessable
  386.      Fortran program into a strict Fortran program.  The precise
  387.      command used is as follows:
  388.  
  389.     `.F'
  390.           `$(FC) -F $(CPPFLAGS) $(FFLAGS)'.
  391.  
  392.     `.r'
  393.           `$(FC) -F $(FFLAGS) $(RFLAGS)'.
  394.  
  395. Compiling Modula-2 programs
  396.      `N.sym' is made from `N.def' with a command of the form `$(M2C)
  397.      $(M2FLAGS) $(DEFFLAGS)'.  `N.o' is made from `N.mod'; the form is:
  398.      `$(M2C) $(M2FLAGS) $(MODFLAGS)'.
  399.  
  400. Assembling and preprocessing assembler programs
  401.      `N.o' is made automatically from `N.s' by running the assembler,
  402.      `as'.  The precise command is `$(AS) $(ASFLAGS)'.
  403.  
  404.      `N.s' is made automatically from `N.S' by running the C
  405.      preprocessor, `cpp'.  The precise command is `$(CPP) $(CPPFLAGS)'.
  406.  
  407. Linking a single object file
  408.      `N' is made automatically from `N.o' by running the linker
  409.      (usually called `ld') via the C compiler.  The precise command
  410.      used is `$(CC) $(LDFLAGS) N.o $(LOADLIBES)'.
  411.  
  412.      This rule does the right thing for a simple program with only one
  413.      source file.  It will also do the right thing if there are multiple
  414.      object files (presumably coming from various other source files),
  415.      one of which has a name matching that of the executable file.
  416.      Thus,
  417.  
  418.           x: y.o z.o
  419.  
  420.      when `x.c', `y.c' and `z.c' all exist will execute:
  421.  
  422.           cc -c x.c -o x.o
  423.           cc -c y.c -o y.o
  424.           cc -c z.c -o z.o
  425.           cc x.o y.o z.o -o x
  426.           rm -f x.o
  427.           rm -f y.o
  428.           rm -f z.o
  429.  
  430.      In more complicated cases, such as when there is no object file
  431.      whose name derives from the executable file name, you must write
  432.      an explicit command for linking.
  433.  
  434.      Each kind of file automatically made into `.o' object files will
  435.      be automatically linked by using the compiler (`$(CC)', `$(FC)' or
  436.      `$(PC)'; the C compiler `$(CC)' is used to assemble `.s' files)
  437.      without the `-c' option.  This could be done by using the `.o'
  438.      object files as intermediates, but it is faster to do the
  439.      compiling and linking in one step, so that's how it's done.
  440.  
  441. Yacc for C programs
  442.      `N.c' is made automatically from `N.y' by running Yacc with the
  443.      command `$(YACC) $(YFLAGS)'.
  444.  
  445. Lex for C programs
  446.      `N.c' is made automatically from `N.l' by by running Lex.  The
  447.      actual command is `$(LEX) $(LFLAGS)'.
  448.  
  449. Lex for Ratfor programs
  450.      `N.r' is made automatically from `N.l' by by running Lex.  The
  451.      actual command is `$(LEX) $(LFLAGS)'.
  452.  
  453.      The convention of using the same suffix `.l' for all Lex files
  454.      regardless of whether they produce C code or Ratfor code makes it
  455.      impossible for `make' to determine automatically which of the two
  456.      languages you are using in any particular case.  If `make' is
  457.      called upon to remake an object file from a `.l' file, it must
  458.      guess which compiler to use.  It will guess the C compiler, because
  459.      that is more common.  If you are using Ratfor, make sure `make'
  460.      knows this by mentioning `N.r' in the makefile.  Or, if you are
  461.      using Ratfor exclusively, with no C files, remove `.c' from the
  462.      list of implicit rule suffixes with:
  463.  
  464.           .SUFFIXES:
  465.           .SUFFIXES: .o .r .f .l ...
  466.  
  467. Making Lint Libraries from C, Yacc, or Lex programs
  468.      `N.ln' is made from `N.c' by running `lint'.  The precise command
  469.      is `$(LINT) $(LINTFLAGS) $(CPPFLAGS) -i'.  The same command is
  470.      used on the C code produced from `N.y' or `N.l'.
  471.  
  472. TeX and Web
  473.      `N.dvi' is made from `N.tex' with the command `$(TEX)'.  `N.tex'
  474.      is made from `N.web' with `$(WEAVE)', or from `N.w' (and from
  475.      `N.ch' if it exists or can be made) with `$(CWEAVE)'.  `N.p' is
  476.      made from `N.web' with `$(TANGLE)' and `N.c' is made from `N.w'
  477.      (and from `N.ch' if it exists or can be made) with `$(CTANGLE)'.
  478.  
  479. Texinfo and Info
  480.      `N.dvi' is made from `N.texinfo', `N.texi', or `N.txinfo', with
  481.      the `$(TEXI2DVI)' command.  `N.info' is made from `N.texinfo',
  482.      `N.texi', or `N.txinfo', with the `$(MAKEINFO)' command.
  483.  
  484. RCS
  485.      Any file `N' is extracted if necessary from an RCS file named
  486.      either `N,v' or `RCS/N,v'.  The precise command used is
  487.      `$(CO) $(COFLAGS)'.  `N' will not be extracted from RCS if it
  488.      already exists, even if the RCS file is newer.  The rules for RCS
  489.      are terminal (*note Match-Anything Pattern Rules: Match-Anything
  490.      Rules.), so RCS files cannot be generated from another source;
  491.      they must actually exist.
  492.  
  493. SCCS
  494.      Any file `N' is extracted if necessary from an SCCS file named
  495.      either `s.N' or `SCCS/s.N'.  The precise command used is
  496.      `$(GET) $(GFLAGS)'.  The rules for SCCS are terminal (*note
  497.      Match-Anything Pattern Rules: Match-Anything Rules.), so SCCS
  498.      files cannot be generated from another source; they must actually
  499.      exist.
  500.  
  501.      For the benefit of SCCS, a file `N' is copied from `N.sh' and made
  502.      executable (by everyone).  This is for shell scripts that are
  503.      checked into SCCS.  Since RCS preserves the execution permission
  504.      of a file, you do not need to use this feature with RCS.
  505.  
  506.      We recommend that you avoid using of SCCS.  RCS is widely held to
  507.      be superior, and is also free.  By choosing free software in place
  508.      of comparable (or inferior) proprietary software, you support the
  509.      free software movement.
  510.  
  511.    Usually, you want to change only the variables listed in the table
  512. above, which are documented in the following section.
  513.  
  514.    However, the commands in built-in implicit rules actually use
  515. variables such as `COMPILE.c', `LINK.p', and `PREPROCESS.S', whose
  516. values contain the commands listed above.
  517.  
  518.    `make' follows the convention that the rule to compile a `.X' source
  519. file uses the variable `COMPILE.X'.  Similarly, the rule to produce an
  520. executable from a `.X' file uses `LINK.X'; and the rule to preprocess a
  521. `.X' file uses `PREPROCESS.X'.
  522.  
  523.    Every rule that produces an object file uses the variable
  524. `OUTPUT_OPTION'.  `make' defines this variable either to contain `-o
  525. $@', or to be empty, depending on a compile-time option.  You need the
  526. `-o' option to ensure that the output goes into the right file when the
  527. source file is in a different directory, as when using `VPATH' (*note
  528. Directory Search::.).  However, compilers on some systems do not accept
  529. a `-o' switch for object files.  If you use such a system, and use
  530. `VPATH', some compilations will put their output in the wrong place.  A
  531. possible workaround for this problem is to give `OUTPUT_OPTION' the
  532. value `; mv $*.o $@'.
  533.  
  534. 
  535. File: make.info,  Node: Implicit Variables,  Next: Chained Rules,  Prev: Catalogue of Rules,  Up: Implicit Rules
  536.  
  537. Variables Used by Implicit Rules
  538. ================================
  539.  
  540.    The commands in built-in implicit rules make liberal use of certain
  541. predefined variables.  You can alter these variables in the makefile,
  542. with arguments to `make', or in the environment to alter how the
  543. implicit rules work without redefining the rules themselves.
  544.  
  545.    For example, the command used to compile a C source file actually
  546. says `$(CC) -c $(CFLAGS) $(CPPFLAGS)'.  The default values of the
  547. variables used are `cc' and nothing, resulting in the command `cc -c'.
  548. By redefining `CC' to `ncc', you could cause `ncc' to be used for all C
  549. compilations performed by the implicit rule.  By redefining `CFLAGS' to
  550. be `-g', you could pass the `-g' option to each compilation.  *All*
  551. implicit rules that do C compilation use `$(CC)' to get the program
  552. name for the compiler and *all* include `$(CFLAGS)' among the arguments
  553. given to the compiler.
  554.  
  555.    The variables used in implicit rules fall into two classes: those
  556. that are names of programs (like `CC') and those that contain arguments
  557. for the programs (like `CFLAGS').  (The "name of a program" may also
  558. contain some command arguments, but it must start with an actual
  559. executable program name.)  If a variable value contains more than one
  560. argument, separate them with spaces.
  561.  
  562.    Here is a table of variables used as names of programs in built-in
  563. rules:
  564.  
  565. `AR'
  566.      Archive-maintaining program; default `ar'.
  567.  
  568. `AS'
  569.      Program for doing assembly; default `as'.
  570.  
  571. `CC'
  572.      Program for compiling C programs; default `cc'.
  573.  
  574. `CXX'
  575.      Program for compiling C++ programs; default `g++'.
  576.  
  577. `CO'
  578.      Program for extracting a file from RCS; default `co'.
  579.  
  580. `CPP'
  581.      Program for running the C preprocessor, with results to standard
  582.      output; default `$(CC) -E'.
  583.  
  584. `FC'
  585.      Program for compiling or preprocessing Fortran and Ratfor programs;
  586.      default `f77'.
  587.  
  588. `GET'
  589.      Program for extracting a file from SCCS; default `get'.
  590.  
  591. `LEX'
  592.      Program to use to turn Lex grammars into C programs or Ratfor
  593.      programs; default `lex'.
  594.  
  595. `PC'
  596.      Program for compiling Pascal programs; default `pc'.
  597.  
  598. `YACC'
  599.      Program to use to turn Yacc grammars into C programs; default
  600.      `yacc'.
  601.  
  602. `YACCR'
  603.      Program to use to turn Yacc grammars into Ratfor programs; default
  604.      `yacc -r'.
  605.  
  606. `MAKEINFO'
  607.      Program to convert a Texinfo source file into an Info file; default
  608.      `makeinfo'.
  609.  
  610. `TEX'
  611.      Program to make TeX DVI files from TeX source; default `tex'.
  612.  
  613. `TEXI2DVI'
  614.      Program to make TeX DVI files from Texinfo source; default
  615.      `texi2dvi'.
  616.  
  617. `WEAVE'
  618.      Program to translate Web into TeX; default `weave'.
  619.  
  620. `CWEAVE'
  621.      Program to translate C Web into TeX; default `cweave'.
  622.  
  623. `TANGLE'
  624.      Program to translate Web into Pascal; default `tangle'.
  625.  
  626. `CTANGLE'
  627.      Program to translate C Web into C; default `ctangle'.
  628.  
  629. `RM'
  630.      Command to remove a file; default `rm -f'.
  631.  
  632.    Here is a table of variables whose values are additional arguments
  633. for the programs above.  The default values for all of these is the
  634. empty string, unless otherwise noted.
  635.  
  636. `ARFLAGS'
  637.      Flags to give the archive-maintaining program; default `rv'.
  638.  
  639. `ASFLAGS'
  640.      Extra flags to give to the assembler (when explicitly invoked on a
  641.      `.s' or `.S' file).
  642.  
  643. `CFLAGS'
  644.      Extra flags to give to the C compiler.
  645.  
  646. `CXXFLAGS'
  647.      Extra flags to give to the C++ compiler.
  648.  
  649. `COFLAGS'
  650.      Extra flags to give to the RCS `co' program.
  651.  
  652. `CPPFLAGS'
  653.      Extra flags to give to the C preprocessor and programs that use it
  654.      (the C and Fortran compilers).
  655.  
  656. `FFLAGS'
  657.      Extra flags to give to the Fortran compiler.
  658.  
  659. `GFLAGS'
  660.      Extra flags to give to the SCCS `get' program.
  661.  
  662. `LDFLAGS'
  663.      Extra flags to give to compilers when they are supposed to invoke
  664.      the linker, `ld'.
  665.  
  666. `LFLAGS'
  667.      Extra flags to give to Lex.
  668.  
  669. `PFLAGS'
  670.      Extra flags to give to the Pascal compiler.
  671.  
  672. `RFLAGS'
  673.      Extra flags to give to the Fortran compiler for Ratfor programs.
  674.  
  675. `YFLAGS'
  676.      Extra flags to give to Yacc.
  677.  
  678. 
  679. File: make.info,  Node: Chained Rules,  Next: Pattern Rules,  Prev: Implicit Variables,  Up: Implicit Rules
  680.  
  681. Chains of Implicit Rules
  682. ========================
  683.  
  684.    Sometimes a file can be made by a sequence of implicit rules.  For
  685. example, a file `N.o' could be made from `N.y' by running first Yacc
  686. and then `cc'.  Such a sequence is called a "chain".
  687.  
  688.    If the file `N.c' exists, or is mentioned in the makefile, no
  689. special searching is required: `make' finds that the object file can be
  690. made by C compilation from `N.c'; later on, when considering how to
  691. make `N.c', the rule for running Yacc is used.  Ultimately both `N.c'
  692. and `N.o' are updated.
  693.  
  694.    However, even if `N.c' does not exist and is not mentioned, `make'
  695. knows how to envision it as the missing link between `N.o' and `N.y'!
  696. In this case, `N.c' is called an "intermediate file".  Once `make' has
  697. decided to use the intermediate file, it is entered in the data base as
  698. if it had been mentioned in the makefile, along with the implicit rule
  699. that says how to create it.
  700.  
  701.    Intermediate files are remade using their rules just like all other
  702. files.  The difference is that the intermediate file is deleted when
  703. `make' is finished.  Therefore, the intermediate file which did not
  704. exist before `make' also does not exist after `make'.  The deletion is
  705. reported to you by printing a `rm -f' command that shows what `make' is
  706. doing.  (You can list the target pattern of an implicit rule (such as
  707. `%.o') as a dependency of the special target `.PRECIOUS' to preserve
  708. intermediate files made by implicit rules whose target patterns match
  709. that file's name; see *Note Interrupts::.)
  710.  
  711.    A chain can involve more than two implicit rules.  For example, it is
  712. possible to make a file `foo' from `RCS/foo.y,v' by running RCS, Yacc
  713. and `cc'.  Then both `foo.y' and `foo.c' are intermediate files that
  714. are deleted at the end.
  715.  
  716.    No single implicit rule can appear more than once in a chain.  This
  717. means that `make' will not even consider such a ridiculous thing as
  718. making `foo' from `foo.o.o' by running the linker twice.  This
  719. constraint has the added benefit of preventing any infinite loop in the
  720. search for an implicit rule chain.
  721.  
  722.    There are some special implicit rules to optimize certain cases that
  723. would otherwise be handled by rule chains.  For example, making `foo'
  724. from `foo.c' could be handled by compiling and linking with separate
  725. chained rules, using `foo.o' as an intermediate file.  But what
  726. actually happens is that a special rule for this case does the
  727. compilation and linking with a single `cc' command.  The optimized rule
  728. is used in preference to the step-by-step chain because it comes
  729. earlier in the ordering of rules.
  730.  
  731. 
  732. File: make.info,  Node: Pattern Rules,  Next: Last Resort,  Prev: Chained Rules,  Up: Implicit Rules
  733.  
  734. Defining and Redefining Pattern Rules
  735. =====================================
  736.  
  737.    You define an implicit rule by writing a "pattern rule".  A pattern
  738. rule looks like an ordinary rule, except that its target contains the
  739. character `%' (exactly one of them).  The target is considered a
  740. pattern for matching file names; the `%' can match any nonempty
  741. substring, while other characters match only themselves.  The
  742. dependencies likewise use `%' to show how their names relate to the
  743. target name.
  744.  
  745.    Thus, a pattern rule `%.o : %.c' says how to make any file `STEM.o'
  746. from another file `STEM.c'.
  747.  
  748.    Note that expansion using `%' in pattern rules occurs *after* any
  749. variable or function expansions, which take place when the makefile is
  750. read.  *Note How to Use Variables: Using Variables, and *Note Functions
  751. for Transforming Text: Functions.
  752.  
  753. * Menu:
  754.  
  755. * Pattern Intro::               An introduction to pattern rules.
  756. * Pattern Examples::            Examples of pattern rules.
  757. * Automatic::                   How to use automatic variables in the
  758.                                   commands of implicit rules.
  759. * Pattern Match::               How patterns match.
  760. * Match-Anything Rules::        Precautions you should take prior to
  761.                                   defining rules that can match any
  762.                                   target file whatever.
  763. * Canceling Rules::             How to override or cancel built-in rules.
  764.  
  765. 
  766. File: make.info,  Node: Pattern Intro,  Next: Pattern Examples,  Up: Pattern Rules
  767.  
  768. Introduction to Pattern Rules
  769. -----------------------------
  770.  
  771.    A pattern rule contains the character `%' (exactly one of them) in
  772. the target; otherwise, it looks exactly like an ordinary rule.  The
  773. target is a pattern for matching file names; the `%' matches any
  774. nonempty substring, while other characters match only themselves.
  775.  
  776.    For example, `%.c' as a pattern matches any file name that ends in
  777. `.c'.  `s.%.c' as a pattern matches any file name that starts with
  778. `s.', ends in `.c' and is at least five characters long.  (There must
  779. be at least one character to match the `%'.)  The substring that the
  780. `%' matches is called the "stem".
  781.  
  782.    `%' in a dependency of a pattern rule stands for the same stem that
  783. was matched by the `%' in the target.  In order for the pattern rule to
  784. apply, its target pattern must match the file name under consideration,
  785. and its dependency patterns must name files that exist or can be made.
  786. These files become dependencies of the target.
  787.  
  788.    Thus, a rule of the form
  789.  
  790.      %.o : %.c ; COMMAND...
  791.  
  792. specifies how to make a file `N.o', with another file `N.c' as its
  793. dependency, provided that `N.c' exists or can be made.
  794.  
  795.    There may also be dependencies that do not use `%'; such a dependency
  796. attaches to every file made by this pattern rule.  These unvarying
  797. dependencies are useful occasionally.
  798.  
  799.    A pattern rule need not have any dependencies that contain `%', or
  800. in fact any dependencies at all.  Such a rule is effectively a general
  801. wildcard.  It provides a way to make any file that matches the target
  802. pattern.  *Note Last Resort::.
  803.  
  804.    Pattern rules may have more than one target.  Unlike normal rules,
  805. this does not act as many different rules with the same dependencies and
  806. commands.  If a pattern rule has multiple targets, `make' knows that
  807. the rule's commands are responsible for making all of the targets.  The
  808. commands are executed only once to make all the targets.  When searching
  809. for a pattern rule to match a target, the target patterns of a rule
  810. other than the one that matches the target in need of a rule are
  811. incidental: `make' worries only about giving commands and dependencies
  812. to the file presently in question.  However, when this file's commands
  813. are run, the other targets are marked as having been updated themselves.
  814.  
  815.    The order in which pattern rules appear in the makefile is important
  816. since this is the order in which they are considered.  Of equally
  817. applicable rules, only the first one found is used.  The rules you
  818. write take precedence over those that are built in.  Note however, that
  819. a rule whose dependencies actually exist or are mentioned always takes
  820. priority over a rule with dependencies that must be made by chaining
  821. other implicit rules.
  822.  
  823. 
  824. File: make.info,  Node: Pattern Examples,  Next: Automatic,  Prev: Pattern Intro,  Up: Pattern Rules
  825.  
  826. Pattern Rule Examples
  827. ---------------------
  828.  
  829.    Here are some examples of pattern rules actually predefined in
  830. `make'.  First, the rule that compiles `.c' files into `.o' files:
  831.  
  832.      %.o : %.c
  833.              $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
  834.  
  835. defines a rule that can make any file `X.o' from `X.c'.  The command
  836. uses the automatic variables `$@' and `$<' to substitute the names of
  837. the target file and the source file in each case where the rule applies
  838. (*note Automatic Variables: Automatic.).
  839.  
  840.    Here is a second built-in rule:
  841.  
  842.      % :: RCS/%,v
  843.              $(CO) $(COFLAGS) $<
  844.  
  845. defines a rule that can make any file `X' whatsoever from a
  846. corresponding file `X,v' in the subdirectory `RCS'.  Since the target
  847. is `%', this rule will apply to any file whatever, provided the
  848. appropriate dependency file exists.  The double colon makes the rule
  849. "terminal", which means that its dependency may not be an intermediate
  850. file (*note Match-Anything Pattern Rules: Match-Anything Rules.).
  851.  
  852.    This pattern rule has two targets:
  853.  
  854.      %.tab.c %.tab.h: %.y
  855.              bison -d $<
  856.  
  857. This tells `make' that the command `bison -d X.y' will make both
  858. `X.tab.c' and `X.tab.h'.  If the file `foo' depends on the files
  859. `parse.tab.o' and `scan.o' and the file `scan.o' depends on the file
  860. `parse.tab.h', when `parse.y' is changed, the command `bison -d parse.y'
  861. will be executed only once, and the dependencies of both `parse.tab.o'
  862. and `scan.o' will be satisfied.  (Presumably the file `parse.tab.o'
  863. will be recompiled from `parse.tab.c' and the file `scan.o' from
  864. `scan.c', while `foo' is linked from `parse.tab.o', `scan.o', and its
  865. other dependencies, and it will execute happily ever after.)
  866.  
  867. 
  868. File: make.info,  Node: Automatic,  Next: Pattern Match,  Prev: Pattern Examples,  Up: Pattern Rules
  869.  
  870. Automatic Variables
  871. -------------------
  872.  
  873.    Suppose you are writing a pattern rule to compile a `.c' file into a
  874. `.o' file: how do you write the `cc' command so that it operates on the
  875. right source file name?  You cannot write the name in the command,
  876. because the name is different each time the implicit rule is applied.
  877.  
  878.    What you do is use a special feature of `make', the "automatic
  879. variables".  These variables have values computed afresh for each rule
  880. that is executed, based on the target and dependencies of the rule.  In
  881. this example, you would use `$@' for the object file name and `$<' for
  882. the source file name.
  883.  
  884.    Here is a table of automatic variables:
  885.  
  886. `$@'
  887.      The file name of the target of the rule.  If the target is an
  888.      archive member, then `$@' is the name of the archive file.  In a
  889.      pattern rule that has multiple targets (*note Introduction to
  890.      Pattern Rules: Pattern Intro.), `$@' is the name of whichever
  891.      target caused the rule's commands to be run.
  892.  
  893. `$%'
  894.      The target member name, when the target is an archive member.
  895.      *Note Archives::.  For example, if the target is `foo.a(bar.o)'
  896.      then `$%' is `bar.o' and `$@' is `foo.a'.  `$%' is empty when the
  897.      target is not an archive member.
  898.  
  899. `$<'
  900.      The name of the first dependency.  If the target got its commands
  901.      from an implicit rule, this will be the first dependency added by
  902.      the implicit rule (*note Implicit Rules::.).
  903.  
  904. `$?'
  905.      The names of all the dependencies that are newer than the target,
  906.      with spaces between them.  For dependencies which are archive
  907.      members, only the member named is used (*note Archives::.).
  908.  
  909. `$^'
  910.      The names of all the dependencies, with spaces between them.  For
  911.      dependencies which are archive members, only the member named is
  912.      used (*note Archives::.).
  913.  
  914. `$*'
  915.      The stem with which an implicit rule matches (*note How Patterns
  916.      Match: Pattern Match.).  If the target is `dir/a.foo.b' and the
  917.      target pattern is `a.%.b' then the stem is `dir/foo'.  The stem is
  918.      useful for constructing names of related files.
  919.  
  920.      In a static pattern rule, the stem is part of the file name that
  921.      matched the `%' in the target pattern.
  922.  
  923.      In an explicit rule, there is no stem; so `$*' cannot be determined
  924.      in that way.  Instead, if the target name ends with a recognized
  925.      suffix (*note Old-Fashioned Suffix Rules: Suffix Rules.), `$*' is
  926.      set to the target name minus the suffix.  For example, if the
  927.      target name is `foo.c', then `$*' is set to `foo', since `.c' is a
  928.      suffix.  GNU `make' does this bizarre thing only for compatibility
  929.      with other implementations of `make'.  You should generally avoid
  930.      using `$*' except in implicit rules or static pattern rules.
  931.  
  932.      If the target name in an explicit rule does not end with a
  933.      recognized suffix, `$*' is set to the empty string for that rule.
  934.  
  935.    `$?' is useful even in explicit rules when you wish to operate on
  936. only the dependencies that have changed.  For example, suppose that an
  937. archive named `lib' is supposed to contain copies of several object
  938. files.  This rule copies just the changed object files into the archive:
  939.  
  940.      lib: foo.o bar.o lose.o win.o
  941.              ar r lib $?
  942.  
  943.    Of the variables listed above, four have values that are single file
  944. names, and two have values that are lists of file names.  These six
  945. have variants that get just the file's directory name or just the file
  946. name within the directory.  The variant variables' names are formed by
  947. appending `D' or `F', respectively.  These variants are semi-obsolete
  948. in GNU `make' since the functions `dir' and `notdir' can be used to get
  949. an equivalent effect (*note Functions for File Names: Filename
  950. Functions.).  Here is a table of the variants:
  951.  
  952. `$(@D)'
  953.      The directory part of the file name of the target.  If the value of
  954.      `$@' is `dir/foo.o' then `$(@D)' is `dir/'.  This value is `./' if
  955.      `$@' does not contain a slash.  `$(@D)' is equivalent to
  956.      `$(dir $@)'.
  957.  
  958. `$(@F)'
  959.      The file-within-directory part of the file name of the target.  If
  960.      the value of `$@' is `dir/foo.o' then `$(@F)' is `foo.o'.  `$(@F)'
  961.      is equivalent to `$(notdir $@)'.
  962.  
  963. `$(*D)'
  964. `$(*F)'
  965.      The directory part and the file-within-directory part of the stem;
  966.      `dir/' and `foo' in this example.
  967.  
  968. `$(%D)'
  969. `$(%F)'
  970.      The directory part and the file-within-directory part of the target
  971.      archive member name.  This makes sense only for archive member
  972.      targets of the form `ARCHIVE(MEMBER)' and is useful only when
  973.      MEMBER may contain a directory name.  (*Note Archive Members as
  974.      Targets: Archive Members.)
  975.  
  976. `$(<D)'
  977. `$(<F)'
  978.      The directory part and the file-within-directory part of the first
  979.      dependency.
  980.  
  981. `$(^D)'
  982. `$(^F)'
  983.      Lists of the directory parts and the file-within-directory parts
  984.      of all dependencies.
  985.  
  986. `$(?D)'
  987. `$(?F)'
  988.      Lists of the directory parts and the file-within-directory parts of
  989.      all dependencies that are newer than the target.
  990.  
  991.    Note that we use a special stylistic convention when we talk about
  992. these automatic variables; we write "the value of `$<'", rather than
  993. "the variable `<'" as we would write for ordinary variables such as
  994. `objects' and `CFLAGS'.  We think this convention looks more natural in
  995. this special case.  Please do not assume it has a deep significance;
  996. `$<' refers to the variable named `<' just as `$(CFLAGS)' refers to the
  997. variable named `CFLAGS'.  You could just as well use `$(<)' in place of
  998. `$<'.
  999.  
  1000. 
  1001. File: make.info,  Node: Pattern Match,  Next: Match-Anything Rules,  Prev: Automatic,  Up: Pattern Rules
  1002.  
  1003. How Patterns Match
  1004. ------------------
  1005.  
  1006.    A target pattern is composed of a `%' between a prefix and a suffix,
  1007. either or both of which may be empty.  The pattern matches a file name
  1008. only if the file name starts with the prefix and ends with the suffix,
  1009. without overlap.  The text between the prefix and the suffix is called
  1010. the "stem".  Thus, when the pattern `%.o' matches the file name
  1011. `test.o', the stem is `test'.  The pattern rule dependencies are turned
  1012. into actual file names by substituting the stem for the character `%'.
  1013. Thus, if in the same example one of the dependencies is written as
  1014. `%.c', it expands to `test.c'.
  1015.  
  1016.    When the target pattern does not contain a slash (and it usually does
  1017. not), directory names in the file names are removed from the file name
  1018. before it is compared with the target prefix and suffix.  After the
  1019. comparison of the file name to the target pattern, the directory names,
  1020. along with the slash that ends them, are added on to the dependency
  1021. file names generated from the pattern rule's dependency patterns and
  1022. the file name. The directories are ignored only for the purpose of
  1023. finding an implicit rule to use, not in the application of that rule.
  1024. Thus, `e%t' matches the file name `src/eat', with `src/a' as the stem.
  1025. When dependencies are turned into file names, the directories from the
  1026. stem are added at the front, while the rest of the stem is substituted
  1027. for the `%'.  The stem `src/a' with a dependency pattern `c%r' gives
  1028. the file name `src/car'.
  1029.  
  1030. 
  1031. File: make.info,  Node: Match-Anything Rules,  Next: Canceling Rules,  Prev: Pattern Match,  Up: Pattern Rules
  1032.  
  1033. Match-Anything Pattern Rules
  1034. ----------------------------
  1035.  
  1036.    When a pattern rule's target is just `%', it matches any file name
  1037. whatever.  We call these rules "match-anything" rules.  They are very
  1038. useful, but it can take a lot of time for `make' to think about them,
  1039. because it must consider every such rule for each file name listed
  1040. either as a target or as a dependency.
  1041.  
  1042.    Suppose the makefile mentions `foo.c'.  For this target, `make'
  1043. would have to consider making it by linking an object file `foo.c.o',
  1044. or by C compilation-and-linking in one step from `foo.c.c', or by
  1045. Pascal compilation-and-linking from `foo.c.p', and many other
  1046. possibilities.
  1047.  
  1048.    We know these possibilities are ridiculous since `foo.c' is a C
  1049. source file, not an executable.  If `make' did consider these
  1050. possibilities, it would ultimately reject them, because files such as
  1051. `foo.c.o' and `foo.c.p' would not exist.  But these possibilities are so
  1052. numerous that `make' would run very slowly if it had to consider them.
  1053.  
  1054.    To gain speed, we have put various constraints on the way `make'
  1055. considers match-anything rules.  There are two different constraints
  1056. that can be applied, and each time you define a match-anything rule you
  1057. must choose one or the other for that rule.
  1058.  
  1059.    One choice is to mark the match-anything rule as "terminal" by
  1060. defining it with a double colon.  When a rule is terminal, it does not
  1061. apply unless its dependencies actually exist.  Dependencies that could
  1062. be made with other implicit rules are not good enough.  In other words,
  1063. no further chaining is allowed beyond a terminal rule.
  1064.  
  1065.    For example, the built-in implicit rules for extracting sources from
  1066. RCS and SCCS files are terminal; as a result, if the file `foo.c,v' does
  1067. not exist, `make' will not even consider trying to make it as an
  1068. intermediate file from `foo.c,v.o' or from `RCS/SCCS/s.foo.c,v'.  RCS
  1069. and SCCS files are generally ultimate source files, which should not be
  1070. remade from any other files; therefore, `make' can save time by not
  1071. looking for ways to remake them.
  1072.  
  1073.    If you do not mark the match-anything rule as terminal, then it is
  1074. nonterminal.  A nonterminal match-anything rule cannot apply to a file
  1075. name that indicates a specific type of data.  A file name indicates a
  1076. specific type of data if some non-match-anything implicit rule target
  1077. matches it.
  1078.  
  1079.    For example, the file name `foo.c' matches the target for the pattern
  1080. rule `%.c : %.y' (the rule to run Yacc).  Regardless of whether this
  1081. rule is actually applicable (which happens only if there is a file
  1082. `foo.y'), the fact that its target matches is enough to prevent
  1083. consideration of any nonterminal match-anything rules for the file
  1084. `foo.c'.  Thus, `make' will not even consider trying to make `foo.c' as
  1085. an executable file from `foo.c.o', `foo.c.c', `foo.c.p', etc.
  1086.  
  1087.    The motivation for this constraint is that nonterminal match-anything
  1088. rules are used for making files containing specific types of data (such
  1089. as executable files) and a file name with a recognized suffix indicates
  1090. some other specific type of data (such as a C source file).
  1091.  
  1092.    Special built-in dummy pattern rules are provided solely to recognize
  1093. certain file names so that nonterminal match-anything rules will not be
  1094. considered.  These dummy rules have no dependencies and no commands, and
  1095. they are ignored for all other purposes.  For example, the built-in
  1096. implicit rule
  1097.  
  1098.      %.p :
  1099.  
  1100. exists to make sure that Pascal source files such as `foo.p' match a
  1101. specific target pattern and thereby prevent time from being wasted
  1102. looking for `foo.p.o' or `foo.p.c'.
  1103.  
  1104.    Dummy pattern rules such as the one for `%.p' are made for every
  1105. suffix listed as valid for use in suffix rules (*note Old-Fashioned
  1106. Suffix Rules: Suffix Rules.).
  1107.  
  1108. 
  1109. File: make.info,  Node: Canceling Rules,  Prev: Match-Anything Rules,  Up: Pattern Rules
  1110.  
  1111. Canceling Implicit Rules
  1112. ------------------------
  1113.  
  1114.    You can override a built-in implicit rule (or one you have defined
  1115. yourself) by defining a new pattern rule with the same target and
  1116. dependencies, but different commands.  When the new rule is defined, the
  1117. built-in one is replaced.  The new rule's position in the sequence of
  1118. implicit rules is determined by where you write the new rule.
  1119.  
  1120.    You can cancel a built-in implicit rule by defining a pattern rule
  1121. with the same target and dependencies, but no commands.  For example,
  1122. the following would cancel the rule that runs the assembler:
  1123.  
  1124.      %.o : %.s
  1125.  
  1126. 
  1127. File: make.info,  Node: Last Resort,  Next: Suffix Rules,  Prev: Pattern Rules,  Up: Implicit Rules
  1128.  
  1129. Defining Last-Resort Default Rules
  1130. ==================================
  1131.  
  1132.    You can define a last-resort implicit rule by writing a terminal
  1133. match-anything pattern rule with no dependencies (*note Match-Anything
  1134. Rules::.).  This is just like any other pattern rule; the only thing
  1135. special about it is that it will match any target.  So such a rule's
  1136. commands are used for all targets and dependencies that have no commands
  1137. of their own and for which no other implicit rule applies.
  1138.  
  1139.    For example, when testing a makefile, you might not care if the
  1140. source files contain real data, only that they exist.  Then you might
  1141. do this:
  1142.  
  1143.      %::
  1144.              touch $@
  1145.  
  1146. to cause all the source files needed (as dependencies) to be created
  1147. automatically.
  1148.  
  1149.    You can instead define commands to be used for targets for which
  1150. there are no rules at all, even ones which don't specify commands.  You
  1151. do this by writing a rule for the target `.DEFAULT'.  Such a rule's
  1152. commands are used for all dependencies which do not appear as targets in
  1153. any explicit rule, and for which no implicit rule applies.  Naturally,
  1154. there is no `.DEFAULT' rule unless you write one.
  1155.  
  1156.    If you use `.DEFAULT' with no commands or dependencies:
  1157.  
  1158.      .DEFAULT:
  1159.  
  1160. the commands previously stored for `.DEFAULT' are cleared.  Then `make'
  1161. acts as if you had never defined `.DEFAULT' at all.
  1162.  
  1163.    If you do not want a target to get the commands from a match-anything
  1164. pattern rule or `.DEFAULT', but you also do not want any commands to be
  1165. run for the target, you can give it empty commands (*note Defining
  1166. Empty Commands: Empty Commands.).
  1167.  
  1168.    You can use a last-resort rule to override part of another makefile.
  1169. *Note Overriding Part of Another Makefile: Overriding Makefiles.
  1170.  
  1171.