📄 make.html
字号:
<p>The contents of the environment, excluding the <i>MAKEFLAGS</i> and <i>SHELL</i> variables and including the variables with nullvalues.</p></li><li><p>Macros defined in the inference rules built into <i>make</i>.</p></li></ol><p>Macro definitions from these sources shall not override macro definitions from a lower-numbered source. Macro definitions from asingle source (for example, the <i>make</i> utility command line, the <i>MAKEFLAGS</i> environment variable, or the otherenvironment variables) shall override previous macro definitions from the same source.</p><p>Macros defined in the makefile(s) shall override macro definitions that occur before them in the makefile(s) and macrodefinitions from source 4. If the <b>-e</b> option is not specified, macros defined in the makefile(s) shall override macrodefinitions from source 3. Macros defined in the makefile(s) shall not override macro definitions from source 1 or source 2.</p><p>Before the makefile(s) are read, all of the <i>make</i> utility command line options (except <b>-f</b> and <b>-p</b>) and<i>make</i> utility command line macro definitions (except any for the <i>MAKEFLAGS</i> macro), not already included in the<i>MAKEFLAGS</i> macro, shall be added to the <i>MAKEFLAGS</i> macro, quoted in an implementation-defined manner such that when<i>MAKEFLAGS</i> is read by another instance of the <i>make</i> command, the original macro's value is recovered. Otherimplementation-defined options and macros may also be added to the <i>MAKEFLAGS</i> macro. If this modifies the value of the<i>MAKEFLAGS</i> macro, or, if the <i>MAKEFLAGS</i> macro is modified at any subsequent time, the <i>MAKEFLAGS</i> environmentvariable shall be modified to match the new value of the <i>MAKEFLAGS</i> macro. The result of setting <i>MAKEFLAGS</i> in theMakefile is unspecified.</p><p>Before the makefile(s) are read, all of the <i>make</i> utility command line macro definitions (except the <i>MAKEFLAGS</i>macro or the <i>SHELL</i> macro) shall be added to the environment of <i>make</i>. Other implementation-defined variables may alsobe added to the environment of <i>make</i>.</p><p>The <b>SHELL</b> macro shall be treated specially. It shall be provided by <i>make</i> and set to the pathname of the shellcommand language interpreter (see <a href="sh.html"><i>sh</i></a> ). The <i>SHELL</i> environment variable shall not affect thevalue of the <b>SHELL</b> macro. If <b>SHELL</b> is defined in the makefile or is specified on the command line, it shall replacethe original value of the <b>SHELL</b> macro, but shall not affect the <i>SHELL</i> environment variable. Other effects of defining<b>SHELL</b> in the makefile or on the command line are implementation-defined.</p><h5><a name="tag_04_84_13_05"></a>Inference Rules</h5><p>Inference rules are formatted as follows:</p><pre><i>target</i><tt>:<tab></tt><i>command</i><b>[</b><tt><tab></tt><i>command</i><b>]</b><tt>...<br></tt><i>line that does not begin with</i> <tt><tab></tt> <i>or</i> <tt>#</tt></pre><p>The application shall ensure that the <i>target</i> portion is a valid target name (see <a href="#tag_04_84_13_03">TargetRules</a> ) of the form <b>.s2</b> or <b>.s1.s2</b> (where <b>.s1</b> and <b>.s2</b> are suffixes that have been given asprerequisites of the <b>.SUFFIXES</b> special target and <i>s1</i> and <i>s2</i> do not contain any slashes or periods.) If thereis only one period in the target, it is a single-suffix inference rule. Targets with two periods are double-suffix inference rules.Inference rules can have only one target before the colon.</p><p>The application shall ensure that the makefile does not specify prerequisites for inference rules; no characters other thanwhite space shall follow the colon in the first line, except when creating the <i>empty rule,</i> described below. Prerequisitesare inferred, as described below.</p><p>Inference rules can be redefined. A target that matches an existing inference rule shall overwrite the old inference rule. Anempty rule can be created with a command consisting of simply a semicolon (that is, the rule still exists and is found duringinference rule search, but since it is empty, execution has no effect). The empty rule can also be formatted as follows:</p><pre><i>rule</i><tt>: ;</tt></pre><p>where zero or more <blank>s separate the colon and semicolon.</p><p>The <i>make</i> utility uses the suffixes of targets and their prerequisites to infer how a target can be made up-to-date. Alist of inference rules defines the commands to be executed. By default, <i>make</i> contains a built-in set of inference rules.Additional rules can be specified in the makefile.</p><p>The special target <b>.SUFFIXES</b> contains as its prerequisites a list of suffixes that shall be used by the inference rules.The order in which the suffixes are specified defines the order in which the inference rules for the suffixes are used. Newsuffixes shall be appended to the current list by specifying a <b>.SUFFIXES</b> special target in the makefile. A <b>.SUFFIXES</b>target with no prerequisites shall clear the list of suffixes. An empty <b>.SUFFIXES</b> target followed by a new <b>.SUFFIXES</b>list is required to change the order of the suffixes.</p><p>Normally, the user would provide an inference rule for each suffix. The inference rule to update a target with a suffix<b>.s1</b> from a prerequisite with a suffix <b>.s2</b> is specified as a target <b>.s2.s1</b>. The internal macros provide themeans to specify general inference rules (see <a href="#tag_04_84_13_07">Internal Macros</a> ).</p><p>When no target rule is found to update a target, the inference rules shall be checked. The suffix of the target ( <b>.s1</b>) tobe built is compared to the list of suffixes specified by the <b>.SUFFIXES</b> special targets. If the <b>.s1</b> suffix is foundin <b>.SUFFIXES</b>, the inference rules shall be searched in the order defined for the first <b>.s2.s1</b> rule whose prerequisitefile ( <b>$*.s2</b>) exists. If the target is out-of-date with respect to this prerequisite, the commands for that inference ruleshall be executed.</p><p>If the target to be built does not contain a suffix and there is no rule for the target, the single suffix inference rules shallbe checked. The single-suffix inference rules define how to build a target if a file is found with a name that matches the targetname with one of the single suffixes appended. A rule with one suffix <b>.s2</b> is the definition of how to build <i>target</i>from <b>target.s2</b>. The other suffix ( <b>.s1</b>) is treated as null.</p><p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> Atilde ( <tt>'˜'</tt> ) in the above rules refers to an SCCS file in the current directory. Thus, the rule <b>.c˜.o</b>would transform an SCCS C-language source file into an object file ( <b>.o</b>). Because the <b>s.</b> of the SCCS files is aprefix, it is incompatible with <i>make</i>'s suffix point of view. Hence, the <tt>'˜'</tt> is a way of changing any filereference into an SCCS file reference. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><h5><a name="tag_04_84_13_06"></a>Libraries</h5><p>If a target or prerequisite contains parentheses, it shall be treated as a member of an archive library. For the <i>lib</i>(<i>member</i> <b>.o</b>) expression <i>lib</i> refers to the name of the archive library and <i>member</i> <b>.o</b> to the membername. The application shall ensure that the member is an object file with the <b>.o</b> suffix. The modification time of theexpression is the modification time for the member as kept in the archive library; see <a href="ar.html"><i>ar</i></a> . The<b>.a</b> suffix shall refer to an archive library. The <b>.s2.a</b> rule shall be used to update a member in the library from afile with a suffix <b>.s2</b>.</p><h5><a name="tag_04_84_13_07"></a>Internal Macros</h5><p>The <i>make</i> utility shall maintain five internal macros that can be used in target and inference rules. In order to clearlydefine the meaning of these macros, some clarification of the terms <i>target rule</i>, <i>inference rule</i>, <i>target</i>, and<i>prerequisite</i> is necessary.</p><p>Target rules are specified by the user in a makefile for a particular target. Inference rules are user-specified or<i>make</i>-specified rules for a particular class of target name. Explicit prerequisites are those prerequisites specified in amakefile on target lines. Implicit prerequisites are those prerequisites that are generated when inference rules are used.Inference rules are applied to implicit prerequisites or to explicit prerequisites that do not have target rules defined for themin the makefile. Target rules are applied to targets specified in the makefile.</p><p>Before any target in the makefile is updated, each of its prerequisites (both explicit and implicit) shall be updated. Thisshall be accomplished by recursively processing each prerequisite. Upon recursion, each prerequisite shall become a target itself.Its prerequisites in turn shall be processed recursively until a target is found that has no prerequisites, at which point therecursion stops. The recursion shall then back up, updating each target as it goes.</p><p>In the definitions that follow, the word <i>target</i> refers to one of:</p><ul><li><p>A target specified in the makefile</p></li><li><p>An explicit prerequisite specified in the makefile that becomes the target when <i>make</i> processes it during recursion</p></li><li><p>An implicit prerequisite that becomes a target when <i>make</i> processes it during recursion</p></li></ul><p>In the definitions that follow, the word <i>prerequisite</i> refers to one of the following:</p><ul><li><p>An explicit prerequisite specified in the makefile for a particular target</p></li><li><p>An implicit prerequisite generated as a result of locating an appropriate inference rule and corresponding file that matches thesuffix of the target</p></li></ul><p>The five internal macros are:</p><dl compact><dt>$@</dt><dd>The $@ shall evaluate to the full target name of the current target, or the archive filename part of a library archive target.It shall be evaluated for both target and inference rules. <p>For example, in the <b>.c.a</b> inference rule, $@ represents the out-of-date <b>.a</b> file to be built. Similarly, in amakefile target rule to build <b>lib.a</b> from <b>file.c</b>, $@ represents the out-of-date <b>lib.a</b>.</p></dd><dt>$%</dt><dd>The $% macro shall be evaluated only when the current target is an archive library member of the form <i>libname</i>(<i>member</i> <b>.o</b>). In these cases, $@ shall evaluate to <i>libname</i> and $% shall evaluate to <i>member</i> <b>.o</b>. The$% macro shall be evaluated for both target and inference rules. <p>For example, in a makefile target rule to build <b>lib.a</b>( <b>file.o</b>), $% represents <b>file.o</b>, as opposed to $@,which represents <b>lib.a</b>.</p></dd><dt>$?</dt><dd>The $? macro shall evaluate to the list of prerequisites that are newer than the current target. It shall be evaluated for bothtarget and inference rules. <p>For example, in a makefile target rule to build <i>prog</i> from <b>file1.o</b>, <b>file2.o</b>, and <b>file3.o</b>, and where<i>prog</i> is not out-of-date with respect to <b>file1.o</b>, but is out-of-date with respect to <b>file2.o</b> and<b>file3.o</b>, $? represents <b>file2.o</b> and <b>file3.o</b>.</p></dd><dt>$<</dt><dd>In an inference rule, the $< macro shall evaluate to the filename whose existence allowed the inference rule to be chosenfor the target. In the <b>.DEFAULT</b> rule, the $< macro shall evaluate to the current target name. The meaning of the $<macro shall be otherwise unspecified. <p>For example, in the <b>.c.a</b> inference rule, $< represents the prerequisite <b>.c</b> file.</p></dd><dt>$*</dt><dd>The $* macro shall evaluate to the current target name with its suffix deleted. It shall be evaluated at least for inferencerules. <p>For example, in the <b>.c.a</b> inference rule, $*.o represents the out-of-date <b>.o</b> file that corresponds to theprerequisite <b>.c</b> file.</p></dd></dl><p>Each of the internal macros has an alternative form. When an uppercase <tt>'D'</tt> or <tt>'F'</tt> is appended to any of themacros, the meaning shall be changed to the <i>directory part</i> for <tt>'D'</tt> and <i>filename part</i> for <tt>'F'</tt> . Thedirectory part is the path prefix of the file without a trailing slash; for the current directory, the directory part is<tt>'.'</tt> . When the $? macro contains more than one prerequisite filename, the $(?D) and $(?F) (or ${?D} and ${?F}) macrosexpand to a list of directory name parts and filename parts respectively.</p><p>For the target <i>lib</i>( <i>member</i> <b>.o</b>) and the <b>s2.a</b> rule, the internal macros shall be defined as:</p><dl compact><dt>$<</dt><dd><i>member</i> <b>.s2</b></dd><dt>$*</dt><dd><i>member</i></dd><dt>$@</dt><dd><i>lib</i></dd><dt>$?</dt><dd><i>member</i> <b>.s2</b></dd><dt>$%</dt><dd><i>member</i> <b>.o</b></dd></dl><h5><a name="tag_04_84_13_08"></a>Default Rules</h5><p>The default rules for <i>make</i> shall achieve results that are the same as if the following were used. Implementations that donot support the C-Language Development Utilities option may omit <b>CC</b>, <b>CFLAGS</b>, <b>YACC</b>, <b>YFLAGS</b>, <b>LEX</b>,<b>LFLAGS</b>, <b>LDFLAGS</b>, and the <b>.c</b>, <b>.y</b>, and <b>.l</b> inference rules. Implementations that do not supportFORTRAN may omit <b>FC</b>, <b>FFLAGS</b>, and the <b>.f</b> inference rules. Implementations may provide additional macros andrules.</p><pre><i>SPECIAL TARGETS</i><tt><br><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">.SCCS_GET: sccs $(SCCSFLAGS) get $(SCCSGETFLAGS) $@<img src="../images/opt-end.gif" alt="[Option End]" border="0"><br><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup>.SUFFIXES: .o .c .y .l .a .sh .f <img src="../images/opt-start.gif" border="0">.c˜ .y˜ .l˜ .sh˜ .f˜<imgsrc="../images/opt-end.gif" border="0"><br></tt><i>MACROS</i><tt><br>MAKE=makeAR=arARFLAGS=-rvYACC=yaccYFLAGS=LEX=lexLFLAGS=LDFLAGS=CC=c99CFLAGS=-O
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -