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

📄 make-02.html

📁 unix make 文档
💻 HTML
📖 第 1 页 / 共 5 页
字号:
	<span lang="EN-US" style="font-size: 10.5pt; font-family: Arial">&nbsp;</span></p>
	<p class="MsoNormal" style="text-indent: 17.95pt">
	<span lang="EN-US" style="font-size: 10.5pt; font-family: Arial">In addition 
	to the information above, please be careful to include the version number of 
	`make' you are using.&nbsp; You can get this information with the command `make 
	--version'.&nbsp; Be sure also to include the type of machine and operating 
	system you are using.&nbsp; One way to obtain this information is by looking at 
	the final lines of output from the command</span></p>
	<p class="MsoNormal" style="text-indent: 17.95pt">
	<span lang="EN-US" style="font-size: 10.5pt; font-family: Arial">`<b><i>make 
	--help'</i></b>.</span></p>
	<div class="MsoNormal" align="center" style="text-align:center;mso-pagination:widow-orphan;
mso-layout-grid-align:auto;text-autospace:ideograph-numeric ideograph-other">
		<span lang="EN-US" style="font-size: 12.0pt; font-family: Arial; color: #222222">
		<hr size="1" width="100%" align="center"></span></div>
	<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; text-indent: 24.0pt; line-height: 150%; text-autospace: ideograph-numeric ideograph-other">
	<span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">
	以上时</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">GNU 
	make</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">的</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">bug</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">反馈方式。如果在你使用</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">GNU 
	make</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">过程中。发现</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">bug</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">或者问题。可以通过以上的方式和渠道反馈。</span></p>
	<span style="font-size: 12.0pt; font-family: 楷体_GB2312; color: black">
	好了。开始我们的神奇之旅吧!</span><h3><a name="_gnu_make_2.1"><span lang="EN-US" style="font-size: 14.0pt">2.1&nbsp; </span><b><span lang="EN-US" style="font-size: 14.0pt">Makefile</span></b></a><span style="font-size: 14.0pt; font-family: 楷体_GB2312">简介</span></h3>
	<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; text-indent: 24.0pt; line-height: 150%; text-autospace: ideograph-numeric ideograph-other">
	<span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">
	在执行</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">make</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">之前,需要一个命名为</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">Makefile</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">的特殊文件(本文的后续将使用</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">Makefile</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">作为这个特殊文件的文件名)来告诉</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">make</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">需要做什么(完成什么任务),该怎么做。通常,</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">make</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">工具主要被用来进行工程编译和程序链接。</span></p>
	<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; text-indent: 24.0pt; line-height: 150%; text-autospace: ideograph-numeric ideograph-other">
	<span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">
	本节将分析一个简单的</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">Makefile</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">,它对一个包含</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">8</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">个</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">C</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">的源代码和三个头文件的工程进行编译和链接。这个</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">Makefile</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">提供给了</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">make</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">必要的信息,</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">make</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">程序根据</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">Makefile</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">中的规则描述执行相关的命令来完成指定的任务(如:编译、链接和清除编译过程文件等)。</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312">复杂的</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial">Makefile</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312">我们将会在本文后续进行讨论。</span></p>
	<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; text-indent: 24.0pt; line-height: 150%; text-autospace: ideograph-numeric ideograph-other">
	<span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">
	当使用</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">make</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">工具进行编译时,工程中以下几种文件在执行</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">make</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">时将会被编译(重新编译):</span></p>
	<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; text-indent: -21.0pt; line-height: 150%; text-autospace: ideograph-numeric ideograph-other; margin-left: 39.0pt">
	<b>
	<span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">
	1.<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
	</span>
	<span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">
	所有的源文件没有被编译过,则对各个</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">C</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">源文件进行编译并进行链接,生成最后的可执行程序;</span></b></p>
	<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; text-indent: -21.0pt; line-height: 150%; text-autospace: ideograph-numeric ideograph-other; margin-left: 39.0pt">
	<b>
	<span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">
	2.<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
	</span>
	<span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">
	每一个在上次执行</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">make</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">之后修改过的</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">C</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">源代码文件在本次执行</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">make</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">时将会被重新编译;</span></b></p>
	<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; text-indent: -21.0pt; line-height: 150%; text-autospace: ideograph-numeric ideograph-other; margin-left: 39.0pt">
	<b>
	<span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">
	3.<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
	</span>
	<span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">
	头文件在上一次执行</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">make</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">之后被修改。则所有包含此头文件的</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">C</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">源文件在本次执行</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">make</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">时将会被重新编译。</span></b></p>
	<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; text-indent: 24.0pt; line-height: 150%; text-autospace: ideograph-numeric ideograph-other">
	<span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">
	后两种情况是</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">make</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">只将修改过的</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">C</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">源文件重新编译生成</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">.o</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">文件,对于没有修改的文件不进行任何工作。重新编译过程中,任何一个源文件的修改将产生新的对应的</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">.o</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">文件,新的</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">.o</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">文件将和以前的已经存在、此次没有重新编译的</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">.o</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">文件重新连接生成最后的可执行程序。</span></p>
	<span style="font-size: 12.0pt; font-family: 楷体_GB2312; color: black">
	首先让我们先来看一些</span><span lang="EN-US" style="font-size: 12.0pt; font-family: Arial; color: black">Makefile</span><span style="font-size: 12.0pt; font-family: 楷体_GB2312; color: black">相关的基本知识。</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">&nbsp;</span><h3><a name="_gnu_make_2.2"><span lang="EN-US" style="font-size: 14.0pt">2.2</span><b><span lang="EN-US" style="font-size: 14.0pt"> Makefile</span></b></a><span style="font-size: 14.0pt; font-family: 楷体_GB2312">规则介绍</span></h3>
	<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; text-indent: 24.0pt; line-height: 150%; text-autospace: ideograph-numeric ideograph-other">
	<span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">
	一个简单的</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">Makefile</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">描述规则组成:</span></p>
	<p class="MsoNormal" style="text-indent: 41.2pt"><b><i>
	<span lang="EN-US" style="font-size: 12.0pt; font-family: Arial">TARGET... : 
	PREREQUISITES...</span></i></b></p>
	<p class="MsoNormal" style="text-indent: 41.2pt; margin-left: 30.9pt"><b><i>
	<span lang="EN-US" style="font-size: 12.0pt; font-family: Arial">COMMAND</span></i></b></p>
	<p class="MsoNormal" style="text-indent: 41.2pt; margin-left: 30.9pt"><b><i>
	<span lang="EN-US" style="font-size: 12.0pt; font-family: Arial">...</span></i></b></p>
	<p class="MsoNormal" style="text-indent: 41.2pt; margin-left: 30.9pt"><b><i>
	<span lang="EN-US" style="font-size: 12.0pt; font-family: Arial">...</span></i></b></p>
	<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; text-indent: 24.0pt; line-height: 150%; text-autospace: ideograph-numeric ideograph-other">
	<span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">
	target</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">:规则的目标。通常是最后需要生成的文件名或者为了实现这个目的而必需的中间过程文件名。可以是</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">.o</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">文件、也可以是最后的可执行程序的文件名等。另外,目标也可以是一个</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">make</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">执行的动作的名称,如目标“</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">clean</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">”,我们称这样的目标是“伪目标”。</span></p>
	<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; text-indent: 24.0pt; line-height: 150%; text-autospace: ideograph-numeric ideograph-other">
	<span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">
	prerequisites</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">:规则的依赖。生成规则目标所需要的文件名列表。通常一个目标依赖于一个或者多个文件。</span></p>
	<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; text-indent: 24.0pt; line-height: 150%; text-autospace: ideograph-numeric ideograph-other">
	<span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">
	command</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">:规则的命令行。是规则所要执行的动作(任意的</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">shell</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">命令或者是可在</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">shell</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">下执行的程序)。它限定了</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Arial; color: black">make</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">执行这条规则时所需要的动作。</span></p>

⌨️ 快捷键说明

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