⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 make.html

📁 unix 下的C开发手册,还用详细的例程。
💻 HTML
📖 第 1 页 / 共 4 页
字号:
<b>SHELL</b>macro is treated specially.It is provided by<i>make</i>and set to the pathname of the shell command languageinterpreter (see<i><a href="sh.html">sh</a></i>).The<i>SHELL</i>environment variablewill not affect the value of the<b>SHELL</b>macro.If<b>SHELL</b>is defined in the makefile or isspecified on the command line, it will replace the original valueof the<b>SHELL</b>macro, but will 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-dependent.<h5><a name = "tag_001_014_1377_005">&nbsp;</a>Inference Rules</h5><xref type="5" name="infrules"></xref>Inference rules are formatted as follows:<pre><code><i>target</i>:&lt;tab&gt;<i>command</i><b>[</b>&lt;tab&gt;<i>command</i><b>]...</b><i>line that does not begin with </i>&lt;tab&gt;<i> or </i>#</code></pre><p>The<i>target</i>portion must be a valid target name (see<xref href=mktarg><a href="#tag_001_014_1377_003">Target Rules</a></xref>)of the form<i>.s2</i>or<i>.s1.s2</i>(where<i>.s1</i>and<i>.s2</i>are suffixes that have been given as prerequisites of the<b>.SUFFIXES</b>special target and<i>s1</i>and<i>s2</i>do not contain any slashes or periods.)If there is 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>The makefile must not specify prerequisites for inference rules;no characters other than white space can follow the colonin the first line,except when creating the<i>empty rule,</i>described below.Prerequisites are inferred, as described below.<p>Inference rules can be redefined.A target that matches an existinginference rule will overwrite the old inference rule.An empty rule can be created with a commandconsisting of simply a semicolon(that is, the rule still exists and is found during inference rulesearch, but since it is empty, execution has no effect).The empty rule also can be formatted as follows:<pre><code><i>rule</i>: ;</code></pre>where zero or moreblank charactersseparate the colon and semicolon.<p>The<i>make</i>utility uses the suffixes of targets and their prerequisites to inferhow a target can be made up-to-date.A list of inference rulesdefines the commands to be executed.By default,<i>make</i>contains a built-in set of inference rules.Additional rules can be specified in themakefile.<p>The special target<b>.SUFFIXES</b>contains as its prerequisites alist of suffixes that are to be used by the inference rules.The order in which the suffixes are specified defines the orderin which the inference rules for the suffixes are used.New suffixes will be appended to the current list by specifying a<b>.SUFFIXES</b>special target in themakefile.A<b>.SUFFIXES</b>target with noprerequisites will 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>Normally, the user would provide an inference rule for each suffix.The inference rule to update a target with a suffix<i>.s1</i>from a prerequisite with a suffix<i>.s2</i>is specified as a target<i>.s2.s1</i>.The internal macros provide the means to specify general inference rules.(See<xref href=mkimacs><a href="#tag_001_014_1377_007">Internal Macros</a></xref>.)<p>When no target rule is found to update a target, the inferencerules are checked.The suffix of the target(<i>.s1</i>)to be built is compared to the list of suffixes specified by the<b>.SUFFIXES</b>special targets.If the<i>.s1</i>suffix is found in<b>.SUFFIXES</b>,the inference rules are searched in the order defined for the first<i>.s2.s1</i>rule whose prerequisite file(<b>$*</b><i>.s2</i>)exists.If the target is out-of-date withrespect to this prerequisite, the commands for that inference ruleare executed.<p>If the target to be built does not contain a suffix andthere is no rule for the target, the singlesuffix inference rules will be checked.The single-suffix inference rules define how to builda target if a file is found with a name thatmatches the target name with one of the singlesuffixes appended.A rule with one suffix<i>.s2</i>is the definition of how to build<i>target</i>from<i>target.s2</i>.The other suffix(<i>.s1</i>)is treated as null.<p>A tilde(~)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 anobject file(<b>.o</b>).Because the<b>s.</b>of the SCCS files is a prefix,it is incompatible with<i>make</i>'ssuffix point of view.Hence, the  ~ is a way of changing any filereference into an SCCS file reference.<h5><a name = "tag_001_014_1377_006">&nbsp;</a>Libraries</h5>If a target or prerequisite contains parentheses, it will be treatedas a member of an archive library.For the <i>lib</i><b>(</b><i>member</i><b>.o)</b> expression<i>lib</i>refers to the name of the archive library and<i>member</i>.oto the member name.The member must be an object file with the<b>.o</b>suffix.The modification time of the expression is the modification timefor the member as kept in the archive library.See<i><a href="ar.html">ar</a></i>.The<b>.a</b>suffix refers to an archive library.The<i>.s2</i><b>.a</b>rule is usedto update a member in the library from a file with a suffix<i>.s2</i>.<h5><a name = "tag_001_014_1377_007">&nbsp;</a>Internal Macros</h5><xref type="5" name="mkimacs"></xref>The<i>make</i>utility maintains five internal macros that canbe used in target and inference rules.In order to clearlydefine the meaning of these macros, some clarification of theterms<i>target rule</i>,<i>inference rule</i>,<i>target</i>and<i>prerequisite</i>is necessary.<p>Target rules are specified by the user in a makefile for aparticular target.Inference rules are user- or<i>make</i>-specifiedrules for a particular class of target names.Explicit prerequisites are those prerequisitesspecified in a makefile on target lines.Implicit prerequisites are those prerequisitesthat are generated when inference rules are used.Inference rules are applied to implicit prerequisites or to explicitprerequisites that do not have target rules defined for them inthe makefile.Target rules are applied to targets specified in the makefile.<p>Before any target in the makefile is updated, each of itsprerequisites (both explicit and implicit) will be updated.This is accomplished by recursively processing each prerequisite.Upon recursion, each prerequisite becomes a target itself.Its prerequisites in turnare processed recursively until a target is found that has noprerequisites, at which point the recursion stops.The recursion then backs up, updating each target as it goes.<p>In the definitions that follow, the word<i>target</i>refers to one of:<ul><p><li>a target specified in the makefile<p><li>an explicit prerequisite specified in themakefile that becomes the target when<i>make</i>processes it during recursion<p><li>an implicit prerequisite that becomes a target when<i>make</i>processes it during recursion.<p></ul><p>In the definitions that follow, the word<i>prerequisite</i>refers to one o the following:<ul><p><li>an explicit prerequisite specified in the makefilefor a particular target<p><li>an implicit prerequisitegenerated as a result of locating an appropriate inference ruleand corresponding file that matches the suffix of the target.<p></ul><br><p>The five internal macros are:<dl compact><dt>$@<dd>The $@ evaluates to the full target nameof the current target, or the archive filenamepart of a library archive target.It is evaluated for both target and inference rules.For example, in the<b>.c.a</b>inference rule, $@ represents the out-of-date<b>.a</b>file to be built.Similarly, in a makefile target rule to build<b>lib.a</b>from<b>file.c</b>,$@ represents the out-of-date<b>lib.a</b>.<dt>$%<dd>The $% macro is evaluated only when the currenttarget is an archive library member of the form<i>libname</i>(<i>member</i><b>.o</b>).In these cases, $@ evaluates to<i>libname</i>and $%evaluates to<i>member</i><b>.o</b>.The $% macro is evaluated for both target and inference rules.For example, in a makefile target rule to build<b>lib.a(file.o)</b>,$% represents<b>file.o</b> as opposed to $@, which represents<b>lib.a</b>.<dt>$?<dd>The $? macro evaluates to the list ofprerequisites that are newer than the current target.It is evaluated for both target and inference rules.For example, in a makefile target rule to build<b>prog</b>from<b>file1.o</b>,<b>file2.o</b>and<b>file3.o</b>,and where<b>prog</b>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>.<dt>$&lt;<dd>In an inference rule, $&lt; evaluates to the filenamewhose existence allowed the inference rule to be chosen for the target.In the<b>.DEFAULT</b>rule, the $&lt; macro evaluates to the current target name.The $&lt; macro is evaluated only for inference rules.For example, in the<b>.c.a</b>inference rule, $&lt; represents the prerequisite<b>.c</b>file.<dt>$*<dd>The $* macro evaluates to the current targetname with its suffix deleted.It is evaluated at least for inference rules.For example, in the<b>.c.a</b>inference rule, $*.o represents the out-of-date<b>.o</b>file that corresponds to the prerequisite<b>.c</b>file.</dl><p>Each of the internal macros has an alternative form.When an upper-caseDorFis appended to any of the macros, the meaningis changed to the<i>directory part</i>forDand<i>filename part</i>forF.The directory part is the path prefix of the file without a trailing slash;for the current directory, the directory part is &quot;.&quot;.When the $? macro contains more than one prerequisite filename, the$(?D)and$(?F)(or${?D}and${?F})macros expand to a list of directory nameparts and filename parts respectively.<p>For the target <i>lib</i><b>(</b><i>member</i><b>.o)</b> and the<b>s2.a</b>rule, the internal macros are defined as:<dl compact><dt>$&lt;<dd><i>member</i><b>.s2</b><dt>$*<dd><i>member</i><dt>$@<dd><i>lib</i><dt>$?<dd><i>member</i><b>.s2</b><dt>$%<dd><i>member</i><b>.o</b></dl><h5><a name = "tag_001_014_1377_008">&nbsp;</a>Default Rules</h5><xref type="5" name="mkdefr"></xref>The default rules for<i>make</i>achieve results that are the sameas if the following were used.Implementations that do not supportFORTRAN may omit<b>FC</b>,<b>FFLAGS</b>and the.finference rules.Implementations may provide additional macros and rules.<pre><code><i>SPECIAL TARGETS</i>.SCCS_GET: sccs $(SCCSFLAGS) get $(SCCSGETFLAGS) $@     .SUFFIXES: .o .c .y .l .a .sh .f .c~ .y~ .l~ .sh~ .f~      <i>MACROS</i>MAKE=makeAR=arARFLAGS=-rvYACC=yaccYFLAGS=LEX=lexLFLAGS=LDFLAGS=CC=c89CFLAGS=-OFC=fort77FFLAGS=-O 1GET=getGFLAGS=SCCSFLAGS=SCCSGETFLAGS=-s<i>SINGLE SUFFIX RULES</i>.c:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -