📄 make-10.html
字号:
<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></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"><span lang="EN-US" style="font-family: 楷体_GB2312">空命令</span></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"><span lang="EN-US" style="font-family: 楷体_GB2312">目标指定变量</span>
</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"># sample
Makefile</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"> </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">CUR_DIR =
$(shell pwd)</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">INCS := $(CUR_DIR)/include</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">CFLAGS := -Wall
–I$(INCS)</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"> </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">EXEF := foo bar</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"> </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">.PHONY : all
clean</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">all : $(EXEF)</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"> </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">foo : CFLAGS+=-O2</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">bar : CFLAGS+=-g</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"> </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">clean :</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"> $(RM)
*.o *.d $(EXES)</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">
</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">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">GNU
make</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">所提供的隐含规则功能,可以大大提供效率。</span></p>
<h2><a name="_gnu_make_10.2"><span style="font-size: 14pt" lang="en-us"><b>1</b></span><b><span lang="EN-US" style="font-size: 14.0pt">0.2<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7.0pt; font-family: Times New Roman">
</span>make</span></b><span style="font-size: 14.0pt; font-family: 楷体_GB2312">的隐含规则一览</span></a></h2>
<p class="MsoBodyTextFirstIndent" style="text-indent:24.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">GUN
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%; 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%; color: black">-r</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">-R</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">”参数取消隐含规则,否则这些隐含规则将有效。</span></p>
<p class="MsoBodyTextFirstIndent" style="text-indent:24.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">-r</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">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%; 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%; 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%; color: black">.SUFFIXES</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">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%; color: black">.out</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">.a</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">.ln</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">.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%; 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%; color: black">.cc</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">.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%; color: black">.p</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">.f</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">.F</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">.r</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">.y</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">.l</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">.s</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">.S</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">.mod</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">.sym</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">.def</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">.h</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">.info</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">.dvi</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">.tex</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">.texinfo</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">.texi</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">txinfo</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">.w</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">.ch</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">.web</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">.sh</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">.elc</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">el</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: black">”。所有我们下边将提到的隐含规则,如果其依赖文件中某一个满足列表中列出的后缀,则是后缀规则。如果修改了可识别后缀列表,那么可能会是许多默认预定义的规则无效(因为一些后缀可能不会别识别)。以下是常用的一些隐含规则(对于不常见的隐含规则这里没有描述):</span></p>
<p class="MsoBodyTextFirstIndent" style="text-indent: -21.0pt; margin-left: 39.0pt">
<b><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; color: blue">
1.<span style="font:7.0pt "Times New Roman""> </span></span>
<span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: blue">
编译</span><span lang="EN-US" style="font-size: 12.0pt; line-height: 150%; color: blue">C</span><span style="font-size: 12.0pt; line-height: 150%; font-family: 楷体_GB2312; color: blue">程序</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">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -