home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 4
/
FreshFish_May-June1994.bin
/
gnu
/
info
/
make.info-6
(
.txt
)
< prev
next >
Wrap
GNU Info File
|
1994-02-21
|
48KB
|
870 lines
This is Info file make.info, produced by Makeinfo-1.54 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.45, last updated 14 December 1993, of `The GNU
Make Manual', for `make', Version 3.70 Beta.
Copyright (C) 1988, '89, '90, '91, '92, '93 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: 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 source suffix in the file name. A
two-suffix rule whose target and source suffixes are `.o' and `.c' is
equivalent to the pattern rule `%.o : %.c'.
A single-suffix rule is defined by a single suffix, which is the
source suffix. It matches any file name, and the corresponding implicit
dependency name is made by appending the source suffix. A single-suffix
rule whose source suffix is `.c' is equivalent to the pattern rule `% :
%.c'.
Suffix rule definitions are recognized by comparing each rule's
target against a defined list of known suffixes. When `make' sees a
rule whose target is a known suffix, this rule is considered a
single-suffix rule. When `make' sees a rule whose target is two known
suffixes concatenated, this rule is taken as a double-suffix rule.
For example, `.c' and `.o' are both on the default list of known
suffixes. Therefore, if you define a rule whose target is `.c.o',
`make' takes it to be a double-suffix rule with source suffix `.c' and
target suffix `.o'. Here is the old-fashioned way to define the rule
for compiling a C source file:
.c.o:
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
Suffix rules cannot have any dependencies of their own. If they
have any, they are treated as normal files with funny names, not as
suffix rules. Thus, the rule:
.c.o: foo.h
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
tells how to make the file `.c.o' from the dependency file `foo.h', and
is not at all like the pattern rule:
%.o: %.c foo.h
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
which tells how to make `.o' files from `.c' files, and makes all `.o'
files using this pattern rule also depend on `foo.h'.
Suffix rules with no commands are also meaningless. They do not
remove previous rules as do pattern rules with no commands (*note
Canceling Implicit Rules: Canceling Rules.). They simply enter the
suffix or pair of suffixes concatenated as a target in the data base.
The known suffixes are simply the names of the dependencies of the
special target `.SUFFIXES'. You can add your own suffixes by writing a
rule for `.SUFFIXES' that adds more dependencies, as in:
.SUFFIXES: .hack .win
which adds `.hack' and `.win' to the end of the list of suffixes.
If you wish to eliminate the default known suffixes instead of just
adding to them, write a rule for `.SUFFIXES' with no dependencies. By
special dispensation, this eliminates all existing dependencies of
`.SUFFIXES'. You can then write another rule to add the suffixes you
want. For example,
.SUFFIXES: # Delete the default suffixes
.SUFFIXES: .c .o .h # Define our suffix list
The `-r' or `--no-builtin-rules' flag causes the default list of
suffixes to be empty.
The variable `SUFFIXES' is defined to the default list of suffixes
before `make' reads any makefiles. You can change the list of suffixes
with a rule for the special target `.SUFFIXES', but that does not alter
this variable.
File: make.info, Node: Search Algorithm, Prev: Suffix Rules, Up: Implicit Rules
Implicit Rule Search Algorithm
==============================
Here is the procedure `make' uses for searching for an implicit rule
for a target T. This procedure is followed for each double-colon rule
with no commands, for each target of ordinary rules none of which have
commands, and for each dependency that is not the target of any rule.
It is also followed recursively for dependencies that come from implicit
rules, in the search for a chain of rules.
Suffix rules are not mentioned in this algorithm because suffix
rules are converted to equivalent pattern rules once the makefiles have
been read in.
For an archive member target of the form `ARCHIVE(MEMBER)', the
following algorithm is run twice, first using the entire target name T,
and second using `(MEMBER)' as the target T if the first run found no
rule.
1. Split T into a directory part, called D, and the rest, called N.
For example, if T is `src/foo.o', then D is `src/' and N is
`foo.o'.
2. Make a list of all the pattern rules one of whose targets matches
T or N. If the target pattern contains a slash, it is matched
against T; otherwise, against N.
3. If any rule in that list is *not* a match-anything rule, then
remove all nonterminal match-anything rules from the list.
4. Remove from the list all rules with no commands.
5. For each pattern rule in the list:
a. Find the stem S, which is the nonempty part of T or N matched
by the `%' in the target pattern.
b. Compute the dependency names by substituting S for `%'; if
the target pattern does not contain a slash, append D to the
front of each dependency name.
c. Test whether all the dependencies exist or ought to exist.
(If a file name is mentioned in the makefile as a target or
as an explicit dependency, then we say it ought to exist.)
If all dependencies exist or ought to exist, or there are no
dependencies, then this rule applies.
6. If no pattern rule has been found so far, try harder. For each
pattern rule in the list:
a. If the rule is terminal, ignore it and go on to the next rule.
b. Compute the dependency names as before.
c. Test whether all the dependencies exist or ought to exist.
d. For each dependency that does not exist, follow this algorithm
recursively to see if the dependency can be made by an
implicit rule.
e. If all dependencies exist, ought to exist, or can be made by
implicit rules, then this rule applies.
7. If no implicit rule applies, the rule for `.DEFAULT', if any,
applies. In that case, give T the same commands that `.DEFAULT'
has. Otherwise, there are no commands for T.
Once a rule that applies has been found, for each target pattern of
the rule other than the one that matched T or N, the `%' in the pattern
is replaced with S and the resultant file name is stored until the
commands to remake the target file T are executed. After these
commands are executed, each of these stored file names are entered into
the data base and marked as having been updated and having the same
update status as the file T.
When the commands of a pattern rule are executed for T, the automatic
variables are