635 lines
15 KiB
HTML
635 lines
15 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of MAKE</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>MAKE</H1>
|
|
Section: User Commands (1)<BR>Updated: 28 February 2016<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
make - GNU make utility to maintain groups of programs
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<B>make</B>
|
|
|
|
[<I>OPTION</I>]... [<I>TARGET</I>]...
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
<P>
|
|
|
|
The
|
|
<I>make</I>
|
|
|
|
utility will determine automatically which pieces of a large program need to
|
|
be recompiled, and issue the commands to recompile them. The manual describes
|
|
the GNU implementation of
|
|
<B>make</B>,
|
|
|
|
which was written by Richard Stallman and Roland McGrath, and is currently
|
|
maintained by Paul Smith. Our examples show C programs, since they are very
|
|
common, but you can use
|
|
<B>make</B>
|
|
|
|
with any programming language whose compiler can be run with a shell command.
|
|
In fact,
|
|
<B>make</B>
|
|
|
|
is not limited to programs. You can use it to describe any task where some
|
|
files must be updated automatically from others whenever the others change.
|
|
<P>
|
|
|
|
To prepare to use
|
|
<B>make</B>,
|
|
|
|
you must write a file called the
|
|
<I>makefile</I>
|
|
|
|
that describes the relationships among files in your program, and the states
|
|
the commands for updating each file. In a program, typically the executable
|
|
file is updated from object files, which are in turn made by compiling source
|
|
files.
|
|
<P>
|
|
|
|
Once a suitable makefile exists, each time you change some source files,
|
|
this simple shell command:
|
|
<P>
|
|
<DL COMPACT><DT id="1"><DD>
|
|
<B>make</B>
|
|
|
|
</DL>
|
|
|
|
<P>
|
|
suffices to perform all necessary recompilations.
|
|
The
|
|
<B>make</B>
|
|
|
|
program uses the makefile description and the last-modification times of the
|
|
files to decide which of the files need to be updated. For each of those
|
|
files, it issues the commands recorded in the makefile.
|
|
<P>
|
|
|
|
<B>make</B>
|
|
|
|
executes commands in the
|
|
<I>makefile</I>
|
|
|
|
to update one or more target
|
|
<I>names</I>,
|
|
|
|
where
|
|
<I>name</I>
|
|
|
|
is typically a program.
|
|
If no
|
|
<B>-f</B>
|
|
|
|
option is present,
|
|
<B>make</B>
|
|
|
|
will look for the makefiles
|
|
<I>GNUmakefile</I>,
|
|
|
|
<I>makefile</I>,
|
|
|
|
and
|
|
<I>Makefile</I>,
|
|
|
|
in that order.
|
|
<P>
|
|
|
|
Normally you should call your makefile either
|
|
<I>makefile</I>
|
|
|
|
or
|
|
<I>Makefile</I>.
|
|
|
|
(We recommend
|
|
<I>Makefile</I>
|
|
|
|
because it appears prominently near the beginning of a directory
|
|
listing, right near other important files such as
|
|
<I>README</I>.)
|
|
|
|
The first name checked,
|
|
<I>GNUmakefile</I>,
|
|
|
|
is not recommended for most makefiles. You should use this name if you have a
|
|
makefile that is specific to GNU
|
|
<B>make</B>,
|
|
|
|
and will not be understood by other versions of
|
|
<B>make</B>.
|
|
|
|
If
|
|
<I>makefile</I>
|
|
|
|
is '-', the standard input is read.
|
|
<P>
|
|
|
|
<B>make</B>
|
|
|
|
updates a target if it depends on prerequisite files
|
|
that have been modified since the target was last modified,
|
|
or if the target does not exist.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>OPTIONS</H2>
|
|
|
|
<P>
|
|
<DL COMPACT>
|
|
<DT id="2"><B>-b</B>, <B>-m</B><DD>
|
|
These options are ignored for compatibility with other versions of
|
|
<B>make</B>.
|
|
|
|
<DT id="3"><B>-B</B>, <B>--always-make</B><DD>
|
|
Unconditionally make all targets.
|
|
<DT id="4"><B>-C</B> <I>dir</I>, <B>--directory</B>=<I>dir</I><DD>
|
|
Change to directory
|
|
<I>dir</I>
|
|
|
|
before reading the makefiles or doing anything else.
|
|
If multiple
|
|
<B>-C</B>
|
|
|
|
options are specified, each is interpreted relative to the
|
|
previous one:
|
|
<B>-C </B>/
|
|
|
|
<B>-C </B>etc
|
|
|
|
is equivalent to
|
|
<B>-C </B>/etc.
|
|
|
|
This is typically used with recursive invocations of
|
|
<B>make</B>.
|
|
|
|
<DT id="5"><B>-d</B>
|
|
|
|
<DD>
|
|
Print debugging information in addition to normal processing.
|
|
The debugging information says which files are being considered for
|
|
remaking, which file-times are being compared and with what results,
|
|
which files actually need to be remade, which implicit rules are
|
|
considered and which are applied---everything interesting about how
|
|
<B>make</B>
|
|
|
|
decides what to do.
|
|
<DT id="6"><B>--debug</B><I>[=FLAGS]</I>
|
|
|
|
<DD>
|
|
Print debugging information in addition to normal processing.
|
|
If the
|
|
<I>FLAGS</I>
|
|
|
|
are omitted, then the behavior is the same as if
|
|
<B>-d</B>
|
|
|
|
was specified.
|
|
<I>FLAGS</I>
|
|
|
|
may be
|
|
<I>a</I>
|
|
|
|
for all debugging output (same as using
|
|
<B>-d</B>),
|
|
|
|
<I>b</I>
|
|
|
|
for basic debugging,
|
|
<I>v</I>
|
|
|
|
for more verbose basic debugging,
|
|
<I>i</I>
|
|
|
|
for showing implicit rules,
|
|
<I>j</I>
|
|
|
|
for details on invocation of commands, and
|
|
<I>m</I>
|
|
|
|
for debugging while remaking makefiles. Use
|
|
<I>n</I>
|
|
|
|
to disable all previous debugging flags.
|
|
<DT id="7"><B>-e</B>, <B>--environment-overrides</B><DD>
|
|
Give variables taken from the environment precedence
|
|
over variables from makefiles.
|
|
<DT id="8"><B>-f</B> <I>file</I>, <B>--file</B>=<I>file</I>, <B>--makefile</B>=<I>FILE</I><DD>
|
|
Use
|
|
<I>file</I>
|
|
|
|
as a makefile.
|
|
<DT id="9"><B>-i</B>, <B>--ignore-errors</B><DD>
|
|
Ignore all errors in commands executed to remake files.
|
|
<DT id="10"><B>-I</B> <I>dir</I>, <B>--include-dir</B>=<I>dir</I><DD>
|
|
Specifies a directory
|
|
<I>dir</I>
|
|
|
|
to search for included makefiles.
|
|
If several
|
|
<B>-I</B>
|
|
|
|
options are used to specify several directories, the directories are
|
|
searched in the order specified.
|
|
Unlike the arguments to other flags of
|
|
<B>make</B>,
|
|
|
|
directories given with
|
|
<B>-I</B>
|
|
|
|
flags may come directly after the flag:
|
|
<B>-I</B><I>dir</I>
|
|
|
|
is allowed, as well as
|
|
<B>-I</B>
|
|
|
|
<I>dir</I>.
|
|
|
|
This syntax is allowed for compatibility with the C
|
|
preprocessor's
|
|
<B>-I</B>
|
|
|
|
flag.
|
|
<DT id="11"><B>-j</B> [<I>jobs</I>], <B>--jobs</B>[=<I>jobs</I>]<DD>
|
|
Specifies the number of
|
|
<I>jobs</I>
|
|
|
|
(commands) to run simultaneously.
|
|
If there is more than one
|
|
<B>-j</B>
|
|
|
|
option, the last one is effective.
|
|
If the
|
|
<B>-j</B>
|
|
|
|
option is given without an argument,
|
|
<B>make</B>
|
|
|
|
will not limit the number of jobs that can run simultaneously. When
|
|
<B>make</B>
|
|
|
|
invokes a
|
|
<B>sub-make,</B>
|
|
|
|
all instances of make will coordinate to run the specified number of
|
|
jobs at a time; see the section
|
|
<B>PARALLEL MAKE AND THE JOBSERVER</B>
|
|
|
|
for details.
|
|
<DT id="12"><B>--jobserver-fds</B> [<I>R,W</I>]<DD>
|
|
Internal option
|
|
<B>make</B>
|
|
|
|
uses to pass the jobserver pipe read and write file descriptor numbers
|
|
to
|
|
<B>sub-makes;</B>
|
|
|
|
see the section
|
|
<B>PARALLEL MAKE AND THE JOBSERVER</B>
|
|
|
|
for details
|
|
<DT id="13"><B>-k</B>, <B>--keep-going</B><DD>
|
|
Continue as much as possible after an error.
|
|
While the target that failed, and those that depend on it, cannot
|
|
be remade, the other dependencies of these targets can be processed
|
|
all the same.
|
|
<DT id="14"><B>-l</B> [<I>load</I>], <B>--load-average</B>[=<I>load</I>]<DD>
|
|
Specifies that no new jobs (commands) should be started if there are
|
|
others jobs running and the load average is at least
|
|
<I>load</I>
|
|
|
|
(a floating-point number).
|
|
With no argument, removes a previous load limit.
|
|
<DT id="15"><B>-L</B>, <B>--check-symlink-times</B><DD>
|
|
Use the latest mtime between symlinks and target.
|
|
<DT id="16"><B>-n</B>, <B>--just-print</B>, <B>--dry-run</B>, <B>--recon</B><DD>
|
|
Print the commands that would be executed, but do not execute them (except in
|
|
certain circumstances).
|
|
<DT id="17"><B>-o</B> <I>file</I>, <B>--old-file</B>=<I>file</I>, <B>--assume-old</B>=<I>file</I><DD>
|
|
Do not remake the file
|
|
<I>file</I>
|
|
|
|
even if it is older than its dependencies, and do not remake anything
|
|
on account of changes in
|
|
<I>file</I>.
|
|
|
|
Essentially the file is treated as very old and its rules are ignored.
|
|
<DT id="18"><B>-O</B>[<I>type</I>], <B>--output-sync</B>[=<I>type</I>]<DD>
|
|
When running multiple jobs in parallel with <B>-j</B>, ensure the output of
|
|
each job is collected together rather than interspersed with output from
|
|
other jobs. If
|
|
<I>type</I>
|
|
|
|
is not specified or is
|
|
<B>target</B>
|
|
|
|
the output from the entire recipe for each target is grouped together. If
|
|
<I>type</I>
|
|
|
|
is
|
|
<B>line</B>
|
|
|
|
the output from each command line within a recipe is grouped together.
|
|
If
|
|
<I>type</I>
|
|
|
|
is
|
|
<B>recurse</B>
|
|
|
|
output from an entire recursive make is grouped together. If
|
|
<I>type</I>
|
|
|
|
is
|
|
<B>none</B>
|
|
|
|
output synchronization is disabled.
|
|
<DT id="19"><B>-p</B>, <B>--print-data-base</B><DD>
|
|
Print the data base (rules and variable values) that results from
|
|
reading the makefiles; then execute as usual or as otherwise
|
|
specified.
|
|
This also prints the version information given by the
|
|
<B>-v</B>
|
|
|
|
switch (see below).
|
|
To print the data base without trying to remake any files, use
|
|
<I>make -p -f/dev/null</I>.
|
|
|
|
<DT id="20"><B>-q</B>, <B>--question</B><DD>
|
|
``Question mode''.
|
|
Do not run any commands, or print anything; just return an exit status
|
|
that is zero if the specified targets are already up to date, nonzero
|
|
otherwise.
|
|
<DT id="21"><B>-r</B>, <B>--no-builtin-rules</B><DD>
|
|
Eliminate use of the built-in implicit rules.
|
|
Also clear out the default list of suffixes for suffix rules.
|
|
<DT id="22"><B>-R</B>, <B>--no-builtin-variables</B><DD>
|
|
Don't define any built-in variables.
|
|
<DT id="23"><B>-s</B>, <B>--silent</B>, <B>--quiet</B><DD>
|
|
Silent operation; do not print the commands as they are executed.
|
|
<DT id="24"><B>-S</B>, <B>--no-keep-going</B>, <B>--stop</B><DD>
|
|
Cancel the effect of the
|
|
<B>-k</B>
|
|
|
|
option.
|
|
This is never necessary except in a recursive
|
|
<B>make</B>
|
|
|
|
where
|
|
<B>-k</B>
|
|
|
|
might be inherited from the top-level
|
|
<B>make</B>
|
|
|
|
via MAKEFLAGS or if you set
|
|
<B>-k</B>
|
|
|
|
in MAKEFLAGS in your environment.
|
|
<DT id="25"><B>-t</B>, <B>--touch</B><DD>
|
|
Touch files (mark them up to date without really changing them)
|
|
instead of running their commands.
|
|
This is used to pretend that the commands were done, in order to fool
|
|
future invocations of
|
|
<B>make</B>.
|
|
|
|
<DT id="26"><B>--trace</B>
|
|
|
|
<DD>
|
|
Information about the disposition of each target is printed (why the target is
|
|
being rebuilt and what commands are run to rebuild it).
|
|
<DT id="27"><B>-v</B>, <B>--version</B><DD>
|
|
Print the version of the
|
|
<B>make</B>
|
|
|
|
program plus a copyright, a list of authors and a notice that there
|
|
is no warranty.
|
|
<DT id="28"><B>-w</B>, <B>--print-directory</B><DD>
|
|
Print a message containing the working directory
|
|
before and after other processing.
|
|
This may be useful for tracking down errors from complicated nests of
|
|
recursive
|
|
<B>make</B>
|
|
|
|
commands.
|
|
<DT id="29"><B>--no-print-directory</B>
|
|
|
|
<DD>
|
|
Turn off
|
|
<B>-w</B>,
|
|
|
|
even if it was turned on implicitly.
|
|
<DT id="30"><B>-W</B> <I>file</I>, <B>--what-if</B>=<I>file</I>, <B>--new-file</B>=<I>file</I>, <B>--assume-new</B>=<I>file</I><DD>
|
|
Pretend that the target
|
|
<I>file</I>
|
|
|
|
has just been modified.
|
|
When used with the
|
|
<B>-n</B>
|
|
|
|
flag, this shows you what would happen if you were to modify that file.
|
|
Without
|
|
<B>-n</B>,
|
|
|
|
it is almost the same as running a
|
|
<I>touch</I>
|
|
|
|
command on the given file before running
|
|
<B>make</B>,
|
|
|
|
except that the modification time is changed only in the imagination of
|
|
<B>make</B>.
|
|
|
|
<DT id="31"><B>--warn-undefined-variables</B>
|
|
|
|
<DD>
|
|
Warn when an undefined variable is referenced.
|
|
</DL>
|
|
<A NAME="lbAF"> </A>
|
|
<H2>EXIT STATUS</H2>
|
|
|
|
GNU
|
|
<B>make</B>
|
|
|
|
exits with a status of zero if all makefiles were successfully parsed
|
|
and no targets that were built failed. A status of one will be returned
|
|
if the
|
|
<B>-q</B>
|
|
|
|
flag was used and
|
|
<B>make</B>
|
|
|
|
determines that a target needs to be rebuilt. A status of two will be
|
|
returned if any errors were encountered.
|
|
<A NAME="lbAG"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
The full documentation for
|
|
<B>make</B>
|
|
|
|
is maintained as a Texinfo manual. If the
|
|
<B>info</B>
|
|
|
|
and
|
|
<B>make</B>
|
|
|
|
programs are properly installed at your site, the command
|
|
<DL COMPACT>
|
|
<DT id="32"><DD>
|
|
<B>info make</B>
|
|
|
|
</DL>
|
|
<P>
|
|
|
|
should give you access to the complete manual.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>PARALLEL MAKE AND THE JOBSERVER</H2>
|
|
|
|
Using the
|
|
<I>-j</I>
|
|
|
|
option, the user can instruct
|
|
<B>make</B>
|
|
|
|
to execute tasks in parallel. By specifying a numeric argument to
|
|
<I>-j</I>
|
|
|
|
the user may specify an upper limit of the number of parallel tasks to
|
|
be run.
|
|
<P>
|
|
|
|
When the build environment is such that a top level
|
|
<B>make</B>
|
|
|
|
invokes
|
|
<B>sub-makes</B>
|
|
|
|
(for instance, a style in which each sub-directory contains its own
|
|
<I>Makefile</I>
|
|
|
|
), no individual instance of
|
|
<B>make</B>
|
|
|
|
knows how many tasks are running in parallel, so keeping the number of
|
|
tasks under the upper limit would be impossible without communication
|
|
between all the
|
|
<B>make</B>
|
|
|
|
instances running. While solutions like having the top level
|
|
<B>make</B>
|
|
|
|
serve as a central controller are feasible, or using other
|
|
synchronization mechanisms like shared memory or sockets can be
|
|
created, the current implementation uses a simple shared pipe.
|
|
<P>
|
|
|
|
This pipe is created by the top-level
|
|
<B>make</B>
|
|
|
|
process, and passed on to all the
|
|
<B>sub-makes.</B>
|
|
|
|
The top level
|
|
<B>make</B>process<B>writes</B>
|
|
|
|
<B>N-1</B>
|
|
|
|
one-byte tokens into the pipe (The top level
|
|
<B>make</B>
|
|
|
|
is assumed to reserve one token for itself). Whenever any of the
|
|
<B>make</B>
|
|
|
|
processes (including the top-level
|
|
<B>make</B>
|
|
|
|
) needs to run a new task, it reads a byte from the shared pipe. If
|
|
there are no tokens left, it must wait for a token to be written back
|
|
to the pipe. Once the task is completed, the
|
|
<B>make</B>
|
|
|
|
process writes a token back to the pipe (and thus, if the tokens had
|
|
been exhausted, unblocking the first
|
|
<B>make</B>
|
|
|
|
process that was waiting to read a token). Since only
|
|
<B>N-1</B>
|
|
|
|
tokens were written into the pipe, no more than
|
|
<B>N</B>
|
|
|
|
tasks can be running at any given time.
|
|
<P>
|
|
|
|
If the job to be run is not a
|
|
<B>sub-make</B>
|
|
|
|
then
|
|
<B>make</B>
|
|
|
|
will close the jobserver pipe file descriptors before invoking the
|
|
commands, so that the command can not interfere with the
|
|
<I>jobserver,</I>
|
|
|
|
and the command does not find any unusual file descriptors.
|
|
<A NAME="lbAI"> </A>
|
|
<H2>BUGS</H2>
|
|
|
|
See the chapter ``Problems and Bugs'' in
|
|
<I>The GNU Make Manual</I>.
|
|
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>AUTHOR</H2>
|
|
|
|
This manual page contributed by Dennis Morse of Stanford University.
|
|
Further updates contributed by Mike Frysinger. It has been reworked by Roland
|
|
McGrath. Maintained by Paul Smith.
|
|
<A NAME="lbAK"> </A>
|
|
<H2>COPYRIGHT</H2>
|
|
|
|
Copyright © 1992-1993, 1996-2016 Free Software Foundation, Inc.
|
|
This file is part of
|
|
<I>GNU make</I>.
|
|
|
|
<P>
|
|
|
|
GNU Make is free software; you can redistribute it and/or modify it under the
|
|
terms of the GNU General Public License as published by the Free Software
|
|
Foundation; either version 3 of the License, or (at your option) any later
|
|
version.
|
|
<P>
|
|
|
|
GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
<P>
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
this program. If not, see
|
|
<I><A HREF="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</A></I>.
|
|
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="33"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="34"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="35"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="36"><A HREF="#lbAE">OPTIONS</A><DD>
|
|
<DT id="37"><A HREF="#lbAF">EXIT STATUS</A><DD>
|
|
<DT id="38"><A HREF="#lbAG">SEE ALSO</A><DD>
|
|
<DT id="39"><A HREF="#lbAH">PARALLEL MAKE AND THE JOBSERVER</A><DD>
|
|
<DT id="40"><A HREF="#lbAI">BUGS</A><DD>
|
|
<DT id="41"><A HREF="#lbAJ">AUTHOR</A><DD>
|
|
<DT id="42"><A HREF="#lbAK">COPYRIGHT</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:18 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|