home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 4
/
FreshFish_May-June1994.bin
/
gnu
/
info
/
make.info-3
(
.txt
)
< prev
next >
Wrap
GNU Info File
|
1994-02-21
|
49KB
|
914 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: Errors, Next: Interrupts, Prev: Parallel, Up: Commands
Errors in Commands
==================
After each shell command returns, `make' looks at its exit status.
If the command completed successfully, the next command line is executed
in a new shell; after the last command line is finished, the rule is
finished.
If there is an error (the exit status is nonzero), `make' gives up on
the current rule, and perhaps on all rules.
Sometimes the failure of a certain command does not indicate a
problem. For example, you may use the `mkdir' command to ensure that a
directory exists. If the directory already exists, `mkdir' will report
an error, but you probably want `make' to continue regardless.
To ignore errors in a command line, write a `-' at the beginning of
the line's text (after the initial tab). The `-' is discarded before
the command is passed to the shell for execution.
For example,
clean:
-rm -f *.o
This causes `rm' to continue even if it is unable to remove a file.
When you run `make' with the `-i' or `--ignore-errors' flag, errors
are ignored in all commands of all rules. A rule in the makefile for
the special target `.IGNORE' has the same effect. These ways of
ignoring errors are obsolete because `-' is more flexible.
When errors are to be ignored, because of either a `-' or the `-i'
flag, `make' treats an error return just like success, except that it
prints out a message that tells you the status code the command exited
with, and says that the error has been ignored.
When an error happens that `make' has not been told to ignore, it
implies that the current target cannot be correctly remade, and neither
can any other that depends on it either directly or indirectly. No
further commands will be executed for these targets, since their
preconditions have not been achieved.
Normally `make' gives up immediately in this circumstance, returning
a nonzero status. However, if the `-k' or `--keep-going' flag is
specified, `make' continues to consider the other dependencies of the
pending targets, remaking them if necessary, before it gives up and
returns nonzero status. For example, after an error in compiling one
object file, `make -k' will continue compiling other object files even
though it already knows that linking them will be impossible. *Note
Summary of Options: Options Summary.
The usual behavior assumes that your purpose is to get the specified
targets up to date; once `make' learns that this is impossible, it
might as well report the failure immediately. The `-k' option says
that the real purpose is to test as many of the changes made in the
program as possible, perhaps to find several independent problems so
that you can correct them all before the next attempt to compile. This
is why Emacs' `compile' command passes the `-k' flag by default.
File: make.info, Node: Interrupts, Next: Recursion, Prev: Errors, Up: Commands
Interrupting or Killing `make'
==============================
If `make' gets a fatal signal while a command is executing, it may
delete the target file that the command was supposed to update. This is
done if the target file's last-modification time has changed since
`make' first checked it.
The purpose of deleting the target is to make sure that it is remade
from scratch when `make' is next run. Why is this? Suppose you type
`Ctrl-c' while a compiler is running, and it has begun to write an
object file `foo.o'. The `Ctrl-c' kills the compiler, resulting in an
incomplete file whose last-modification time is newer than the source
file `foo.c'. But `make' also receives the `Ctrl-c' signal and deletes
this incomplete file. If `make' did not do this, the next invocation
of `make' would think that `foo.o' did not require updating--resulting
in a strange error message from the linker when it tries to link an
object file half of which is missing.
You can prevent the deletion of a target file in this way by making
the special target `.PRECIOUS' depend on it. Before remaking a target,
`make' checks to see whether it appears on the dependencies of
`.PRECIOUS', and thereby decides whether the target should be deleted
if a signal happens. Some reasons why you might do this are that the
target is updated in some atomic fashion, or exists only to record a
modification-time (its contents do not matter), or must exist at all
times to prevent other sorts of trouble.
File: make.info, Node: Recursion, Next: Sequences, Prev: Interrupts, Up: Commands
Recursive Use of `make'
=======================
Recursive use of `make' means using `make' as a command in a
makefile. This technique is useful when you want separate makefiles for
various subsystems that compose a larger system. For example, suppose
you have a subdirectory `subdir' which has its own makefile, and you
would like the containing directory's makefile to run `make' on the
subdirectory. You can do it by writing this:
subsystem:
cd subdir; $(MAKE)
or, equivalently, this (*note Summary of Options: Options Summary.):
subsystem:
$(MAKE) -C subdir
You can write recursive `make' commands just by copying this example,
but there are many things to know about how they work and why, and about
how the sub-`make' relates to the top-level `make'.
* Menu:
* MAKE Variable:: The special effects of using `$(MAKE)'.
* Variables/Recursion:: How to communicate variables to a sub-`make'.
* Options/Recursion:: How to communicate options to a sub-`make'.
* -w Option:: How the `-w' or `--print-directory' option
helps debug use of recursive `make' commands.
File: make.info, Node: MAKE Variable, Next: Variables/Recursion, Up: Recursion
How the `MAKE' Variable Works
-----------------------------
Recursive `make' commands should always use the variable `MAKE', not
the explicit command name `make', as shown here:
subsystem:
cd subdir; $(MAKE)
The value of this variable is the file name with which `make' was
invoked. If this file name was `/bin/make', then the command executed
is `cd subdir; /bin/make'. If you use a special version of `make' to
run the top-level makefile, the same special version will be executed
for recursive invocations.
Also, any arguments that define variable values are added to `MAKE',
so the sub-`make' gets them too. Thus, if you do `make CFLAGS=-O', so
that all C compilations will be optimized, the sub-`make' is run with
`cd subdir; /bin/make CFLAGS=-O'.
The `MAKE' variable actually just refers to two other variables
which contain these special values. In fact, `MAKE' is always defined
as `$(MAKE_COMMAND) $(MAKEOVERRIDES)'. The variable `MAKE_COMMAND' is
the file name with which `make' was invoked (such as `/bin/make',
above). The variable `MAKEOVERRIDES' contains definitions for the
variables defined on the command line; in the above example, its value
is `CFLAGS=-O'. If you *do not* want these variable de