home *** CD-ROM | disk | FTP | other *** search
/ Openstep 4.2 (Developer) / Openstep Developer 4.2.iso / NextDeveloper / Source / GNU / make / make-3.74 / make.info-5 < prev    next >
Encoding:
GNU Info File  |  1995-08-01  |  46.5 KB  |  1,132 lines

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