什么是 Makefile.am 和 Makefile.in?
这两个文件多出现在开源项目中。
它们的用途是什么?它们如何工作?
These two files are mostly seen in open source projects.
What are they for, and how do they work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Makefile.am
是程序员定义的文件,由automake
使用来生成Makefile.in
文件(.am< /code> 代表automake)。
通常在源 tarball 中看到的
configure
脚本将使用Makefile.in
生成Makefile
。configure
脚本本身是从程序员定义的文件生成的,该文件名为configure.ac
或configure.in
(已弃用)。我更喜欢.ac
(用于 autoconf),因为它与生成的Makefile.in
文件不同这样我就可以拥有诸如make dist-clean
之类的规则,它运行rm -f *.in
。由于它是生成的文件,因此通常不会存储在 Git、SVN、Mercurial 或 CVS 等修订系统中,而是存储在.ac
文件中。详细了解 GNU Autotools。
了解
make
和Makefile
首先,然后了解automake
,autoconf
、libtool
等。Makefile.am
is a programmer-defined file and is used byautomake
to generate theMakefile.in
file (the.am
stands for automake).The
configure
script typically seen in source tarballs will use theMakefile.in
to generate aMakefile
.The
configure
script itself is generated from a programmer-defined file named eitherconfigure.ac
orconfigure.in
(deprecated). I prefer.ac
(for autoconf) since it differentiates it from the generatedMakefile.in
files and that way I can have rules such asmake dist-clean
which runsrm -f *.in
. Since it is a generated file, it is not typically stored in a revision system such as Git, SVN, Mercurial or CVS, rather the.ac
file would be.Read more on GNU Autotools.
Read about
make
andMakefile
first, then learn aboutautomake
,autoconf
,libtool
, etc.简单示例
无耻地改编自:http: //www.gnu.org/software/automake/manual/html_node/Creating-amhello.html 并在 Ubuntu 14.04 Automake 1.14.1 上进行测试。
Makefile.am
README.md
configure.ac
src/Makefile.am
src/main.c
用法
此输出:
注释
autoreconf --install
生成几个应由 Git 跟踪的模板文件,包括 <代码>Makefile.in。只需要第一次运行即可。make install
安装:/usr/local/bin
README.md
到/usr/local/share/doc/automake_hello_world
在 GitHub 上供您尝试它出来了。
Simple example
Shamelessly adapted from: http://www.gnu.org/software/automake/manual/html_node/Creating-amhello.html and tested on Ubuntu 14.04 Automake 1.14.1.
Makefile.am
README.md
configure.ac
src/Makefile.am
src/main.c
Usage
This outputs:
Notes
autoreconf --install
generates several template files which should be tracked by Git, includingMakefile.in
. It only needs to be run the first time.make install
installs:/usr/local/bin
README.md
to/usr/local/share/doc/automake_hello_world
On GitHub for you to try it out.
DEVELOPER 运行
autoconf
和automake
:(安装程序稍后将运行以生成Makefile)
(配置稍后将读取以生成Makefile)
安装程序运行
configure
、make
和sudo make install
:输入/输出映射
下面的符号大致为: 输入 -->节目-->输出
DEVELOPER 运行这些:
configure.ac -> autoconf -> 配置(脚本)--- (*.ac = autoconf)
configure.in --> autoconf -> configure(脚本)---(
configure.in
已弃用。使用configure.ac)Makefile.am -> automake -> Makefile.in ----------- (*.am = automake)
INSTALLER 运行这些:
Makefile.in -> 配置 -> Makefile(*.in = input 文件)
Makefile -> 制作 ----------> (将新软件放入您的下载或临时目录中)
Makefile -> 进行安装 -> (将新软件放入系统目录中)
“autoconf是M4宏的可扩展包,它生成shell脚本来自动配置软件源代码包。这些脚本可以使包适应多种类UNIX系统无需用户手动干预,Autoconf 从模板文件创建包的配置脚本,以 M4 宏调用的形式列出包可以使用的操作系统功能。”
“automake是一个自动生成符合GNU编码标准的Makefile.in文件的工具。Automake需要使用Autoconf。”
手册:
GNU AutoTools(这方面的权威手册)
m4 (由 autoconf 使用)
<强>autoconf
automake
免费在线教程:
示例:
用于构建 LibreOffice 的主要 configure.ac 代码超过 12k 行,(但子文件夹中还有 57 个其他 configure.ac 文件.)
由此我生成的 configure 代码超过 41k 行。
而 Makefile.in 和 < makefile 都只有 493 行代码。 (但是,子文件夹中还有 768 个 Makefile.in。)
DEVELOPER runs
autoconf
andautomake
:(which the installer will later run to make the Makefile)
(which configure will later read to make the Makefile)
INSTALLER runs
configure
,make
andsudo make install
:INPUT/OUTPUT MAP
Notation below is roughly: inputs --> programs --> outputs
DEVELOPER runs these:
configure.ac -> autoconf -> configure (script) --- (*.ac = autoconf)
configure.in --> autoconf -> configure (script) --- (
configure.in
depreciated. Use configure.ac)Makefile.am -> automake -> Makefile.in ----------- (*.am = automake)
INSTALLER runs these:
Makefile.in -> configure -> Makefile (*.in = input file)
Makefile -> make ----------> (puts new software in your downloads or temporary directory)
Makefile -> make install -> (puts new software in system directories)
"autoconf is an extensible package of M4 macros that produce shell scripts to automatically configure software source code packages. These scripts can adapt the packages to many kinds of UNIX-like systems without manual user intervention. Autoconf creates a configuration script for a package from a template file that lists the operating system features that the package can use, in the form of M4 macro calls."
"automake is a tool for automatically generating Makefile.in files compliant with the GNU Coding Standards. Automake requires the use of Autoconf."
Manuals:
GNU AutoTools (The definitive manual on this stuff)
m4 (used by autoconf)
autoconf
automake
Free online tutorials:
Example:
The main configure.ac used to build LibreOffice is over 12k lines of code, (but there are also 57 other configure.ac files in subfolders.)
From this my generated configure is over 41k lines of code.
And while the Makefile.in and Makefile are both only 493 lines of code. (But, there are also 768 more Makefile.in's in subfolders.)
参考 :
Makefile.am -- automake 的用户输入文件
configure.in -- autoconf 的用户输入文件
autoconf 从 configure.in 生成配置
automake 从 Makefile.am 生成 Makefile.in
configure 从 Makefile 生成 Makefile Makefile.in
例如:
reference :
Makefile.am -- a user input file to automake
configure.in -- a user input file to autoconf
autoconf generates configure from configure.in
automake gererates Makefile.in from Makefile.am
configure generates Makefile from Makefile.in
For ex: