Skip to Content
C语言核心技术(原书第2版)
book

C语言核心技术(原书第2版)

by Peter Prinz, Tony Crawford
August 2017
Intermediate to advanced
798 pages
17h 44m
Chinese
China Machine Press
Content preview from C语言核心技术(原书第2版)
使用
make
构建
C
程序
|
699
使用
make
构建
C
程序
件就必须被重新构建——对象文件是执行文件的依赖条件(
prerequisite
)。同时,对
象文件又是中间目标(
intermediate target
),如果源文件和头文件发生变化,对象文件
就必须被重新编译。(因此,可执行文件间接依赖源文件。
make
能够很好地管理这种
依赖关系链,即便这些关系可能非常复杂。)每个目标的规则通常包含一个或多个命
令(
command
),称为命令脚本(
command script
),
make
会执行命令脚本,以构建目
标。例如,构建可执行文件的规则需要运行链接器,而构建对象文件的规则需要运行预
处理器和编译器。换句话说,规则的依赖条件描述“何时”构建目标,命令脚本则描述
“如何”构建目标。
20.2 Makefile
make
程序对于它的规则具有特殊的语法。而且,通常来说,对于项目中所有想采用
make
来管理的操作需要收集到一个文件中,以便
make
程序读取执行。命令行选项-
f
filename
告知
make
,哪些文件包含想要
make
应用的规则。通常会省略该选项,
make
直接
寻找以
makefile
作为默认名称的文件;如果指定了
-f
filename
选项但搜索失败,则使用
Makefile
注
1
文件。
当阅读
makefile
时,千万要记住,它们不是简单地按顺序依次执行的脚本。首先,
make
会先分析整个
makefile
,构建出目标与它们的依赖条件之间的依赖关系树,然后通过迭
代处理依赖树来构建所希望的目标。
除了包含规则以外,
makefile ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

算法精讲视频课程:24篇系列讲座

算法精讲视频课程:24篇系列讲座

罗伯特·塞奇威克, 凯文·韦恩(Kevin Wayne)

Publisher Resources

ISBN: 9787111562207