[英]What are Makefile.am and Makefile.in?
These two files are mostly seen in open source projects.这两个文件多见于开源项目。
What are they for, and how do they work?它们是做什么用的,它们是如何工作的?
Makefile.am
is a programmer-defined file and is used by automake
to generate the Makefile.in
file (the .am
stands for a uto m ake). Makefile.am
是一个程序员定义的文件,并且用于通过automake
以生成Makefile.in
文件( .am
代表一个UTO米AKE)。 The configure
script typically seen in source tarballs will use the Makefile.in
to generate a Makefile
.通常在源 tarball 中看到的configure
脚本将使用Makefile.in
生成Makefile
。
The configure
script itself is generated from a programmer-defined file named either configure.ac
or configure.in
(deprecated). configure
脚本本身是从名为configure.ac
或configure.in
(已弃用)的程序员定义的文件生成的。 I prefer .ac
(for a uto c onf) since it differentiates it from the generated Makefile.in
files and that way I can have rules such as make dist-clean
which runs rm -f *.in
.我喜欢.ac
(对于反对派çONF),因为它从产生区别它Makefile.in
文件,这样我可以有规则,如make dist-clean
它运行rm -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.由于它是生成的文件,因此通常不会存储在 Git、SVN、Mercurial 或 CVS 等修订系统中,而是.ac
文件。
Read more on GNU Autotools .阅读更多关于GNU Autotools 的信息。 Read about make
and Makefile
first, then learn about automake
, autoconf
, libtool
, etc.首先阅读make
和Makefile
,然后了解automake
、 autoconf
、 libtool
等。
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.无耻地改编自: http : //www.gnu.org/software/automake/manual/html_node/Creating-amhello.html并在 Ubuntu 14.04 Automake 1.14.1 上测试。
Makefile.am生成文件
SUBDIRS = src
dist_doc_DATA = README.md
README.md自述文件
Some doc.
configure.ac配置文件
AC_INIT([automake_hello_world], [1.0], [bug-automake@gnu.org])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_PROG_CC
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([
Makefile
src/Makefile
])
AC_OUTPUT
src/Makefile.am源代码/Makefile.am
bin_PROGRAMS = autotools_hello_world
autotools_hello_world_SOURCES = main.c
src/main.c src/main.c
#include <config.h>
#include <stdio.h>
int main (void) {
puts ("Hello world from " PACKAGE_STRING);
return 0;
}
Usage用法
autoreconf --install
mkdir build
cd build
../configure
make
sudo make install
autotools_hello_world
sudo make uninstall
This outputs:这输出:
Hello world from automake_hello_world 1.0
Notes笔记
autoreconf --install
generates several template files which should be tracked by Git, including Makefile.in
. autoreconf --install
生成几个应该由 Git 跟踪的模板文件,包括Makefile.in
。 It only needs to be run the first time.它只需要第一次运行。
make install
installs: make install
安装:
/usr/local/bin
二进制文件到/usr/local/bin
README.md
to /usr/local/share/doc/automake_hello_world
README.md
到/usr/local/share/doc/automake_hello_world
On GitHub for you to try it out. 在 GitHub 上供您试用。
autoconf
and automake
:开发人员运行autoconf
和automake
:configure
, make
and sudo make install
:安装程序运行configure
, make
和sudo make install
:./configure # Creates Makefile (from Makefile.in).
make # Creates the application (from the Makefile just created).
sudo make install # Installs the application
# Often, by default its files are installed into /usr/local
Notation below is roughly: inputs --> programs --> outputs下面的符号大致是:输入 --> 程序 --> 输出
DEVELOPER runs these:开发人员运行这些:
configure.ac -> autoconf -> configure (script) --- (*. ac = a uto c onf) configure.ac - >的autoconf - >配置(脚本)---(* AC =一个UTOÇONF。)
configure.in --> autoconf -> configure (script) --- ( configure.in
depreciated. Use configure.ac) configure.in --> autoconf -> configure (script) --- ( configure.in
depreciated. Use configure.ac)
Makefile.am -> automake -> Makefile.in ----------- (*. am = a uto m ake) Makefile.am - >的automake - > Makefile.in -----------(。*是= A UTO米AKE)
INSTALLER runs these:安装程序运行这些:
Makefile.in -> configure -> Makefile (*. in = in put file) Makefile.in - >配置- (。*在放文件=)>的Makefile
Makefile -> make ----------> (puts new software in your downloads or temporary directory) Makefile -> make ---------->(将新软件放在您的下载或临时目录中)
Makefile -> make install -> (puts new software in system directories) Makefile -> make install ->(将新软件放入系统目录)
" 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." " autoconf是一个可扩展的 M4 宏包,它生成 shell 脚本来自动配置软件源代码包。这些脚本可以使包适应多种类 UNIX 系统,而无需用户手动干预。Autoconf 从一个包创建配置脚本。以 M4 宏调用的形式列出软件包可以使用的操作系统功能的模板文件。”
" automake is a tool for automatically generating Makefile.in files compliant with the GNU Coding Standards. Automake requires the use of Autoconf." “ automake是一种自动生成符合 GNU 编码标准的 Makefile.in 文件的工具。Automake 需要使用 Autoconf。”
Manuals:手册:
GNU AutoTools (The definitive manual on this stuff) GNU AutoTools (这方面的权威手册)
Free online tutorials:免费在线教程:
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.)用于构建 LibreOffice 的主要configure.ac代码超过 12k 行,(但在子文件夹中还有 57 个其他 configure.ac 文件。)
From this my generated configure is over 41k lines of code.由此我生成的配置超过 41k 行代码。
And while the Makefile.in and Makefile are both only 493 lines of code.而Makefile.in和Makefile都只有 493 行代码。 (But, there are also 768 more Makefile.in's in subfolders.) (但是,子文件夹中还有 768 个 Makefile.in。)
Makefile.am -- a user input file to automake Makefile.am -- automake 的用户输入文件
configure.in -- a user input file to autoconf configure.in -- 自动配置的用户输入文件
autoconf generates configure from configure.in autoconf 从 configure.in 生成配置
automake gererates Makefile.in from Makefile.am automake 从 Makefile.am 生成 Makefile.in
configure generates Makefile from Makefile.in configure 从 Makefile.in 生成 Makefile
For ex:例如:
$]
configure.in Makefile.in
$] sudo autoconf
configure configure.in Makefile.in ...
$] sudo ./configure
Makefile Makefile.in
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.