Makefile中指示符“include”、“-include”和“sinclude”的区别

<p class="Default" style="margin: 0cm 0cm 0pt; text-align: justify;"><span style="font-size: small;"><span style="">指示符</span>
<span style='font-family: "Times New Roman";' lang="EN-US">“</span>
<span style="font-family: Arial;" lang="EN-US">include</span>
<span style="font-family: Arial;" lang="EN-US">”</span>
<span style="">、</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">“</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">-include</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">”</span>
<span style="">和</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">“</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">sinclude</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">”</span>
</span>
</p>
<p class="Default" style="margin: 0cm 0cm 0pt;"><span lang="EN-US"><span style=""></span>
</span>
</p>
<p class="Default" style="margin: 0cm 0cm 0pt; text-indent: 21pt;"><span style="font-size: small;"><span style="">如果指示符</span>
<span style='font-family: "Times New Roman";' lang="EN-US">“</span>
<span style="font-family: Arial;" lang="EN-US">include</span>
<span style="font-family: Arial;" lang="EN-US">”</span>
<span style="">指定的文件不是以斜线开始(绝对路径,如</span>
<span style="font-family: Arial;" lang="EN-US">/usr/src/Makefile...</span>
<span style="">),而且当前目录下也不存在此文件;</span>
<span style="font-family: Arial;" lang="EN-US">make</span>
<span style="">将根据文件名试图在以下几个目录下查找:首先,查找使用命令行选项</span>
<span style="font-family: Arial;" lang="EN-US">“</span>
<span style="font-family: Arial;" lang="EN-US">-I</span>
<span style="font-family: Arial;" lang="EN-US">”</span>
<span style="">或者</span>
<span style="font-family: Arial;" lang="EN-US">“</span>
<span style="font-family: Arial;" lang="EN-US">--include-dir</span>
<span style="font-family: Arial;" lang="EN-US">”</span>
<span style="">指定的目录,如果找到指定的文件,则使用这个文件;否则继续依此搜索以下几个目录(如果其存在):</span>
<span style='color: windowtext; font-family: "Times New Roman";' lang="EN-US">“</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">/usr/gnu/include</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">”</span>
<span style="">、</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">“</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">/usr/local/include</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">”</span>
<span style="">和</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">“</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">/usr/include</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">”</span>
<span style="">。</span>
</span>
</p>
<p class="Default" style="margin: 0cm 0cm 0pt; text-indent: 24pt; text-align: justify;"><span style="font-size: small;"><span style="">当在这些目录下都没有找到</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">“</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">include</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">”</span>
<span style="">指定的文件时,</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">make</span>
<span style="">将会提示一个包含文件未找到的告警提示,但是不会立刻退出。而是继续处理</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">Makefile</span>
<span style="">的后续内容。当完成读取整个</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">Makefile</span>
<span style="">后,</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">make</span>
<span style="">将试图使用规则来创建通过指示符</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">“</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">include</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">”</span>
<span style="">指定的但未找到的文件,当不能创建它时(没有创建这个文件的规则),</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">make</span>
<span style="">将提示致命错误并退出。会输出类似如下错误提示:</span>
<span style="color: windowtext;" lang="EN-US"><span style=""> </span>
</span>
</span>
</p>
<p class="Default" style="margin: 0cm 0cm 0pt; text-indent: 48pt;"><span style="font-size: small;"><strong><em><span style="color: windowtext; font-family: Arial;" lang="EN-US">Makefile:</span>
</em>
</strong>
<span style="">错误的行数:未找到文件名:提示信息(</span>
<strong><em><span style="color: windowtext; font-family: Arial;" lang="EN-US">No such file or directory</span>
</em>
</strong>
<span style="">)</span>
<span style="color: windowtext;" lang="EN-US"><span style=""> </span>
</span>
</span>
</p>
<p class="Default" style="margin: 0cm 0cm 0pt; text-indent: 48pt;"><span style="font-size: small;"><strong><em><span style="color: windowtext; font-family: Arial;" lang="EN-US">Make</span>
</em>
</strong>
<span style="">:</span>
<span style="color: windowtext;"><span style=""> </span>
</span>
<strong><em><span style="color: windowtext; font-family: Arial;" lang="EN-US">*** No rule to make target ‘&lt;filename&gt;’. Stop </span>
</em>
</strong>
</span>
</p>
<p class="Default" style="margin: 0cm 0cm 0pt; text-indent: 24pt; text-align: justify;"><span style="font-size: small;"><span style="">通常我们在</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">Makefile</span>
<span style="">中可使用</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">“</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">-include</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">”</span>
<span style="">来代替</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">“</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">include</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">”</span>
<span style="">,来忽略由于包含文件不存在或者无法创建时的错误提示(</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">“</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">-</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">”</span>
<span style="">的意思是告诉</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">make</span>
<span style="">,忽略此操作的错误。</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">make</span>
<span style="">继续执行)。像下边那样:</span>
<span style="color: windowtext;" lang="EN-US"><span style=""> </span>
</span>
</span>
</p>
<p class="Default" style="margin: 0cm 0cm 0pt; text-indent: 48pt;"><span style="font-size: small;"><strong><em><span style="color: windowtext; font-family: Arial;" lang="EN-US">-include FILENAMES... </span>
</em>
</strong>
</span>
</p>
<p class="Default" style="margin: 0cm 0cm 0pt; text-indent: 24pt; text-align: justify;"><span style="font-size: small;"><span style="">使用这种方式时,当所要包含的文件不存在时不会有错误提示、</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">make</span>
<span style="">也不会退出;除此之外,和第一种方式效果相同。以下是这两种方式的比较:</span>
<span style="color: windowtext;" lang="EN-US"><span style=""> </span>
</span>
</span>
</p>
<p class="Default" style="margin: 0cm 0cm 0pt; text-indent: 24pt; text-align: justify;"><span style="font-size: small;"><span style="">使用</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">“</span>
<strong><em><span style="color: windowtext; font-family: Arial;" lang="EN-US">include FILENAMES...</span>
</em>
</strong>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">”</span>
<span style="">,</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">make</span>
<span style="">程序处理时,如果</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">“</span>
<strong><em><span style="color: windowtext; font-family: Arial;" lang="EN-US">FILENAMES</span>
</em>
</strong>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">”</span>
<span style="">列表中的任何一个文件不能正常读取而且不存在一个创建此文件的规则时</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">make</span>
<span style="">程序将会提示错误并退出。</span>
</span>
</p>
<p class="Default" style="margin: 0cm 0cm 0pt; text-indent: 24pt; text-align: justify;"><span style="font-size: small;"><span style="">使用</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">“</span>
<strong><em><span style="color: windowtext; font-family: Arial;" lang="EN-US">-include FILENAMES...</span>
</em>
</strong>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">”</span>
<span style="">的情况是,当所包含的文件不存在或者不存在一个规则去创建它,</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">make</span>
<span style="">程序会继续执行,只有真正由于不能正确完成终极目标的重建时(某些必需的目标无法在当前已读取的</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">makefile</span>
<span style="">文件内容中找到正确的重建规则),才会提示致命错误并退出。</span>
</span>
</p>
<p>
<span style="font-size: small;"><span style="">为了和其它的</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">make</span>
<span style="">程序进行兼容。也可以使用</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">“</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">sinclude</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">”</span>
<span style="">来代替</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">“</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">-include</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">”</span>
<span style="">(</span>
<span style="color: windowtext; font-family: Arial;" lang="EN-US">GNU</span>
<span style="">所支持的方式)。</span>
</span>
</p>

你可能感兴趣的:(makefile)