319 lines
11 KiB
HTML
319 lines
11 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 - Features of GNU make</TITLE>
|
|
<link href="make_13.html" rel=Next>
|
|
<link href="make_11.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_11.html">previous</A>, <A HREF="make_13.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="SEC114" HREF="make_toc.html#TOC114">Features of GNU <CODE>make</CODE></A></H1>
|
|
<P>
|
|
<A NAME="IDX911"></A>
|
|
<A NAME="IDX912"></A>
|
|
<A NAME="IDX913"></A>
|
|
|
|
</P>
|
|
<P>
|
|
Here is a summary of the features of GNU <CODE>make</CODE>, for comparison
|
|
with and credit to other versions of <CODE>make</CODE>. We consider the
|
|
features of <CODE>make</CODE> in 4.2 BSD systems as a baseline. If you are
|
|
concerned with writing portable makefiles, you should not use the
|
|
features of <CODE>make</CODE> listed here, nor the ones in section <A HREF="make_13.html#SEC115">Incompatibilities and Missing Features</A>.
|
|
|
|
</P>
|
|
<P>
|
|
Many features come from the version of <CODE>make</CODE> in System V.
|
|
|
|
</P>
|
|
|
|
<UL>
|
|
<LI>
|
|
|
|
The <CODE>VPATH</CODE> variable and its special meaning.
|
|
See section <A HREF="make_4.html#SEC26">Searching Directories for Prerequisites</A>.
|
|
This feature exists in System V <CODE>make</CODE>, but is undocumented.
|
|
It is documented in 4.3 BSD <CODE>make</CODE> (which says it mimics System V's
|
|
<CODE>VPATH</CODE> feature).
|
|
<LI>
|
|
|
|
Included makefiles. See section <A HREF="make_3.html#SEC15">Including Other Makefiles</A>.
|
|
Allowing multiple files to be included with a single directive is a GNU
|
|
extension.
|
|
|
|
<LI>
|
|
|
|
Variables are read from and communicated via the environment.
|
|
See section <A HREF="make_6.html#SEC68">Variables from the Environment</A>.
|
|
|
|
<LI>
|
|
|
|
Options passed through the variable <CODE>MAKEFLAGS</CODE> to recursive
|
|
invocations of <CODE>make</CODE>.
|
|
See section <A HREF="make_5.html#SEC53">Communicating Options to a Sub-<CODE>make</CODE></A>.
|
|
|
|
<LI>
|
|
|
|
The automatic variable <CODE>$%</CODE> is set to the member name
|
|
in an archive reference. See section <A HREF="make_10.html#SEC101">Automatic Variables</A>.
|
|
|
|
<LI>
|
|
|
|
The automatic variables <CODE>$@</CODE>, <CODE>$*</CODE>, <CODE>$<</CODE>, <CODE>$%</CODE>,
|
|
and <CODE>$?</CODE> have corresponding forms like <CODE>$(@F)</CODE> and
|
|
<CODE>$(@D)</CODE>. We have generalized this to <CODE>$^</CODE> as an obvious
|
|
extension. See section <A HREF="make_10.html#SEC101">Automatic Variables</A>.
|
|
<LI>
|
|
|
|
Substitution variable references.
|
|
See section <A HREF="make_6.html#SEC58">Basics of Variable References</A>.
|
|
|
|
<LI>
|
|
|
|
The command-line options <SAMP>`-b'</SAMP> and <SAMP>`-m'</SAMP>, accepted and
|
|
ignored. In System V <CODE>make</CODE>, these options actually do something.
|
|
|
|
<LI>
|
|
|
|
Execution of recursive commands to run <CODE>make</CODE> via the variable
|
|
<CODE>MAKE</CODE> even if <SAMP>`-n'</SAMP>, <SAMP>`-q'</SAMP> or <SAMP>`-t'</SAMP> is specified.
|
|
See section <A HREF="make_5.html#SEC50">Recursive Use of <CODE>make</CODE></A>.
|
|
|
|
<LI>
|
|
|
|
Support for suffix <SAMP>`.a'</SAMP> in suffix rules. See section <A HREF="make_11.html#SEC113">Suffix Rules for Archive Files</A>. This feature is obsolete in GNU <CODE>make</CODE>, because the
|
|
general feature of rule chaining (see section <A HREF="make_10.html#SEC97">Chains of Implicit Rules</A>) allows one pattern rule for installing members in an
|
|
archive (see section <A HREF="make_11.html#SEC110">Implicit Rule for Archive Member Targets</A>) to be sufficient.
|
|
|
|
<LI>
|
|
|
|
The arrangement of lines and backslash-newline combinations in
|
|
commands is retained when the commands are printed, so they appear as
|
|
they do in the makefile, except for the stripping of initial
|
|
whitespace.
|
|
</UL>
|
|
|
|
<P>
|
|
The following features were inspired by various other versions of
|
|
<CODE>make</CODE>. In some cases it is unclear exactly which versions inspired
|
|
which others.
|
|
|
|
</P>
|
|
|
|
<UL>
|
|
<LI>
|
|
|
|
Pattern rules using <SAMP>`%'</SAMP>.
|
|
This has been implemented in several versions of <CODE>make</CODE>.
|
|
We're not sure who invented it first, but it's been spread around a bit.
|
|
See section <A HREF="make_10.html#SEC98">Defining and Redefining Pattern Rules</A>.
|
|
<LI>
|
|
|
|
Rule chaining and implicit intermediate files.
|
|
This was implemented by Stu Feldman in his version of <CODE>make</CODE>
|
|
for AT&T Eighth Edition Research Unix, and later by Andrew Hume of
|
|
AT&T Bell Labs in his <CODE>mk</CODE> program (where he terms it
|
|
"transitive closure"). We do not really know if
|
|
we got this from either of them or thought it up ourselves at the
|
|
same time. See section <A HREF="make_10.html#SEC97">Chains of Implicit Rules</A>.
|
|
|
|
<LI>
|
|
|
|
The automatic variable <CODE>$^</CODE> containing a list of all prerequisites
|
|
of the current target. We did not invent this, but we have no idea who
|
|
did. See section <A HREF="make_10.html#SEC101">Automatic Variables</A>. The automatic variable
|
|
<CODE>$+</CODE> is a simple extension of <CODE>$^</CODE>.
|
|
|
|
<LI>
|
|
|
|
The "what if" flag (<SAMP>`-W'</SAMP> in GNU <CODE>make</CODE>) was (as far as we know)
|
|
invented by Andrew Hume in <CODE>mk</CODE>.
|
|
See section <A HREF="make_9.html#SEC88">Instead of Executing the Commands</A>.
|
|
|
|
<LI>
|
|
|
|
The concept of doing several things at once (parallelism) exists in
|
|
many incarnations of <CODE>make</CODE> and similar programs, though not in the
|
|
System V or BSD implementations. See section <A HREF="make_5.html#SEC46">Command Execution</A>.
|
|
|
|
<LI>
|
|
|
|
Modified variable references using pattern substitution come from
|
|
SunOS 4. See section <A HREF="make_6.html#SEC58">Basics of Variable References</A>.
|
|
This functionality was provided in GNU <CODE>make</CODE> by the
|
|
<CODE>patsubst</CODE> function before the alternate syntax was implemented
|
|
for compatibility with SunOS 4. It is not altogether clear who
|
|
inspired whom, since GNU <CODE>make</CODE> had <CODE>patsubst</CODE> before SunOS
|
|
4 was released.
|
|
<LI>
|
|
|
|
The special significance of <SAMP>`+'</SAMP> characters preceding command lines
|
|
(see section <A HREF="make_9.html#SEC88">Instead of Executing the Commands</A>) is
|
|
mandated by
|
|
<CITE>IEEE Standard 1003.2-1992</CITE> (POSIX.2).
|
|
|
|
<LI>
|
|
|
|
The <SAMP>`+='</SAMP> syntax to append to the value of a variable comes from SunOS
|
|
4 <CODE>make</CODE>. See section <A HREF="make_6.html#SEC65">Appending More Text to Variables</A>.
|
|
|
|
<LI>
|
|
|
|
The syntax <SAMP>`<VAR>archive</VAR>(<VAR>mem1</VAR> <VAR>mem2</VAR>...)'</SAMP> to list
|
|
multiple members in a single archive file comes from SunOS 4 <CODE>make</CODE>.
|
|
See section <A HREF="make_11.html#SEC109">Archive Members as Targets</A>.
|
|
|
|
<LI>
|
|
|
|
The <CODE>-include</CODE> directive to include makefiles with no error for a
|
|
nonexistent file comes from SunOS 4 <CODE>make</CODE>. (But note that SunOS 4
|
|
<CODE>make</CODE> does not allow multiple makefiles to be specified in one
|
|
<CODE>-include</CODE> directive.) The same feature appears with the name
|
|
<CODE>sinclude</CODE> in SGI <CODE>make</CODE> and perhaps others.
|
|
</UL>
|
|
|
|
<P>
|
|
The remaining features are inventions new in GNU <CODE>make</CODE>:
|
|
|
|
</P>
|
|
|
|
<UL>
|
|
<LI>
|
|
|
|
Use the <SAMP>`-v'</SAMP> or <SAMP>`--version'</SAMP> option to print version and
|
|
copyright information.
|
|
|
|
<LI>
|
|
|
|
Use the <SAMP>`-h'</SAMP> or <SAMP>`--help'</SAMP> option to summarize the options to
|
|
<CODE>make</CODE>.
|
|
|
|
<LI>
|
|
|
|
Simply-expanded variables. See section <A HREF="make_6.html#SEC59">The Two Flavors of Variables</A>.
|
|
|
|
<LI>
|
|
|
|
Pass command-line variable assignments automatically through the
|
|
variable <CODE>MAKE</CODE> to recursive <CODE>make</CODE> invocations.
|
|
See section <A HREF="make_5.html#SEC50">Recursive Use of <CODE>make</CODE></A>.
|
|
|
|
<LI>
|
|
|
|
Use the <SAMP>`-C'</SAMP> or <SAMP>`--directory'</SAMP> command option to change
|
|
directory. See section <A HREF="make_9.html#SEC92">Summary of Options</A>.
|
|
|
|
<LI>
|
|
|
|
Make verbatim variable definitions with <CODE>define</CODE>.
|
|
See section <A HREF="make_6.html#SEC67">Defining Variables Verbatim</A>.
|
|
|
|
<LI>
|
|
|
|
Declare phony targets with the special target <CODE>.PHONY</CODE>.
|
|
|
|
Andrew Hume of AT&T Bell Labs implemented a similar feature with a
|
|
different syntax in his <CODE>mk</CODE> program. This seems to be a case of
|
|
parallel discovery. See section <A HREF="make_4.html#SEC33">Phony Targets</A>.
|
|
|
|
<LI>
|
|
|
|
Manipulate text by calling functions.
|
|
See section <A HREF="make_8.html#SEC75">Functions for Transforming Text</A>.
|
|
|
|
<LI>
|
|
|
|
Use the <SAMP>`-o'</SAMP> or <SAMP>`--old-file'</SAMP>
|
|
option to pretend a file's modification-time is old.
|
|
See section <A HREF="make_9.html#SEC89">Avoiding Recompilation of Some Files</A>.
|
|
|
|
<LI>
|
|
|
|
Conditional execution.
|
|
|
|
This feature has been implemented numerous times in various versions
|
|
of <CODE>make</CODE>; it seems a natural extension derived from the features
|
|
of the C preprocessor and similar macro languages and is not a
|
|
revolutionary concept. See section <A HREF="make_7.html#SEC71">Conditional Parts of Makefiles</A>.
|
|
|
|
<LI>
|
|
|
|
Specify a search path for included makefiles.
|
|
See section <A HREF="make_3.html#SEC15">Including Other Makefiles</A>.
|
|
|
|
<LI>
|
|
|
|
Specify extra makefiles to read with an environment variable.
|
|
See section <A HREF="make_3.html#SEC16">The Variable <CODE>MAKEFILES</CODE></A>.
|
|
|
|
<LI>
|
|
|
|
Strip leading sequences of <SAMP>`./'</SAMP> from file names, so that
|
|
<TT>`./<VAR>file</VAR>'</TT> and <TT>`<VAR>file</VAR>'</TT> are considered to be the
|
|
same file.
|
|
<LI>
|
|
|
|
Use a special search method for library prerequisites written in the
|
|
form <SAMP>`-l<VAR>name</VAR>'</SAMP>.
|
|
See section <A HREF="make_4.html#SEC32">Directory Search for Link Libraries</A>.
|
|
|
|
<LI>
|
|
|
|
Allow suffixes for suffix rules
|
|
(see section <A HREF="make_10.html#SEC106">Old-Fashioned Suffix Rules</A>) to contain any
|
|
characters. In other versions of <CODE>make</CODE>, they must begin with
|
|
<SAMP>`.'</SAMP> and not contain any <SAMP>`/'</SAMP> characters.
|
|
|
|
<LI>
|
|
|
|
Keep track of the current level of <CODE>make</CODE> recursion using the
|
|
variable <CODE>MAKELEVEL</CODE>. See section <A HREF="make_5.html#SEC50">Recursive Use of <CODE>make</CODE></A>.
|
|
|
|
<LI>
|
|
|
|
Provide any goals given on the command line in the variable
|
|
<CODE>MAKECMDGOALS</CODE>. See section <A HREF="make_9.html#SEC87">Arguments to Specify the Goals</A>.
|
|
|
|
<LI>
|
|
|
|
Specify static pattern rules. See section <A HREF="make_4.html#SEC39">Static Pattern Rules</A>.
|
|
|
|
<LI>
|
|
|
|
Provide selective <CODE>vpath</CODE> search.
|
|
See section <A HREF="make_4.html#SEC26">Searching Directories for Prerequisites</A>.
|
|
|
|
<LI>
|
|
|
|
Provide computed variable references.
|
|
See section <A HREF="make_6.html#SEC58">Basics of Variable References</A>.
|
|
|
|
<LI>
|
|
|
|
Update makefiles. See section <A HREF="make_3.html#SEC17">How Makefiles Are Remade</A>.
|
|
System V <CODE>make</CODE> has a very, very limited form of this
|
|
functionality in that it will check out SCCS files for makefiles.
|
|
|
|
<LI>
|
|
|
|
Various new built-in implicit rules.
|
|
See section <A HREF="make_10.html#SEC95">Catalogue of Implicit Rules</A>.
|
|
|
|
<LI>
|
|
|
|
The built-in variable <SAMP>`MAKE_VERSION'</SAMP> gives the version number of
|
|
<CODE>make</CODE>.
|
|
</UL>
|
|
|
|
<P><HR><P>
|
|
<p>Go to the <A HREF="make_1.html">first</A>, <A HREF="make_11.html">previous</A>, <A HREF="make_13.html">next</A>, <A HREF="make_19.html">last</A> section, <A HREF="make_toc.html">table of contents</A>.
|
|
</BODY>
|
|
</HTML>
|