makefile参考手册

时间:2017-05-27 13:08:22
【文件属性】:

文件名称:makefile参考手册

文件大小:2.9MB

文件格式:PDF

更新时间:2017-05-27 13:08:22

makefile

GNU make中文手册.....................................................................................................................1 ver - 3.8.......................................................................................................................................1 第一章:概述...............................................................................................................................7 1.1 概述.................................................................................................................................7 1.2 准备知识..........................................................................................................................8 第二章 GNU make 介绍.............................................................................................................9 2 GNU make 介绍....................................................................................................................9 2.1 Makefile简介..................................................................................................................10 2.2 Makefile规则介绍...........................................................................................................11 2.3 简单的示例.....................................................................................................................12 2.4 make如何工作...............................................................................................................13 2.5 指定变量........................................................................................................................15 2.6 自动推导规则.................................................................................................................16 2.7 另类风格的makefile.......................................................................................................17 2.8 清除工作目录过程文件...................................................................................................18 第三章:Makefile 总述..............................................................................................................20 3 Makefile总述........................................................................................................................20 3.1 Makefile的内容...............................................................................................................20 3.2 makefile文件的命名.......................................................................................................21 3.3 包含其它makefile文件....................................................................................................22 3.4 变量 MAKEFILES..........................................................................................................24 3.5 变量 MAKEFILE_LIST..................................................................................................26 3.6 其他特殊变量.................................................................................................................26 3.7 makefile文件的重建.......................................................................................................27 3.8 重载另外一个makefile....................................................................................................28 3.9 make如何解析makefile文件...........................................................................................30 3.9.1 变量取值..................................................................................................................30 3.9.2 条件语句..................................................................................................................31 3.9.3 规则的定义...............................................................................................................31 3.10 总结...............................................................................................................................31 第四章:Makefile的规则............................................................................................................33 4 Makefile规则........................................................................................................................33 4.1 一个例子........................................................................................................................33 4.2 规则语法........................................................................................................................34 4.3 依赖的类型.....................................................................................................................35 4.4 文件名使用通配符..........................................................................................................36 4.4.1 统配符使用举例........................................................................................................37 4.4.2 通配符存在的缺陷....................................................................................................38 4.4.3 函数wildcard............................................................................................................38 4.5 目录搜寻........................................................................................................................39 4.5.1 一般搜索(变量VPATH)........................................................................................39 4.5.2 选择性搜索(关键字vpath)....................................................................................40 4.5.3 目录搜索的机制........................................................................................................41 4.5.4 命令行和搜索目录....................................................................................................44 4.5.5 隐含规则和搜索目录.................................................................................................44 4.5.6 库文件和搜索目录....................................................................................................45 4.6 Makefile伪目标...............................................................................................................46 4.7 强制目标(没有命令或依赖的规则).............................................................................50 4.8 空目标文件.....................................................................................................................50 4.9 Makefile的特殊目标.......................................................................................................51 4.10 多目标............................................................................................................................54 4.11 多规则目标.....................................................................................................................55 4.12 静态模式........................................................................................................................56 4.12.1 静态模式规则的语法.......................................................................................56 4.12.2 静态模式和隐含规则.......................................................................................58 4.13 双冒号规则.....................................................................................................................59 4.14 自动产生依赖.................................................................................................................60 第五章:规则的命令..................................................................................................................63 5 为规则书写命令...................................................................................................................63 5.1 命令回显........................................................................................................................63 5.2 命令的执行.....................................................................................................................64 5.3 并发执行命令.................................................................................................................65 5.4 命令执行的错误..............................................................................................................67 5.5 中断make的执行............................................................................................................68 5.6 make的递归执行............................................................................................................69 5.6.1 变量MAKE...............................................................................................................70 5.6.2 变量和递归...............................................................................................................71 5.6.3 命令行选项和递归....................................................................................................75 5.6.4 -w选项......................................................................................................................77 5.7 定义命令包.....................................................................................................................78 5.8 空命令............................................................................................................................80 第六章:Makefile中的变量.........................................................................................................81 6 使用变量..............................................................................................................................81 6.1 变量的引用.....................................................................................................................82 6.2 两种变量定义(赋值)...................................................................................................83 6.2.1 递归展开式变量........................................................................................................83 6.2.2 直接展开式变量........................................................................................................85 6.2.3 定义一个空格...........................................................................................................86 6.2.4 “?=”操作符.............................................................................................................87 6.3 变量的高级用法..............................................................................................................88 6.3.1 变量的替换引用........................................................................................................88 6.3.2 变量的套嵌引用........................................................................................................88 6.4 变量取值........................................................................................................................92 6.5 如何设置变量.................................................................................................................93 6.6 追加变量值.....................................................................................................................94 6.7 override 指示符.............................................................................................................96 6.8 多行定义........................................................................................................................98 6.9 系统环境变量.................................................................................................................99 6.10 目标指定变量...............................................................................................................101 6.11 模式指定变量...............................................................................................................103 第七章:Makefile的条件执行...................................................................................................104 7 Makefile的条件判断...........................................................................................................104 7.1 一个例子......................................................................................................................104 7.2 条件判断的基本语法....................................................................................................105 7.3 标记测试的条件语句....................................................................................................108 第八章:make的内嵌函数........................................................................................................109 8 make的函数.......................................................................................................................109 8.1 函数的调用语法............................................................................................................109 8.2 文本处理函数...............................................................................................................110 8.2.1 $(subst FROM,TO,TEXT).....................................................................................110 8.2.2 $(patsubst PATTERN,REPLACEMENT,TEXT)...................................................110 8.2.3 $(strip STRINT).....................................................................................................112 8.2.4 $(findstring FIND,IN)............................................................................................112 8.2.5 $(filter PATTERN…,TEXT)...................................................................................112 8.2.6 $(filter-out PATTERN...,TEXT).............................................................................113 8.2.7 $(sort LIST)...........................................................................................................113 8.2.8 $(word N,TEXT)....................................................................................................114 8.2.9 $(wordlist S,E,TEXT)............................................................................................114 8.2.10 $(words TEXT)............................................................................................114 8.2.11 $(firstword NAMES…)................................................................................115 8.3 文件名处理函数............................................................................................................115 8.3.1 $(dir NAMES…)....................................................................................................115 8.3.2 $(notdir NAMES…)...............................................................................................116 8.3.3 $(suffix NAMES…)...............................................................................................116 8.3.4 $(basename NAMES…).......................................................................................117 8.3.5 $(addsuffix SUFFIX,NAMES…)...........................................................................117 8.3.6 $(addprefix PREFIX,NAMES…)...........................................................................118 8.3.7 $(join LIST1,LIST2)...............................................................................................118 8.3.8 $(wildcard PATTERN)..........................................................................................119 8.4 foreach 函数................................................................................................................119 8.5 if 函数..........................................................................................................................120 8.6 call函数........................................................................................................................121 8.7 value函数.....................................................................................................................123 8.8 eval函数.......................................................................................................................124 8.9 origin函数.....................................................................................................................125 8.10 shell函数......................................................................................................................127 8.11 make的控制函数..........................................................................................................128 8.11.1 $(error TEXT…)...........................................................................................128 8.11.2 $(warning TEXT…)......................................................................................129 第九章:执行make..................................................................................................................130 9 执行make..........................................................................................................................130 9.1 指定makefile文件.........................................................................................................130 9.2 指定终极目标...............................................................................................................131 9.3 替代命令的执行............................................................................................................133 9.4 防止特定文件重建........................................................................................................135 9.5 替换变量定义...............................................................................................................136 9.6 使用make进行编译测试...............................................................................................137 9.7 Tmake的命令行选项....................................................................................................138 第十章:make的隐含规则........................................................................................................143 10 使用隐含规则...............................................................................................................143 10.1 隐含规则的使用............................................................................................................143 10.2 make的隐含规则一览...................................................................................................145 10.3 隐含变量......................................................................................................................148 10.3.1 代表命令的变量............................................................................................149 10.3.2 命令参数的变量............................................................................................150 10.4 make隐含规则链..........................................................................................................151 10.5 模式规则......................................................................................................................153 10.5.1 模式规则介绍................................................................................................153 10.5.2 模式规则示例................................................................................................155 10.5.3 自动化变量....................................................................................................156 T10.5.4 T模式的匹配.................................................................................................159 10.5.5 万用规则.......................................................................................................160 10.5.6 重建内嵌隐含规则.........................................................................................161 10.6 缺省规则......................................................................................................................162 10.7 后缀规则......................................................................................................................162 10.8 隐含规则搜索算法........................................................................................................164 第十一章:使用make更新静态库文件......................................................................................166 11 更新静态库文件............................................................................................................166 11.1 库成员作为目标............................................................................................................166 11.2 静态库的更新...............................................................................................................167 11.2.1 更新静态库的符号索引表..............................................................................168 11.3 make静态库的注意事项...............................................................................................168 11.4 静态库的后缀规则........................................................................................................169 第十二章 : GNU make的特点...............................................................................................170 12 GNU make的一些特点.................................................................................................170 12.1 源自System v的特点....................................................................................................170 12.2 源自其他版本的特点....................................................................................................171 12.3 GNU make自身的特点.................................................................................................172 第十三章 和其它版本的兼容....................................................................................................174 13 不兼容性......................................................................................................................174 第十四章 Makefile的约定........................................................................................................176 14 书写约定......................................................................................................................176 14.1 基本的约定...................................................................................................................176 14.2 规则命令行的约定........................................................................................................178 14.3 代表命令变量...............................................................................................................179 14.4 安装目录变量...............................................................................................................180 14.5 Makefile的标准目标名..................................................................................................185 14.6 安装命令分类...............................................................................................................190 第十五章 make的常见错误信息...............................................................................................193 15 make产生的错误信息...................................................................................................193 附录1:关键字索引..................................................................................................................196 GNU make可识别的指示符:..............................................................................................196 GNU make函数:...............................................................................................................197 GNU make的自动化变量.....................................................................................................197 GNU make环境变量............................................................................................................198 后序.........................................................................................................................................198


网友评论

  • 比较全面,工作中帮助很大
  • 比较详细地介绍了makefile,可以当作字典使用