📄 196570.html
字号:
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>[转贴]Makefile解读</title>
<meta name="keywords" content="[转贴]Makefile解读,[转贴]Makefile解读">
<meta name="generator" content="CipCMS! 1.0.0 with Templates 1.0.0">
<meta name="Author" content="[转贴]Makefile解读,[转贴]Makefile解读,chinaitpower">
<meta name="description" content="[转贴]Makefile解读,[转贴]Makefile解读"><link rel="stylesheet" href="196570_files/style.css"></head><body topmargin="5" bgcolor="#f4f4e8">
<table align="center" border="0" cellpadding="0" cellspacing="0" width="760">
<tbody><tr>
<td width="186">中国IT动力,最新最全的IT技术教程</td>
<td valign="bottom" width="574"><table border="0" cellpadding="0" cellspacing="0" width="574">
<tbody><tr>
<td width="29"><img src="196570_files/bar_bg_l.gif" height="24" width="29"></td>
<td align="center" background="196570_files/bar_bg.gif">
<a href="http://www.chinaitpower.com/new100.asp" class="bar">最新100篇</a>
| <a href="http://www.chinaitpower.com/commend100.asp" class="bar">推荐100篇</a>
| <a href="http://www.chinaitpower.com/subject/index.asp" class="bar">专题100篇</a>
| <a href="http://www.chinaitpower.com/paihang.asp" class="bar">排行榜</a>
| <a href="http://www.chinaitpower.com/Search.asp" class="bar"><font color="green"><b>搜索</b></font></a>
| <a href="http://online.chinaitpower.com/" class="bar">在线API文档</a>
</td>
<td width="4"><img src="196570_files/bar_bg_r.gif" height="24" width="4"></td>
</tr>
</tbody></table></td>
</tr>
</tbody></table>
<table align="center" bgcolor="#8b7e66" border="0" cellpadding="0" cellspacing="0" width="760">
<tbody><tr>
<td class="white" align="center" height="32" width="4"><img src="196570_files/bar_l.htm" height="32" width="4"></td>
<td class="white" align="center" width="756">
<a href="http://www.chinaitpower.com/" class="white1">首 页</a> | <a href="http://www.chinaitpower.com/Dev/index.html" class="white1">程序开发</a> | <a href="http://www.chinaitpower.com/System/index.html" class="white1">操作系统</a> | <a href="http://www.chinaitpower.com/Soft/index.html" class="white1">软件应用</a> | <a href="http://www.chinaitpower.com/Design/index.html" class="white1">图形图象</a> | <a href="http://www.chinaitpower.com/Net/index.html" class="white1">网络应用</a> | <a href="http://www.chinaitpower.com/Good/index.html" class="white1">精文荟萃</a> | <a href="http://www.chinaitpower.com/RenZ/index.html" class="white1">教育认证</a> | <a href="http://www.chinaitpower.com/hardwarerepair/index.html" class="white1">硬件维护</a> | <a href="http://www.chinaitpower.com/Temps/index.html" class="white1">未整理篇</a> | <a href="http://www.chinaitpower.com/zhanzhang/index.html" class="white1">站长教程</a>
</td>
</tr>
</tbody></table>
<table align="center" border="0" cellpadding="0" cellspacing="0" width="760">
<tbody><tr>
<td bgcolor="white" height="1"></td>
</tr>
<tr>
<td bgcolor="#8b7e66" height="4"></td>
</tr>
</tbody></table>
<table class="border2" align="center" border="0" cellpadding="0" cellspacing="0" width="760">
<tbody><tr>
<td bgcolor="#f4f4e8">
<table width="100%"><tbody><tr>
<td><a href="http://www.chinaitpower.com/2005September/2005-09-13/Dev/Web/Asp/index.html" target="_blank">ASP</a> <a href="http://www.chinaitpower.com/2005September/2005-09-13/Dev/Web/JavaScripts/index.html" target="_blank">JS</a>
</td><td><a href="http://www.chinaitpower.com/2005September/2005-09-13/Dev/Web/PHP/Other/index.html" target="_blank">PHP</a><a href="http://www.chinaitpower.com/2005September/2005-09-13/Dev/Softproject/index.html" target="_blank">工程</a>
</td><td><a href="http://www.chinaitpower.com/2005September/2005-09-13/Dev/Web/NET/ASPNET/index.html" target="_blank">ASP.NET</a>
</td><td><a href="http://www.chinaitpower.com/2005September/2005-09-13/Dev/Web/site/index.html" target="_blank">网站建设</a> <a href="http://www.chinaitpower.com/2005September/2005-09-13/Dev/Softproject/UML/index.html" target="_blank">UML</a>
</td><td><a href="http://www.chinaitpower.com/2005September/2005-09-13/Dev/Programme/Java/index.html" target="_blank">J2EE</a><a href="http://www.chinaitpower.com/2005September/2005-09-13/Sun/index.html" target="_blank">SUN</a>
</td><td><a href="http://www.chinaitpower.com/2005September/2005-09-13/Dev/Programme/Net/index.html" target="_blank">.NET</a>
</td><td><a href="http://www.chinaitpower.com/2005September/2005-09-13/Dev/Programme/VC/index.html" target="_blank"><b>VC</b></a> <a href="http://www.chinaitpower.com/2005September/2005-09-13/Dev/Programme/VB/index.html" target="_blank"><b>VB</b></a> <a href="http://www.chinaitpower.com/2005September/2005-09-13/Dev/Programme/VFP/index.html" target="_blank"><b>VFP</b></a>
</td><td><a href="http://www.chinaitpower.com/2005September/2005-09-13/Net/Net/index.html" target="_blank">网络维护</a>
</td><td><a href="http://www.chinaitpower.com/2005September/2005-09-13/Dev/DataBase/Databse/index.html" target="_blank">数据库</a> <a href="http://www.chinaitpower.com/2005September/2005-09-13/Dev/DataBase/DB2/index.html" target="_blank">DB2</a>
</td><td><a href="http://www.chinaitpower.com/2005September/2005-09-13/Dev/DataBase/MsSql/index.html" target="_blank">SQL2000</a>
</td><td><a href="http://www.chinaitpower.com/2005September/2005-09-13/Dev/DataBase/Oracle/index.html" target="_blank">Oracle</a>
</td><td><a href="http://www.chinaitpower.com/2005September/2005-09-13/Dev/DataBase/Mysql/index.html" target="_blank">Mysql</a>
</td></tr><tr>
<td><a href="http://www.chinaitpower.com/2005September/2005-09-13/System/Server/index.html" target="_blank">服务器</a>
</td><td><a href="http://www.chinaitpower.com/2005September/2005-09-13/System/Win2000/index.html" target="_blank">Win2000</a>
</td><td><a href="http://www.chinaitpower.com/2005September/2005-09-13/Soft/Office/index.html" target="_blank">Office</a> <a href="http://www.chinaitpower.com/2005September/2005-09-13/Dev/Programme/CC/index.html" target="_blank"><b>C</b></a>
</td><td><a href="http://www.chinaitpower.com/2005September/2005-09-13/Design/Web/DreamWeaver/index.html" target="_blank">DreamWeaver</a>
</td><td><a href="http://www.chinaitpower.com/2005September/2005-09-13/Design/Web/FireWorks/index.html" target="_blank">FireWorks</a>
</td><td><a href="http://www.chinaitpower.com/2005September/2005-09-13/Design/Web/Flash/index.html" target="_blank">Flash</a>
</td><td><a href="http://www.chinaitpower.com/2005September/2005-09-13/Design/Image/PhotoShop/index.html" target="_blank">PhotoShop</a>
</td><td><a href="http://www.chinaitpower.com/2005September/2005-09-13/Net/GotoNet/index.html" target="_blank"><font color="red"><b>上网宝典</b></font></a>
</td><td><a href="http://www.chinaitpower.com/2005September/2005-09-13/Design/Image/CorelDraw/index.html" target="_blank">CorelDraw</a>
</td><td><a href="http://www.chinaitpower.com/2005September/2005-09-13/Net/xieyi/index.html" target="_blank">协议大全</a>
</td><td><a href="http://www.chinaitpower.com/2005September/2005-09-13/Net/Safe/index.html" target="_blank">网络安全</a>
</td><td><a href="http://www.chinaitpower.com/2005September/2005-09-13/RenZ/MicroSoft/index.html" target="_blank">微软认证</a>
</td></tr><tr>
<td colspan="12"><b>硬件维护</b>
<a href="http://www.chinaitpower.com/2005September/2005-09-13/hardwarerepair/cpu/index.html" target="_blank">CPU</a>
<a href="http://www.chinaitpower.com/2005September/2005-09-13/hardwarerepair/mainboard/index.html" target="_blank">主板</a>
<a href="http://www.chinaitpower.com/2005September/2005-09-13/hardwarerepair/harddisk/index.html" target="_blank">硬盘</a>
<a href="http://www.chinaitpower.com/2005September/2005-09-13/hardwarerepair/memory/index.html" target="_blank">内存</a>
<a href="http://www.chinaitpower.com/2005September/2005-09-13/hardwarerepair/displaycard/index.html" target="_blank">显卡</a>
<a href="http://www.chinaitpower.com/2005September/2005-09-13/hardwarerepair/display/index.html" target="_blank">显示器</a>
<a href="http://www.chinaitpower.com/2005September/2005-09-13/hardwarerepair/mousekeyboard/index.html" target="_blank">键盘鼠标</a>
<a href="http://www.chinaitpower.com/2005September/2005-09-13/hardwarerepair/sound/index.html" target="_blank">声卡音箱</a>
<a href="http://www.chinaitpower.com/2005September/2005-09-13/hardwarerepair/print/index.html" target="_blank">打印机</a>
<a href="http://www.chinaitpower.com/2005September/2005-09-13/hardwarerepair/power/index.html" target="_blank">机箱电源</a>
<a href="http://www.chinaitpower.com/2005September/2005-09-13/hardwarerepair/BIOS/index.html" target="_blank">BIOS</a>
<a href="http://www.chinaitpower.com/2005September/2005-09-13/hardwarerepair/netcard/index.html" target="_blank">网卡</a>
<a href="http://www.chinaitpower.com/2005September/2005-09-13/Dev/Programme/Net/CCCC/index.html" target="_blank"><font color="red"><b>C#</b></font></a>
<a href="http://www.chinaitpower.com/2005September/2005-09-13/Dev/Programme/Java/index.html" target="_blank"><font color="blue"><b>Java</b></font></a>
<a href="http://www.chinaitpower.com/2005September/2005-09-13/Dev/Programme/Delphi/index.html" target="_blank"><font color="green"><b>Delphi</b></font></a>
<a href="http://www.chinaitpower.com/2005September/2005-09-13/Dev/Programme/VS/index.html" target="_blank"><font color="green"><b>vs.net2005</b></font></a>
</td></tr></tbody></table>
</td>
</tr>
<tr>
<td bgcolor="#8b7e66" height="4"></td>
</tr>
</tbody></table>
<table class="border2" align="center" border="0" cellpadding="0" cellspacing="0" width="760">
<tbody><tr><td bgcolor="#ffffff" height="25"> 当前位置:> <a class="nowplace" href="http://www.chinaitpower.com/System/index.html">操作系统</a> > <a class="nowplace" href="http://www.chinaitpower.com/System/unix/index.html">Unix高级技术</a> </td></tr>
<tr><td height="10"></td></tr><tr>
<td align="center"><b>[转贴]Makefile解读</b>
</td>
</tr>
<tr><td bgcolor="#d6d6d6" height="1"></td></tr>
<tr><td align="center" bgcolor="#f1f1f1" height="25">
作者:<font color="#0e3e92">未知</font>
时间:<font color="#0e3e92">2005-09-13 18:55</font>
出处:<font color="#0e3e92">ChinaUnix.net</font>
责编:<font color="#0e3e92">chinaitpower</font>
</td></tr><tr><td bgcolor="#d6d6d6" height="1"></td></tr>
<tr><td bgcolor="#ffffff" height="25"> 摘要:[转贴]Makefile解读</td></tr>
<tr><td bgcolor="#d6d6d6" height="1"></td></tr>
</tbody></table>
<table class="border2" align="center" bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" width="760">
<tbody><tr><td align="center" height="25">
<table width="95%">
<tbody><tr><td colspan="9" align="center"><script language="JavaScript" src="196570_files/headad.js"></script></td></tr>
<tr><td bgcolor="#d6d6d6" height="1"></td></tr>
<tr>
<td><table align="left" border="0">
<tbody><tr>
<td>
<iframe src="196570_files/ad.htm" border="0" framespacing="0" marginheight="1" marginwidth="1" noresize="" vspace="0" frameborder="0" height="280" scrolling="no" width="336"></iframe>
</td>
</tr>
</tbody></table><br>
原文出自:http://www.linuxforum.net
<br>作者:jkl
<br>
<br>==========================================
<br>Makefile 初探
<br>==========================================
<br>Linux的内核配置文件有两个,一个是隐含的.config文件,嵌入到主Makefile中;另一个是
include/linux/autoconf.h,嵌入到各个c源文件中,它们由make config、make
menuconfig、make xconfig这些过程创建。几乎所有的源文件都会通过linux/config.h而嵌入
autoconf.h,如果按照通常方法建立文件依赖关系(.depend),只要更新过autoconf.h,就会造成所有源代码的重新编绎。
<br>
<br>为了优化make过程,减少不必要的重新编绎,Linux开发了专用的mkdep工具,用它来取代gcc来生成.depend文件。mkdep在
处理源文件时,忽略linux/config.h这样的头文件,识别源文件宏指令中具有"CONFIG_"特征的行。例如,如果有
"#ifdef CONFIG_SMP"这样的行,它就会在.depend文件中输出$(wildcard
/usr/src/linux/include/config/smp.h)。
<br>
<br>include/config/下的文件是另一个工具split-include从autoconf.h中生成,它利用autoconf.h中的
CONFIG_标记,生成与mkdep相对应的文件。例如,如果autoconf.h中有"#undef CONFIG_SMP"这一行,它就
生成include/config/smp.h文件,内容为"#undef CONFIG_SMP"。这些文件名只在.depend文件中出
现,内核源文件是不会嵌入它们的。每配置一次内核,运行split-include一次。split-include会检查旧的子文件的内容,确定是不是
要更新它们。这样,不管autoconf.h修改日期如何,只要其配置不变,make就不会重新编绎内核。
<br>
<br>如果系统的编绎选项发生了变化,Linux也能进行增量编绎。为了做到这一点,make每编绎一个源文件时生成一个flags文件。例如编绎
sched.c时,会在相同的目录下生成隐含的.sched.o.flags文件。它是Makefile的一个片断,当make进入某个子目录编绎时,会
搜索其中的flags文件,将它们嵌入到Makefile中。这些flags代码测试当前的编绎选项与原来的是不是相同,如果相同,就将自已对应的目标文
件加入FILES_FLAGS_UP_TO_DATE列表,然后,系统从编绎对象表中删除它们,得到FILES_FLAGS_CHANGED列表,最后,
将它们设为目标进行更新。
<br>
<br>下一步准备逐步深入的剖析Makefile代码。
<br>
<br>==========================================
<br>Makefile解读之二: sub-make
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -