951 lines
32 KiB
HTML
951 lines
32 KiB
HTML
<HTML>
|
|
<HEAD>
|
|
<!-- This HTML file has been created by texi2html 1.54
|
|
from ../texi/make.texinfo on 19 July 2000 -->
|
|
|
|
<TITLE>GNU make - How to Run make</TITLE>
|
|
<link href="make_10.html" rel=Next>
|
|
<link href="make_8.html" rel=Previous>
|
|
<link href="make_toc.html" rel=ToC>
|
|
|
|
</HEAD>
|
|
<BODY>
|
|
<p>Go to the <A HREF="make_1.html">first</A>, <A HREF="make_8.html">previous</A>, <A HREF="make_10.html">next</A>, <A HREF="make_19.html">last</A> section, <A HREF="make_toc.html">table of contents</A>.
|
|
<P><HR><P>
|
|
|
|
|
|
<H1><A NAME="SEC85" HREF="make_toc.html#TOC85">How to Run <CODE>make</CODE></A></H1>
|
|
|
|
<P>
|
|
A makefile that says how to recompile a program can be used in more
|
|
than one way. The simplest use is to recompile every file that is out
|
|
of date. Usually, makefiles are written so that if you run
|
|
<CODE>make</CODE> with no arguments, it does just that.
|
|
|
|
</P>
|
|
<P>
|
|
But you might want to update only some of the files; you might want to use
|
|
a different compiler or different compiler options; you might want just to
|
|
find out which files are out of date without changing them.
|
|
|
|
</P>
|
|
<P>
|
|
By giving arguments when you run <CODE>make</CODE>, you can do any of these
|
|
things and many others.
|
|
|
|
</P>
|
|
<P>
|
|
The exit status of <CODE>make</CODE> is always one of three values:
|
|
<DL COMPACT>
|
|
|
|
<DT><CODE>0</CODE>
|
|
<DD>
|
|
The exit status is zero if <CODE>make</CODE> is successful.
|
|
<DT><CODE>2</CODE>
|
|
<DD>
|
|
The exit status is two if <CODE>make</CODE> encounters any errors.
|
|
It will print messages describing the particular errors.
|
|
<DT><CODE>1</CODE>
|
|
<DD>
|
|
The exit status is one if you use the <SAMP>`-q'</SAMP> flag and <CODE>make</CODE>
|
|
determines that some target is not already up to date.
|
|
See section <A HREF="make_9.html#SEC88">Instead of Executing the Commands</A>.
|
|
</DL>
|
|
|
|
|
|
|
|
<H2><A NAME="SEC86" HREF="make_toc.html#TOC86">Arguments to Specify the Makefile</A></H2>
|
|
<P>
|
|
<A NAME="IDX577"></A>
|
|
<A NAME="IDX578"></A>
|
|
<A NAME="IDX579"></A>
|
|
|
|
</P>
|
|
<P>
|
|
The way to specify the name of the makefile is with the <SAMP>`-f'</SAMP> or
|
|
<SAMP>`--file'</SAMP> option (<SAMP>`--makefile'</SAMP> also works). For example,
|
|
<SAMP>`-f altmake'</SAMP> says to use the file <TT>`altmake'</TT> as the makefile.
|
|
|
|
</P>
|
|
<P>
|
|
If you use the <SAMP>`-f'</SAMP> flag several times and follow each <SAMP>`-f'</SAMP>
|
|
with an argument, all the specified files are used jointly as
|
|
makefiles.
|
|
|
|
</P>
|
|
<P>
|
|
If you do not use the <SAMP>`-f'</SAMP> or <SAMP>`--file'</SAMP> flag, the default is
|
|
to try <TT>`GNUmakefile'</TT>, <TT>`makefile'</TT>, and <TT>`Makefile'</TT>, in
|
|
that order, and use the first of these three which exists or can be made
|
|
(see section <A HREF="make_3.html#SEC12">Writing Makefiles</A>).
|
|
</P>
|
|
|
|
|
|
<H2><A NAME="SEC87" HREF="make_toc.html#TOC87">Arguments to Specify the Goals</A></H2>
|
|
<P>
|
|
<A NAME="IDX580"></A>
|
|
|
|
</P>
|
|
<P>
|
|
The <STRONG>goals</STRONG> are the targets that <CODE>make</CODE> should strive ultimately
|
|
to update. Other targets are updated as well if they appear as
|
|
prerequisites of goals, or prerequisites of prerequisites of goals, etc.
|
|
|
|
</P>
|
|
<P>
|
|
By default, the goal is the first target in the makefile (not counting
|
|
targets that start with a period). Therefore, makefiles are usually
|
|
written so that the first target is for compiling the entire program or
|
|
programs they describe. If the first rule in the makefile has several
|
|
targets, only the first target in the rule becomes the default goal, not
|
|
the whole list.
|
|
|
|
</P>
|
|
<P>
|
|
You can specify a different goal or goals with arguments to <CODE>make</CODE>.
|
|
Use the name of the goal as an argument. If you specify several goals,
|
|
<CODE>make</CODE> processes each of them in turn, in the order you name them.
|
|
|
|
</P>
|
|
<P>
|
|
Any target in the makefile may be specified as a goal (unless it
|
|
starts with <SAMP>`-'</SAMP> or contains an <SAMP>`='</SAMP>, in which case it will be
|
|
parsed as a switch or variable definition, respectively). Even
|
|
targets not in the makefile may be specified, if <CODE>make</CODE> can find
|
|
implicit rules that say how to make them.
|
|
|
|
</P>
|
|
<P>
|
|
<A NAME="IDX581"></A>
|
|
<A NAME="IDX582"></A>
|
|
<CODE>Make</CODE> will set the special variable <CODE>MAKECMDGOALS</CODE> to the
|
|
list of goals you specified on the command line. If no goals were given
|
|
on the command line, this variable is empty. Note that this variable
|
|
should be used only in special circumstances.
|
|
|
|
</P>
|
|
<P>
|
|
An example of appropriate use is to avoid including <TT>`.d'</TT> files
|
|
during <CODE>clean</CODE> rules (see section <A HREF="make_4.html#SEC43">Generating Prerequisites Automatically</A>), so
|
|
<CODE>make</CODE> won't create them only to immediately remove them
|
|
again:
|
|
</P>
|
|
|
|
<PRE>
|
|
sources = foo.c bar.c
|
|
|
|
ifneq ($(MAKECMDGOALS),clean)
|
|
include $(sources:.c=.d)
|
|
endif
|
|
</PRE>
|
|
|
|
<P>
|
|
One use of specifying a goal is if you want to compile only a part of
|
|
the program, or only one of several programs. Specify as a goal each
|
|
file that you wish to remake. For example, consider a directory containing
|
|
several programs, with a makefile that starts like this:
|
|
|
|
</P>
|
|
|
|
<PRE>
|
|
.PHONY: all
|
|
all: size nm ld ar as
|
|
</PRE>
|
|
|
|
<P>
|
|
If you are working on the program <CODE>size</CODE>, you might want to say
|
|
<SAMP>`make size'</SAMP> so that only the files of that program are recompiled.
|
|
|
|
</P>
|
|
<P>
|
|
Another use of specifying a goal is to make files that are not normally
|
|
made. For example, there may be a file of debugging output, or a
|
|
version of the program that is compiled specially for testing, which has
|
|
a rule in the makefile but is not a prerequisite of the default goal.
|
|
|
|
</P>
|
|
<P>
|
|
Another use of specifying a goal is to run the commands associated with
|
|
a phony target (see section <A HREF="make_4.html#SEC33">Phony Targets</A>) or empty target (see section <A HREF="make_4.html#SEC35">Empty Target Files to Record Events</A>). Many makefiles contain
|
|
a phony target named <TT>`clean'</TT> which deletes everything except source
|
|
files. Naturally, this is done only if you request it explicitly with
|
|
<SAMP>`make clean'</SAMP>. Following is a list of typical phony and empty
|
|
target names. See section <A HREF="make_14.html#SEC121">Standard Targets for Users</A>, for a detailed list of all the
|
|
standard target names which GNU software packages use.
|
|
|
|
</P>
|
|
<DL COMPACT>
|
|
|
|
<DT><TT>`all'</TT>
|
|
<DD>
|
|
<A NAME="IDX583"></A>
|
|
Make all the top-level targets the makefile knows about.
|
|
|
|
<DT><TT>`clean'</TT>
|
|
<DD>
|
|
<A NAME="IDX584"></A>
|
|
Delete all files that are normally created by running <CODE>make</CODE>.
|
|
|
|
<DT><TT>`mostlyclean'</TT>
|
|
<DD>
|
|
<A NAME="IDX585"></A>
|
|
Like <SAMP>`clean'</SAMP>, but may refrain from deleting a few files that people
|
|
normally don't want to recompile. For example, the <SAMP>`mostlyclean'</SAMP>
|
|
target for GCC does not delete <TT>`libgcc.a'</TT>, because recompiling it
|
|
is rarely necessary and takes a lot of time.
|
|
|
|
<DT><TT>`distclean'</TT>
|
|
<DD>
|
|
<A NAME="IDX586"></A>
|
|
<DT><TT>`realclean'</TT>
|
|
<DD>
|
|
<A NAME="IDX587"></A>
|
|
<DT><TT>`clobber'</TT>
|
|
<DD>
|
|
<A NAME="IDX588"></A>
|
|
Any of these targets might be defined to delete <EM>more</EM> files than
|
|
<SAMP>`clean'</SAMP> does. For example, this would delete configuration files
|
|
or links that you would normally create as preparation for compilation,
|
|
even if the makefile itself cannot create these files.
|
|
|
|
<DT><TT>`install'</TT>
|
|
<DD>
|
|
<A NAME="IDX589"></A>
|
|
Copy the executable file into a directory that users typically search
|
|
for commands; copy any auxiliary files that the executable uses into
|
|
the directories where it will look for them.
|
|
|
|
<DT><TT>`print'</TT>
|
|
<DD>
|
|
<A NAME="IDX590"></A>
|
|
Print listings of the source files that have changed.
|
|
|
|
<DT><TT>`tar'</TT>
|
|
<DD>
|
|
<A NAME="IDX591"></A>
|
|
Create a tar file of the source files.
|
|
|
|
<DT><TT>`shar'</TT>
|
|
<DD>
|
|
<A NAME="IDX592"></A>
|
|
Create a shell archive (shar file) of the source files.
|
|
|
|
<DT><TT>`dist'</TT>
|
|
<DD>
|
|
<A NAME="IDX593"></A>
|
|
Create a distribution file of the source files. This might
|
|
be a tar file, or a shar file, or a compressed version of one of the
|
|
above, or even more than one of the above.
|
|
|
|
<DT><TT>`TAGS'</TT>
|
|
<DD>
|
|
<A NAME="IDX594"></A>
|
|
Update a tags table for this program.
|
|
|
|
<DT><TT>`check'</TT>
|
|
<DD>
|
|
<A NAME="IDX595"></A>
|
|
<DT><TT>`test'</TT>
|
|
<DD>
|
|
<A NAME="IDX596"></A>
|
|
Perform self tests on the program this makefile builds.
|
|
</DL>
|
|
|
|
|
|
|
|
<H2><A NAME="SEC88" HREF="make_toc.html#TOC88">Instead of Executing the Commands</A></H2>
|
|
<P>
|
|
<A NAME="IDX597"></A>
|
|
<A NAME="IDX598"></A>
|
|
|
|
</P>
|
|
<P>
|
|
The makefile tells <CODE>make</CODE> how to tell whether a target is up to date,
|
|
and how to update each target. But updating the targets is not always
|
|
what you want. Certain options specify other activities for <CODE>make</CODE>.
|
|
|
|
</P>
|
|
<DL COMPACT>
|
|
|
|
<DT><SAMP>`-n'</SAMP>
|
|
<DD>
|
|
<DT><SAMP>`--just-print'</SAMP>
|
|
<DD>
|
|
<DT><SAMP>`--dry-run'</SAMP>
|
|
<DD>
|
|
<DT><SAMP>`--recon'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX599"></A>
|
|
<A NAME="IDX600"></A>
|
|
<A NAME="IDX601"></A>
|
|
<A NAME="IDX602"></A>
|
|
|
|
"No-op". The activity is to print what commands would be used to make
|
|
the targets up to date, but not actually execute them.
|
|
|
|
<DT><SAMP>`-t'</SAMP>
|
|
<DD>
|
|
<DT><SAMP>`--touch'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX603"></A>
|
|
<A NAME="IDX604"></A>
|
|
<A NAME="IDX605"></A>
|
|
<A NAME="IDX606"></A>
|
|
|
|
"Touch". The activity is to mark the targets as up to date without
|
|
actually changing them. In other words, <CODE>make</CODE> pretends to compile
|
|
the targets but does not really change their contents.
|
|
|
|
<DT><SAMP>`-q'</SAMP>
|
|
<DD>
|
|
<DT><SAMP>`--question'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX607"></A>
|
|
<A NAME="IDX608"></A>
|
|
<A NAME="IDX609"></A>
|
|
|
|
"Question". The activity is to find out silently whether the targets
|
|
are up to date already; but execute no commands in either case. In other
|
|
words, neither compilation nor output will occur.
|
|
|
|
<DT><SAMP>`-W <VAR>file</VAR>'</SAMP>
|
|
<DD>
|
|
<DT><SAMP>`--what-if=<VAR>file</VAR>'</SAMP>
|
|
<DD>
|
|
<DT><SAMP>`--assume-new=<VAR>file</VAR>'</SAMP>
|
|
<DD>
|
|
<DT><SAMP>`--new-file=<VAR>file</VAR>'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX610"></A>
|
|
<A NAME="IDX611"></A>
|
|
<A NAME="IDX612"></A>
|
|
<A NAME="IDX613"></A>
|
|
<A NAME="IDX614"></A>
|
|
<A NAME="IDX615"></A>
|
|
|
|
"What if". Each <SAMP>`-W'</SAMP> flag is followed by a file name. The given
|
|
files' modification times are recorded by <CODE>make</CODE> as being the present
|
|
time, although the actual modification times remain the same.
|
|
You can use the <SAMP>`-W'</SAMP> flag in conjunction with the <SAMP>`-n'</SAMP> flag
|
|
to see what would happen if you were to modify specific files.</DL>
|
|
|
|
<P>
|
|
With the <SAMP>`-n'</SAMP> flag, <CODE>make</CODE> prints the commands that it would
|
|
normally execute but does not execute them.
|
|
|
|
</P>
|
|
<P>
|
|
With the <SAMP>`-t'</SAMP> flag, <CODE>make</CODE> ignores the commands in the rules
|
|
and uses (in effect) the command <CODE>touch</CODE> for each target that needs to
|
|
be remade. The <CODE>touch</CODE> command is also printed, unless <SAMP>`-s'</SAMP> or
|
|
<CODE>.SILENT</CODE> is used. For speed, <CODE>make</CODE> does not actually invoke
|
|
the program <CODE>touch</CODE>. It does the work directly.
|
|
|
|
</P>
|
|
<P>
|
|
With the <SAMP>`-q'</SAMP> flag, <CODE>make</CODE> prints nothing and executes no
|
|
commands, but the exit status code it returns is zero if and only if the
|
|
targets to be considered are already up to date. If the exit status is
|
|
one, then some updating needs to be done. If <CODE>make</CODE> encounters an
|
|
error, the exit status is two, so you can distinguish an error from a
|
|
target that is not up to date.
|
|
|
|
</P>
|
|
<P>
|
|
It is an error to use more than one of these three flags in the same
|
|
invocation of <CODE>make</CODE>.
|
|
|
|
</P>
|
|
<P>
|
|
The <SAMP>`-n'</SAMP>, <SAMP>`-t'</SAMP>, and <SAMP>`-q'</SAMP> options do not affect command
|
|
lines that begin with <SAMP>`+'</SAMP> characters or contain the strings
|
|
<SAMP>`$(MAKE)'</SAMP> or <SAMP>`${MAKE}'</SAMP>. Note that only the line containing
|
|
the <SAMP>`+'</SAMP> character or the strings <SAMP>`$(MAKE)'</SAMP> or <SAMP>`${MAKE}'</SAMP>
|
|
is run regardless of these options. Other lines in the same rule are
|
|
not run unless they too begin with <SAMP>`+'</SAMP> or contain <SAMP>`$(MAKE)'</SAMP> or
|
|
<SAMP>`${MAKE}'</SAMP> (See section <A HREF="make_5.html#SEC51">How the <CODE>MAKE</CODE> Variable Works</A>.)
|
|
|
|
</P>
|
|
<P>
|
|
The <SAMP>`-W'</SAMP> flag provides two features:
|
|
|
|
</P>
|
|
|
|
<UL>
|
|
<LI>
|
|
|
|
If you also use the <SAMP>`-n'</SAMP> or <SAMP>`-q'</SAMP> flag, you can see what
|
|
<CODE>make</CODE> would do if you were to modify some files.
|
|
|
|
<LI>
|
|
|
|
Without the <SAMP>`-n'</SAMP> or <SAMP>`-q'</SAMP> flag, when <CODE>make</CODE> is actually
|
|
executing commands, the <SAMP>`-W'</SAMP> flag can direct <CODE>make</CODE> to act
|
|
as if some files had been modified, without actually modifying the
|
|
files.</UL>
|
|
|
|
<P>
|
|
Note that the options <SAMP>`-p'</SAMP> and <SAMP>`-v'</SAMP> allow you to obtain other
|
|
information about <CODE>make</CODE> or about the makefiles in use
|
|
(see section <A HREF="make_9.html#SEC92">Summary of Options</A>).
|
|
</P>
|
|
|
|
|
|
<H2><A NAME="SEC89" HREF="make_toc.html#TOC89">Avoiding Recompilation of Some Files</A></H2>
|
|
<P>
|
|
<A NAME="IDX616"></A>
|
|
<A NAME="IDX617"></A>
|
|
<A NAME="IDX618"></A>
|
|
<A NAME="IDX619"></A>
|
|
<A NAME="IDX620"></A>
|
|
<A NAME="IDX621"></A>
|
|
|
|
</P>
|
|
<P>
|
|
Sometimes you may have changed a source file but you do not want to
|
|
recompile all the files that depend on it. For example, suppose you add
|
|
a macro or a declaration to a header file that many other files depend
|
|
on. Being conservative, <CODE>make</CODE> assumes that any change in the
|
|
header file requires recompilation of all dependent files, but you know
|
|
that they do not need to be recompiled and you would rather not waste
|
|
the time waiting for them to compile.
|
|
|
|
</P>
|
|
<P>
|
|
If you anticipate the problem before changing the header file, you can
|
|
use the <SAMP>`-t'</SAMP> flag. This flag tells <CODE>make</CODE> not to run the
|
|
commands in the rules, but rather to mark the target up to date by
|
|
changing its last-modification date. You would follow this procedure:
|
|
|
|
</P>
|
|
|
|
<OL>
|
|
<LI>
|
|
|
|
Use the command <SAMP>`make'</SAMP> to recompile the source files that really
|
|
need recompilation.
|
|
|
|
<LI>
|
|
|
|
Make the changes in the header files.
|
|
|
|
<LI>
|
|
|
|
Use the command <SAMP>`make -t'</SAMP> to mark all the object files as
|
|
up to date. The next time you run <CODE>make</CODE>, the changes in the
|
|
header files will not cause any recompilation.
|
|
</OL>
|
|
|
|
<P>
|
|
If you have already changed the header file at a time when some files
|
|
do need recompilation, it is too late to do this. Instead, you can
|
|
use the <SAMP>`-o <VAR>file</VAR>'</SAMP> flag, which marks a specified file as
|
|
"old" (see section <A HREF="make_9.html#SEC92">Summary of Options</A>). This means
|
|
that the file itself will not be remade, and nothing else will be
|
|
remade on its account. Follow this procedure:
|
|
|
|
</P>
|
|
|
|
<OL>
|
|
<LI>
|
|
|
|
Recompile the source files that need compilation for reasons independent
|
|
of the particular header file, with <SAMP>`make -o <VAR>headerfile</VAR>'</SAMP>.
|
|
If several header files are involved, use a separate <SAMP>`-o'</SAMP> option
|
|
for each header file.
|
|
|
|
<LI>
|
|
|
|
Touch all the object files with <SAMP>`make -t'</SAMP>.
|
|
</OL>
|
|
|
|
|
|
|
|
<H2><A NAME="SEC90" HREF="make_toc.html#TOC90">Overriding Variables</A></H2>
|
|
<P>
|
|
<A NAME="IDX622"></A>
|
|
<A NAME="IDX623"></A>
|
|
<A NAME="IDX624"></A>
|
|
<A NAME="IDX625"></A>
|
|
|
|
</P>
|
|
<P>
|
|
An argument that contains <SAMP>`='</SAMP> specifies the value of a variable:
|
|
<SAMP>`<VAR>v</VAR>=<VAR>x</VAR>'</SAMP> sets the value of the variable <VAR>v</VAR> to <VAR>x</VAR>.
|
|
If you specify a value in this way, all ordinary assignments of the same
|
|
variable in the makefile are ignored; we say they have been
|
|
<STRONG>overridden</STRONG> by the command line argument.
|
|
|
|
</P>
|
|
<P>
|
|
The most common way to use this facility is to pass extra flags to
|
|
compilers. For example, in a properly written makefile, the variable
|
|
<CODE>CFLAGS</CODE> is included in each command that runs the C compiler, so a
|
|
file <TT>`foo.c'</TT> would be compiled something like this:
|
|
|
|
</P>
|
|
|
|
<PRE>
|
|
cc -c $(CFLAGS) foo.c
|
|
</PRE>
|
|
|
|
<P>
|
|
Thus, whatever value you set for <CODE>CFLAGS</CODE> affects each compilation
|
|
that occurs. The makefile probably specifies the usual value for
|
|
<CODE>CFLAGS</CODE>, like this:
|
|
|
|
</P>
|
|
|
|
<PRE>
|
|
CFLAGS=-g
|
|
</PRE>
|
|
|
|
<P>
|
|
Each time you run <CODE>make</CODE>, you can override this value if you
|
|
wish. For example, if you say <SAMP>`make CFLAGS='-g -O''</SAMP>, each C
|
|
compilation will be done with <SAMP>`cc -c -g -O'</SAMP>. (This illustrates
|
|
how you can use quoting in the shell to enclose spaces and other
|
|
special characters in the value of a variable when you override it.)
|
|
|
|
</P>
|
|
<P>
|
|
The variable <CODE>CFLAGS</CODE> is only one of many standard variables that
|
|
exist just so that you can change them this way. See section <A HREF="make_10.html#SEC96">Variables Used by Implicit Rules</A>, for a complete list.
|
|
|
|
</P>
|
|
<P>
|
|
You can also program the makefile to look at additional variables of your
|
|
own, giving the user the ability to control other aspects of how the
|
|
makefile works by changing the variables.
|
|
|
|
</P>
|
|
<P>
|
|
When you override a variable with a command argument, you can define either
|
|
a recursively-expanded variable or a simply-expanded variable. The
|
|
examples shown above make a recursively-expanded variable; to make a
|
|
simply-expanded variable, write <SAMP>`:='</SAMP> instead of <SAMP>`='</SAMP>. But, unless
|
|
you want to include a variable reference or function call in the
|
|
<EM>value</EM> that you specify, it makes no difference which kind of
|
|
variable you create.
|
|
|
|
</P>
|
|
<P>
|
|
There is one way that the makefile can change a variable that you have
|
|
overridden. This is to use the <CODE>override</CODE> directive, which is a line
|
|
that looks like this: <SAMP>`override <VAR>variable</VAR> = <VAR>value</VAR>'</SAMP>
|
|
(see section <A HREF="make_6.html#SEC66">The <CODE>override</CODE> Directive</A>).
|
|
|
|
</P>
|
|
|
|
|
|
<H2><A NAME="SEC91" HREF="make_toc.html#TOC91">Testing the Compilation of a Program</A></H2>
|
|
<P>
|
|
<A NAME="IDX626"></A>
|
|
<A NAME="IDX627"></A>
|
|
|
|
</P>
|
|
<P>
|
|
Normally, when an error happens in executing a shell command, <CODE>make</CODE>
|
|
gives up immediately, returning a nonzero status. No further commands are
|
|
executed for any target. The error implies that the goal cannot be
|
|
correctly remade, and <CODE>make</CODE> reports this as soon as it knows.
|
|
|
|
</P>
|
|
<P>
|
|
When you are compiling a program that you have just changed, this is not
|
|
what you want. Instead, you would rather that <CODE>make</CODE> try compiling
|
|
every file that can be tried, to show you as many compilation errors
|
|
as possible.
|
|
|
|
</P>
|
|
<P>
|
|
<A NAME="IDX628"></A>
|
|
<A NAME="IDX629"></A>
|
|
On these occasions, you should use the <SAMP>`-k'</SAMP> or
|
|
<SAMP>`--keep-going'</SAMP> flag. This tells <CODE>make</CODE> to continue to
|
|
consider the other prerequisites 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, <SAMP>`make -k'</SAMP>
|
|
will continue compiling other object files even though it already
|
|
knows that linking them will be impossible. In addition to continuing
|
|
after failed shell commands, <SAMP>`make -k'</SAMP> will continue as much as
|
|
possible after discovering that it does not know how to make a target
|
|
or prerequisite file. This will always cause an error message, but
|
|
without <SAMP>`-k'</SAMP>, it is a fatal error (see section <A HREF="make_9.html#SEC92">Summary of Options</A>).
|
|
</P>
|
|
<P>
|
|
The usual behavior of <CODE>make</CODE> assumes that your purpose is to get the
|
|
goals up to date; once <CODE>make</CODE> learns that this is impossible, it might
|
|
as well report the failure immediately. The <SAMP>`-k'</SAMP> flag says that the
|
|
real purpose is to test as much as possible of the changes made in the
|
|
program, perhaps to find several independent problems so that you can
|
|
correct them all before the next attempt to compile. This is why Emacs'
|
|
<KBD>M-x compile</KBD> command passes the <SAMP>`-k'</SAMP> flag by default.
|
|
|
|
</P>
|
|
|
|
|
|
<H2><A NAME="SEC92" HREF="make_toc.html#TOC92">Summary of Options</A></H2>
|
|
<P>
|
|
<A NAME="IDX630"></A>
|
|
<A NAME="IDX631"></A>
|
|
<A NAME="IDX632"></A>
|
|
|
|
</P>
|
|
<P>
|
|
Here is a table of all the options <CODE>make</CODE> understands:
|
|
|
|
</P>
|
|
<DL COMPACT>
|
|
|
|
<DT><SAMP>`-b'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX633"></A>
|
|
<DT><SAMP>`-m'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX634"></A>
|
|
These options are ignored for compatibility with other versions of <CODE>make</CODE>.
|
|
|
|
<DT><SAMP>`-C <VAR>dir</VAR>'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX635"></A>
|
|
<DT><SAMP>`--directory=<VAR>dir</VAR>'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX636"></A>
|
|
Change to directory <VAR>dir</VAR> before reading the makefiles. If multiple
|
|
<SAMP>`-C'</SAMP> options are specified, each is interpreted relative to the
|
|
previous one: <SAMP>`-C / -C etc'</SAMP> is equivalent to <SAMP>`-C /etc'</SAMP>.
|
|
This is typically used with recursive invocations of <CODE>make</CODE>
|
|
(see section <A HREF="make_5.html#SEC50">Recursive Use of <CODE>make</CODE></A>).
|
|
|
|
<DT><SAMP>`-d'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX637"></A>
|
|
|
|
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
|
|
<CODE>make</CODE> decides what to do. The <CODE>-d</CODE> option is equivalent to
|
|
<SAMP>`--debug=a'</SAMP> (see below).
|
|
|
|
<DT><SAMP>`--debug[=<VAR>options</VAR>]'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX638"></A>
|
|
|
|
Print debugging information in addition to normal processing. Various
|
|
levels and types of output can be chosen. With no arguments, print the
|
|
"basic" level of debugging. Possible arguments are below; only the
|
|
first character is considered, and values must be comma- or
|
|
space-separated.
|
|
|
|
<DL COMPACT>
|
|
|
|
<DT><CODE>a (<I>all</I>)</CODE>
|
|
<DD>
|
|
All types of debugging output are enabled. This is equivalent to using
|
|
<SAMP>`-d'</SAMP>.
|
|
|
|
<DT><CODE>b (<I>basic</I>)</CODE>
|
|
<DD>
|
|
Basic debugging prints each target that was found to be out-of-date, and
|
|
whether the build was successful or not.
|
|
|
|
<DT><CODE>v (<I>verbose</I>)</CODE>
|
|
<DD>
|
|
A level above <SAMP>`basic'</SAMP>; includes messages about which makefiles were
|
|
parsed, prerequisites that did not need to be rebuilt, etc. This option
|
|
also enables <SAMP>`basic'</SAMP> messages.
|
|
|
|
<DT><CODE>i (<I>implicit</I>)</CODE>
|
|
<DD>
|
|
Prints messages describing the implicit rule searches for each target.
|
|
This option also enables <SAMP>`basic'</SAMP> messages.
|
|
|
|
<DT><CODE>j (<I>jobs</I>)</CODE>
|
|
<DD>
|
|
Prints messages giving details on the invocation of specific subcommands.
|
|
|
|
<DT><CODE>m (<I>makefile</I>)</CODE>
|
|
<DD>
|
|
By default, the above messages are not enabled while trying to remake
|
|
the makefiles. This option enables messages while rebuilding makefiles,
|
|
too. Note that the <SAMP>`all'</SAMP> option does enable this option. This
|
|
option also enables <SAMP>`basic'</SAMP> messages.
|
|
</DL>
|
|
|
|
<DT><SAMP>`-e'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX639"></A>
|
|
<DT><SAMP>`--environment-overrides'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX640"></A>
|
|
Give variables taken from the environment precedence
|
|
over variables from makefiles.
|
|
See section <A HREF="make_6.html#SEC68">Variables from the Environment</A>.
|
|
|
|
<DT><SAMP>`-f <VAR>file</VAR>'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX641"></A>
|
|
<DT><SAMP>`--file=<VAR>file</VAR>'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX642"></A>
|
|
<DT><SAMP>`--makefile=<VAR>file</VAR>'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX643"></A>
|
|
Read the file named <VAR>file</VAR> as a makefile.
|
|
See section <A HREF="make_3.html#SEC12">Writing Makefiles</A>.
|
|
|
|
<DT><SAMP>`-h'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX644"></A>
|
|
<DT><SAMP>`--help'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX645"></A>
|
|
|
|
Remind you of the options that <CODE>make</CODE> understands and then exit.
|
|
|
|
<DT><SAMP>`-i'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX646"></A>
|
|
<DT><SAMP>`--ignore-errors'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX647"></A>
|
|
Ignore all errors in commands executed to remake files.
|
|
See section <A HREF="make_5.html#SEC48">Errors in Commands</A>.
|
|
|
|
<DT><SAMP>`-I <VAR>dir</VAR>'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX648"></A>
|
|
<DT><SAMP>`--include-dir=<VAR>dir</VAR>'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX649"></A>
|
|
Specifies a directory <VAR>dir</VAR> to search for included makefiles.
|
|
See section <A HREF="make_3.html#SEC15">Including Other Makefiles</A>. If several <SAMP>`-I'</SAMP>
|
|
options are used to specify several directories, the directories are
|
|
searched in the order specified.
|
|
|
|
<DT><SAMP>`-j [<VAR>jobs</VAR>]'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX650"></A>
|
|
<DT><SAMP>`--jobs[=<VAR>jobs</VAR>]'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX651"></A>
|
|
Specifies the number of jobs (commands) to run simultaneously. With no
|
|
argument, <CODE>make</CODE> runs as many jobs simultaneously as possible. If
|
|
there is more than one <SAMP>`-j'</SAMP> option, the last one is effective.
|
|
See section <A HREF="make_5.html#SEC47">Parallel Execution</A>,
|
|
for more information on how commands are run.
|
|
Note that this option is ignored on MS-DOS.
|
|
|
|
<DT><SAMP>`-k'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX652"></A>
|
|
<DT><SAMP>`--keep-going'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX653"></A>
|
|
Continue as much as possible after an error. While the target that
|
|
failed, and those that depend on it, cannot be remade, the other
|
|
prerequisites of these targets can be processed all the same.
|
|
See section <A HREF="make_9.html#SEC91">Testing the Compilation of a Program</A>.
|
|
|
|
<DT><SAMP>`-l [<VAR>load</VAR>]'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX654"></A>
|
|
<DT><SAMP>`--load-average[=<VAR>load</VAR>]'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX655"></A>
|
|
<DT><SAMP>`--max-load[=<VAR>load</VAR>]'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX656"></A>
|
|
Specifies that no new jobs (commands) should be started if there are
|
|
other jobs running and the load average is at least <VAR>load</VAR> (a
|
|
floating-point number). With no argument, removes a previous load
|
|
limit. See section <A HREF="make_5.html#SEC47">Parallel Execution</A>.
|
|
|
|
<DT><SAMP>`-n'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX657"></A>
|
|
<DT><SAMP>`--just-print'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX658"></A>
|
|
<DT><SAMP>`--dry-run'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX659"></A>
|
|
<DT><SAMP>`--recon'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX660"></A>
|
|
|
|
Print the commands that would be executed, but do not execute them.
|
|
See section <A HREF="make_9.html#SEC88">Instead of Executing the Commands</A>.
|
|
|
|
<DT><SAMP>`-o <VAR>file</VAR>'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX661"></A>
|
|
<DT><SAMP>`--old-file=<VAR>file</VAR>'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX662"></A>
|
|
<DT><SAMP>`--assume-old=<VAR>file</VAR>'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX663"></A>
|
|
Do not remake the file <VAR>file</VAR> even if it is older than its
|
|
prerequisites, and do not remake anything on account of changes in
|
|
<VAR>file</VAR>. Essentially the file is treated as very old and its rules
|
|
are ignored. See section <A HREF="make_9.html#SEC89">Avoiding Recompilation of Some Files</A>.
|
|
<DT><SAMP>`-p'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX664"></A>
|
|
<DT><SAMP>`--print-data-base'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX665"></A>
|
|
<A NAME="IDX666"></A>
|
|
<A NAME="IDX667"></A>
|
|
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 <SAMP>`-v'</SAMP> switch
|
|
(see below). To print the data base without trying to remake any files,
|
|
use <SAMP>`make -qp'</SAMP>. To print the data base of predefined rules and
|
|
variables, use <SAMP>`make -p -f /dev/null'</SAMP>. The data base output
|
|
contains filename and linenumber information for command and variable
|
|
definitions, so it can be a useful debugging tool in complex environments.
|
|
|
|
<DT><SAMP>`-q'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX668"></A>
|
|
<DT><SAMP>`--question'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX669"></A>
|
|
"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, one if any remaking is required, or two if an error is
|
|
encountered. See section <A HREF="make_9.html#SEC88">Instead of Executing the Commands</A>.
|
|
<DT><SAMP>`-r'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX670"></A>
|
|
<DT><SAMP>`--no-builtin-rules'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX671"></A>
|
|
Eliminate use of the built-in implicit rules (see section <A HREF="make_10.html#SEC93">Using Implicit Rules</A>). You can still define your own by writing
|
|
pattern rules (see section <A HREF="make_10.html#SEC98">Defining and Redefining Pattern Rules</A>). The <SAMP>`-r'</SAMP> option also clears out the default list of
|
|
suffixes for suffix rules (see section <A HREF="make_10.html#SEC106">Old-Fashioned Suffix Rules</A>). But you can still define your own suffixes with a rule for
|
|
<CODE>.SUFFIXES</CODE>, and then define your own suffix rules. Note that only
|
|
<EM>rules</EM> are affected by the <CODE>-r</CODE> option; default variables
|
|
remain in effect (see section <A HREF="make_10.html#SEC96">Variables Used by Implicit Rules</A>); see the <SAMP>`-R'</SAMP> option below.
|
|
|
|
<DT><SAMP>`-R'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX672"></A>
|
|
<DT><SAMP>`--no-builtin-variables'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX673"></A>
|
|
Eliminate use of the built-in rule-specific variables (see section <A HREF="make_10.html#SEC96">Variables Used by Implicit Rules</A>). You can still define
|
|
your own, of course. The <SAMP>`-R'</SAMP> option also automatically enables
|
|
the <SAMP>`-r'</SAMP> option (see above), since it doesn't make sense to have
|
|
implicit rules without any definitions for the variables that they use.
|
|
|
|
<DT><SAMP>`-s'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX674"></A>
|
|
<DT><SAMP>`--silent'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX675"></A>
|
|
<DT><SAMP>`--quiet'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX676"></A>
|
|
|
|
Silent operation; do not print the commands as they are executed.
|
|
See section <A HREF="make_5.html#SEC45">Command Echoing</A>.
|
|
|
|
<DT><SAMP>`-S'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX677"></A>
|
|
<DT><SAMP>`--no-keep-going'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX678"></A>
|
|
<DT><SAMP>`--stop'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX679"></A>
|
|
|
|
Cancel the effect of the <SAMP>`-k'</SAMP> option. This is never necessary
|
|
except in a recursive <CODE>make</CODE> where <SAMP>`-k'</SAMP> might be inherited
|
|
from the top-level <CODE>make</CODE> via <CODE>MAKEFLAGS</CODE>
|
|
(see section <A HREF="make_5.html#SEC50">Recursive Use of <CODE>make</CODE></A>)
|
|
or if you set <SAMP>`-k'</SAMP> in <CODE>MAKEFLAGS</CODE> in your environment.
|
|
<DT><SAMP>`-t'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX680"></A>
|
|
<DT><SAMP>`--touch'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX681"></A>
|
|
|
|
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
|
|
<CODE>make</CODE>. See section <A HREF="make_9.html#SEC88">Instead of Executing the Commands</A>.
|
|
|
|
<DT><SAMP>`-v'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX682"></A>
|
|
<DT><SAMP>`--version'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX683"></A>
|
|
Print the version of the <CODE>make</CODE> program plus a copyright, a list
|
|
of authors, and a notice that there is no warranty; then exit.
|
|
|
|
<DT><SAMP>`-w'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX684"></A>
|
|
<DT><SAMP>`--print-directory'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX685"></A>
|
|
Print a message containing the working directory both before and after
|
|
executing the makefile. This may be useful for tracking down errors
|
|
from complicated nests of recursive <CODE>make</CODE> commands.
|
|
See section <A HREF="make_5.html#SEC50">Recursive Use of <CODE>make</CODE></A>. (In practice, you
|
|
rarely need to specify this option since <SAMP>`make'</SAMP> does it for you;
|
|
see section <A HREF="make_5.html#SEC54">The <SAMP>`--print-directory'</SAMP> Option</A>.)
|
|
|
|
<DT><SAMP>`--no-print-directory'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX686"></A>
|
|
Disable printing of the working directory under <CODE>-w</CODE>.
|
|
This option is useful when <CODE>-w</CODE> is turned on automatically,
|
|
but you do not want to see the extra messages.
|
|
See section <A HREF="make_5.html#SEC54">The <SAMP>`--print-directory'</SAMP> Option</A>.
|
|
|
|
<DT><SAMP>`-W <VAR>file</VAR>'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX687"></A>
|
|
<DT><SAMP>`--what-if=<VAR>file</VAR>'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX688"></A>
|
|
<DT><SAMP>`--new-file=<VAR>file</VAR>'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX689"></A>
|
|
<DT><SAMP>`--assume-new=<VAR>file</VAR>'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX690"></A>
|
|
Pretend that the target <VAR>file</VAR> has just been modified. When used
|
|
with the <SAMP>`-n'</SAMP> flag, this shows you what would happen if you were
|
|
to modify that file. Without <SAMP>`-n'</SAMP>, it is almost the same as
|
|
running a <CODE>touch</CODE> command on the given file before running
|
|
<CODE>make</CODE>, except that the modification time is changed only in the
|
|
imagination of <CODE>make</CODE>.
|
|
See section <A HREF="make_9.html#SEC88">Instead of Executing the Commands</A>.
|
|
|
|
<DT><SAMP>`--warn-undefined-variables'</SAMP>
|
|
<DD>
|
|
<A NAME="IDX691"></A>
|
|
<A NAME="IDX692"></A>
|
|
<A NAME="IDX693"></A>
|
|
Issue a warning message whenever <CODE>make</CODE> sees a reference to an
|
|
undefined variable. This can be helpful when you are trying to debug
|
|
makefiles which use variables in complex ways.
|
|
</DL>
|
|
|
|
<P><HR><P>
|
|
<p>Go to the <A HREF="make_1.html">first</A>, <A HREF="make_8.html">previous</A>, <A HREF="make_10.html">next</A>, <A HREF="make_19.html">last</A> section, <A HREF="make_toc.html">table of contents</A>.
|
|
</BODY>
|
|
</HTML>
|