home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD1.bin
/
gnu
/
info
/
make.info-6
(
.txt
)
< prev
next >
Wrap
GNU Info File
|
1994-11-12
|
49KB
|
877 lines
This is Info file make.info, produced by Makeinfo-1.55 from the input
file ./make.texinfo.
This file documents the GNU Make utility, which determines
automatically which pieces of a large program need to be recompiled,
and issues the commands to recompile them.
This is Edition 0.47, last updated 1 November 1994, of `The GNU Make
Manual', for `make', Version 3.72 Beta.
Copyright (C) 1988, '89, '90, '91, '92, '93, '94 Free Software
Foundation, Inc.
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.
Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided that
the entire resulting derived work is distributed under the terms of a
permission notice identical to this one.
Permission is granted to copy and distribute translations of this
manual into another language, under the above conditions for modified
versions, except that this permission notice may be stated in a
translation approved by the Free Software Foundation.
File: make.info, Node: Match-Anything Rules, Next: Canceling Rules, Prev: Pattern Match, Up: Pattern Rules
Match-Anything Pattern Rules
----------------------------
When a pattern rule's target is just `%', it matches any file name
whatever. We call these rules "match-anything" rules. They are very
useful, but it can take a lot of time for `make' to think about them,
because it must consider every such rule for each file name listed
either as a target or as a dependency.
Suppose the makefile mentions `foo.c'. For this target, `make'
would have to consider making it by linking an object file `foo.c.o',
or by C compilation-and-linking in one step from `foo.c.c', or by
Pascal compilation-and-linking from `foo.c.p', and many other
possibilities.
We know these possibilities are ridiculous since `foo.c' is a C
source file, not an executable. If `make' did consider these
possibilities, it would ultimately reject them, because files such as
`foo.c.o' and `foo.c.p' would not exist. But these possibilities are so
numerous that `make' would run very slowly if it had to consider them.
To gain speed, we have put various constraints on the way `make'
considers match-anything rules. There are two different constraints
that can be applied, and each time you define a match-anything rule you
must choose one or the other for that rule.
One choice is to mark the match-anything rule as "terminal" by
defining it with a double colon. When a rule is terminal, it does not
apply unless its dependencies actually exist. Dependencies that could
be made with other implicit rules are not good enough. In other words,
no further chaining is allowed beyond a terminal rule.
For example, the built-in implicit rules for extracting sources from
RCS and SCCS files are terminal; as a result, if the file `foo.c,v' does
not exist, `make' will not even consider trying to make it as an
intermediate file from `foo.c,v.o' or from `RCS/SCCS/s.foo.c,v'. RCS
and SCCS files are generally ultimate source files, which should not be
remade from any other files; therefore, `make' can save time by not
looking for ways to remake them.
If you do not mark the match-anything rule as terminal, then it is
nonterminal. A nonterminal match-anything rule cannot apply to a file
name that indicates a specific type of data. A file name indicates a
specific type of data if some non-match-anything implicit rule target
matches it.
For example, the file name `foo.c' matches the target for the pattern
rule `%.c : %.y' (the rule to run Yacc). Regardless of whether this
rule is actually applicable (which happens only if there is a file
`foo.y'), the fact that its target matches is enough to prevent
consideration of any nonterminal match-anything rules for the file
`foo.c'. Thus, `make' will not even consider trying to make `foo.c' as
an executable file from `foo.c.o', `foo.c.c', `foo.c.p', etc.
The motivation for this constraint is that nonterminal match-anything
rules are used for making files containing specific types of data (such
as executable files) and a file name with a recognized suffix indicates
some other specific type of data (such as a C source file).
Special built-in dummy pattern rules are provided solely to recognize
certain file names so that nonterminal match-anything rules will not be
considered. These dummy rules have no dependencies and no commands, and
they are ignored for all other purposes. For example, the built-in
implicit rule
%.p :
exists to make sure that Pascal source files such as `foo.p' match a
specific target pattern and thereby prevent time from being wasted
looking for `foo.p.o' or `foo.p.c'.
Dummy pattern rules such as the one for `%.p' are made for every
suffix listed as valid for use in suffix rules (*note Old-Fashioned
Suffix Rules: Suffix Rules.).
File: make.info, Node: Canceling Rules, Prev: Match-Anything Rules, Up: Pattern Rules
Canceling Implicit Rules
------------------------
You can override a built-in implicit rule (or one you have defined
yourself) by defining a new pattern rule with the same target and
dependencies, but different commands. When the new rule is defined, the
built-in one is replaced. The new rule's position in the sequence of
implicit rules is determined by where you write the new rule.
You can cancel a built-in implicit rule by defining a pattern rule
with the same target and dependencies, but no commands. For example,
the following would cancel the rule that runs the assembler:
%.o : %.s
File: make.info, Node: Last Resort, Next: Suffix Rules, Prev: Pattern Rules, Up: Implicit Rules
Defining Last-Resort Default Rules
==================================
You can define a last-resort implicit rule by writing a terminal
match-anything pattern rule with no dependencies (*note Match-Anything
Rules::.). This is just like any other pattern rule; the only thing
special about it is that it will match any target. So such a rule's
commands are used for all targets and dependencies that have no commands
of their own and for which no other implicit rule applies.
For example, when testing a makefile, you might not care if the
source files contain real data, only that they exist. Then you might
do this:
%::
touch $@
to cause all the source files needed (as dependencies) to be created
automatically.
You can instead define commands to be used for targets for which
there are no rules at all, even ones which don't specify commands. You
do this by writing a rule for the target `.DEFAULT'. Such a rule's
commands are used for all dependencies which do not appear as targets in
any explicit rule, and for which no implicit rule applies. Naturally,
there is no `.DEFAULT' rule unless you write one.
If you use `.DEFAULT' with no commands or dependencies:
.DEFAULT:
the commands previously stored for `.DEFAULT' are cleared. Then `make'
acts as if you had never defined `.DEFAULT' at all.
If you do not want a target to get the commands from a match-anything
pattern rule or `.DEFAULT', but you also do not want any commands to be
run for the target, you can give it empty commands (*note Defining
Empty Commands: Empty Commands.).
You can use a last-resort rule to override part of another makefile.
*Note Overriding Part of Another Makefile: Overriding Makefiles.
File: make.info, Node: Suffix Rules, Next: Search Algorithm, Prev: Last Resort, Up: Implicit Rules
Old-Fashioned Suffix Rules
==========================
"Suffix rules" are the old-fashioned way of defining implicit rules
for `make'. Suffix rules are obsolete because pattern rules are more
general and clearer. They are supported in GNU `make' for
compatibility with old makefiles. They come in two kinds:
"double-suffix" and "single-suffix".
A double-suffix rule is defined by a pair of suffixes: the target
suffix and the source suffix. It matches any file whose name ends with
the target suffix. The corresponding implicit dependency is made by
replacing the target suffix with the