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

📄 make-14.html

📁 unix make 文档
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<p class="MsoNormal" style="text-indent: 41.2pt"><b><i>
<span lang="EN-US" style="font-size: 12.0pt; font-family: Arial">.c.o:</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">$(CC) -c $(CPPFLAGS) 
$(ALL_CFLAGS) $&lt;</span></i></b></p>
<p class="MsoNormal" style="text-indent: 20.5pt">
<span lang="SV" style="font-size: 12.0pt; font-family: Arial">&nbsp;</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; 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">CFLAGS</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">-g</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">-g</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">-I. 
-g </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">CFLAGS</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">CFLAGS</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">CFLAGS</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">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">INSTALL</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">install</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">INSTALL_PROGRAM</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">INSTALL_DATA</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">INSTALL_PROGRAM</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">$(INSTALL)</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">INSTALL_DATA</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">”的缺省值是“</span>${INSTALL} 
–m 644<span lang="EN-US" style="font-family: 楷体_GB2312; font-size: 12.0pt; line-height: 150%; color: black">”)。<span lang="EN-US">可以</span></span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">使用这些变量,来安装可执行程序或者非可执行程序到指定位置。例如:</span></p>
<p class="MsoNormal" style="text-indent: 20.5pt">
<span lang="EN-US" style="font-size: 12.0pt; font-family: Arial">&nbsp;</span></p>
<p class="MsoNormal" style="text-indent: 41.2pt"><b><i>
<span lang="EN-US" style="font-size: 12.0pt; font-family: Arial">$(INSTALL_PROGRAM) 
foo $(bindir)/foo</span></i></b></p>
<p class="MsoNormal" style="text-indent: 41.2pt"><b><i>
<span lang="EN-US" style="font-size: 12.0pt; font-family: Arial">$(INSTALL_DATA) 
libfoo.a $(libdir)/libfoo.a</span></i></b></p>
<p class="MsoNormal" style="text-indent: 20.5pt">
<span lang="EN-US" style="font-size: 12.0pt; font-family: Arial">&nbsp;</span></p>
<p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; 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">DESTDIR</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">DESTDIR</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 
DESTDIR=exec/ install</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">”。因此上边的命令就可以这样实现:</span></p>
<p class="MsoNormal" style="text-indent: 20.5pt">
<span lang="EN-US" style="font-size: 12.0pt; font-family: Arial">&nbsp;</span></p>
<p class="MsoNormal" style="text-indent: 41.2pt"><b><i>
<span lang="EN-US" style="font-size: 12.0pt; font-family: Arial">$(INSTALL_PROGRAM) 
foo $(DESTDIR)$(bindir)/foo</span></i></b></p>
<p class="MsoNormal" style="text-indent: 41.2pt"><b><i>
<span lang="EN-US" style="font-size: 12.0pt; font-family: Arial">$(INSTALL_DATA) 
libfoo.a $(DESTDIR)$(libdir)/libfoo.a</span></i></b></p>
<p class="MsoNormal" style="text-indent: 20.5pt">
<span lang="EN-US" style="font-size: 12.0pt; font-family: Arial">&nbsp;</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">
&nbsp;</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></p>
<h2><a name="_gnu_make_14.4"><span style="font-size: 14pt" lang="en-us"><b>1</b></span><b><span lang="EN-US" style="font-size: 14.0pt">4.4<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7.0pt; font-family: Times New Roman">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></b><span style="font-size: 14.0pt; font-family: 楷体_GB2312">安装目录变量</span></a></h2>
<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">SVR4</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">4.4BSD</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">Linux</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">Ultrix 
v4</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: 21.0pt">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; font-family: Wingdings; color: black">
&Oslash;<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></p>
<p class="MsoBodyTextFirstIndent" style="text-indent:24.1pt"><b>
<span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; color: blue">
prefix</span></b></p>
<p class="MsoBodyTextFirstIndent" style="text-indent: 0cm; margin-left: 36.0pt">
<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%; color: black">prefix</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%; color: black">/usr/local</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%; color: black">GNU</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%; color: black">prefix</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%; color: black">/usr</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%; color: black">/</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB23

⌨️ 快捷键说明

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