Makefile。我和Makefile.in吗?

时间:2021-12-18 13:51:37

These two files are mostly seen in open source projects.

这两个文件主要见于开放源码项目中。

What are they for, and how do they work?

他们是干什么的,他们是怎么工作的?

4 个解决方案

#1


311  

Makefile.am is a programmer-defined file and is used by automake to generate the Makefile.in file (the .am stands for automake). The configure script typically seen in source tarballs will use the Makefile.in to generate a Makefile.

Makefile。am是一个程序定义的文件,并由automake用于生成Makefile。在文件中(.am表示自动)。在源tarballs中通常看到的configure脚本将使用Makefile。生成一个Makefile。

The configure script itself is generated from a programmer-defined file named either configure.ac or configure.in (deprecated). I prefer .ac (for autoconf) 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. 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.

configure脚本本身是由一个名为configure的程序定义文件生成的。ac或配置。(弃用)。我更喜欢.ac(对于autoconf),因为它将它与生成的Makefile区分开来。在文件中,这样我就可以有规则,例如,可以运行rm -f *。由于它是一个生成的文件,所以它通常不会存储在一个修订系统中,例如Git、SVN、Mercurial或CVS,而不是.ac文件。

Read more on GNU Autotools. Read about make and Makefile first, then learn about automake, autoconf, libtool, etc.

阅读更多关于GNU自动工具。先阅读make和Makefile,然后学习automake、autoconf、libtool等。

#2


35  

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/automal/manual/html_node/creating -amhello.html中不知不觉地进行了修改,并在ubuntu14.04 Automake 1.14.1中进行了测试。

Makefile.am

Makefile.am

SUBDIRS = src
dist_doc_DATA = README.md

README.md

README.md

Some doc.

configure.ac

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

src / Makefile.am

bin_PROGRAMS = autotools_hello_world
autotools_hello_world_SOURCES = main.c

src/main.c

src / 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
autoconf_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. It only needs to be run the first time.

    autoreconf——安装生成几个模板文件,这些文件应该被Git跟踪,包括Makefile.in。它只需要第一次运行。

  • make install installs:

    使安装安装:

    • the binary to /usr/local/bin
    • 的二进制/usr/local/bin
    • README.md to /usr/local/share/doc/automake_hello_world
    • 自述文件。医学博士,/usr/local/share/doc/automake_hello_world

On GitHub for you to try it out.

在GitHub上你可以尝试一下。

#3


11  

reference :

参考:

Makefile.am -- a user input file to automake

Makefile。是一个用户输入文件到automake ?

configure.in -- a user input file to autoconf

配置。在——一个用户输入文件到autoconf。


autoconf generates configure from configure.in

autoconf从配置中生成配置。

automake gererates Makefile.in from Makefile.am

automake gererates Makefile。从Makefile.am

configure generates Makefile from Makefile.in

配置从Makefile中生成Makefile。

For ex:

为例:

$]
configure.in Makefile.in
$] sudo autoconf
configure configure.in Makefile.in ... 
$] sudo ./configure
Makefile Makefile.in

#4


3  

DEVELOPER runs these:

开发人员运行:

1) autoconf - creates shippable configure script (which the installer will run to make the Makefile)
2) automake - creates shippable Makefile.in (which configure will later read to make the Makefile)

1)autoconf -创建可交付的配置脚本(安装程序将运行以生成Makefile) 2) automake -创建可交付的Makefile。在(该配置稍后将读取以生成Makefile)

INSTALLER runs these:

安装程序运行:

1) ./configure - creates the Makefile (from Makefile.in).
2) make - creates the application (from the Makefile just created).
3) sudo make install - installs the application - By default the files are (often) installed into /usr/local.

1)./configure -创建Makefile(来自Makefile.)。2)make -创建应用程序(从刚刚创建的Makefile)。sudo安装-安装应用程序-默认情况下,文件(通常)安装在/usr/local中。


INPUTS -> PROGRAMS -> OUTPUTS:

输入->程序->输出:

DEVELOPER runs these:

开发人员运行:

configure.in -> autoconf -> configure (script) <---- Note! configure.in is depreciated.
configure.ac -> autoconf -> configure (script) <---- Now use configure.ac / (*.ac = autoconf)

配置。在> autoconf ->配置(脚本)<---注意!配置。在贬值。配置。ac -> autoconf ->配置(脚本)<——现在使用configure。ac /(*。ac = autoconf)

Makefile.am -> automake -> Makefile.in / (*.am = automake)

Makefile。am ->自动-> Makefile。/(*。我= automake)

INSTALLER runs these:

安装程序运行:

Makefile.in -> configure -> Makefile (*.in = input file)

Makefile。在->配置-> Makefile(*。在=输入文件)

Makefile -> make -> (the new software in your downloads or temporary directory)
Makefile -> make install -> (puts new software in system directory)

Makefile -> make ->(下载或临时目录中的新软件)Makefile ->进行安装->(将新软件放入系统目录)


"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是一个自动生成Makefile的工具。在符合GNU编码标准的文件中。Automake需要使用Autoconf。

Manuals:

手册:


Interesting facts:
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.
While the Makefile.in and Makefile are both only 493 lines of code.
(But, there are also 768 more Makefile.in's in subfolders.)

有趣的事实:主要配置。用于构建LibreOffice的ac有超过12k行代码,(但是还有57个其他配置。ac子文件夹中的文件)。由此我生成的配置超过了41k行代码。而Makefile。在Makefile中,只有493行代码。(但是,还有768个Makefile。在子文件夹)。

#1


311  

Makefile.am is a programmer-defined file and is used by automake to generate the Makefile.in file (the .am stands for automake). The configure script typically seen in source tarballs will use the Makefile.in to generate a Makefile.

Makefile。am是一个程序定义的文件,并由automake用于生成Makefile。在文件中(.am表示自动)。在源tarballs中通常看到的configure脚本将使用Makefile。生成一个Makefile。

The configure script itself is generated from a programmer-defined file named either configure.ac or configure.in (deprecated). I prefer .ac (for autoconf) 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. 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.

configure脚本本身是由一个名为configure的程序定义文件生成的。ac或配置。(弃用)。我更喜欢.ac(对于autoconf),因为它将它与生成的Makefile区分开来。在文件中,这样我就可以有规则,例如,可以运行rm -f *。由于它是一个生成的文件,所以它通常不会存储在一个修订系统中,例如Git、SVN、Mercurial或CVS,而不是.ac文件。

Read more on GNU Autotools. Read about make and Makefile first, then learn about automake, autoconf, libtool, etc.

阅读更多关于GNU自动工具。先阅读make和Makefile,然后学习automake、autoconf、libtool等。

#2


35  

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/automal/manual/html_node/creating -amhello.html中不知不觉地进行了修改,并在ubuntu14.04 Automake 1.14.1中进行了测试。

Makefile.am

Makefile.am

SUBDIRS = src
dist_doc_DATA = README.md

README.md

README.md

Some doc.

configure.ac

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

src / Makefile.am

bin_PROGRAMS = autotools_hello_world
autotools_hello_world_SOURCES = main.c

src/main.c

src / 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
autoconf_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. It only needs to be run the first time.

    autoreconf——安装生成几个模板文件,这些文件应该被Git跟踪,包括Makefile.in。它只需要第一次运行。

  • make install installs:

    使安装安装:

    • the binary to /usr/local/bin
    • 的二进制/usr/local/bin
    • README.md to /usr/local/share/doc/automake_hello_world
    • 自述文件。医学博士,/usr/local/share/doc/automake_hello_world

On GitHub for you to try it out.

在GitHub上你可以尝试一下。

#3


11  

reference :

参考:

Makefile.am -- a user input file to automake

Makefile。是一个用户输入文件到automake ?

configure.in -- a user input file to autoconf

配置。在——一个用户输入文件到autoconf。


autoconf generates configure from configure.in

autoconf从配置中生成配置。

automake gererates Makefile.in from Makefile.am

automake gererates Makefile。从Makefile.am

configure generates Makefile from Makefile.in

配置从Makefile中生成Makefile。

For ex:

为例:

$]
configure.in Makefile.in
$] sudo autoconf
configure configure.in Makefile.in ... 
$] sudo ./configure
Makefile Makefile.in

#4


3  

DEVELOPER runs these:

开发人员运行:

1) autoconf - creates shippable configure script (which the installer will run to make the Makefile)
2) automake - creates shippable Makefile.in (which configure will later read to make the Makefile)

1)autoconf -创建可交付的配置脚本(安装程序将运行以生成Makefile) 2) automake -创建可交付的Makefile。在(该配置稍后将读取以生成Makefile)

INSTALLER runs these:

安装程序运行:

1) ./configure - creates the Makefile (from Makefile.in).
2) make - creates the application (from the Makefile just created).
3) sudo make install - installs the application - By default the files are (often) installed into /usr/local.

1)./configure -创建Makefile(来自Makefile.)。2)make -创建应用程序(从刚刚创建的Makefile)。sudo安装-安装应用程序-默认情况下,文件(通常)安装在/usr/local中。


INPUTS -> PROGRAMS -> OUTPUTS:

输入->程序->输出:

DEVELOPER runs these:

开发人员运行:

configure.in -> autoconf -> configure (script) <---- Note! configure.in is depreciated.
configure.ac -> autoconf -> configure (script) <---- Now use configure.ac / (*.ac = autoconf)

配置。在> autoconf ->配置(脚本)<---注意!配置。在贬值。配置。ac -> autoconf ->配置(脚本)<——现在使用configure。ac /(*。ac = autoconf)

Makefile.am -> automake -> Makefile.in / (*.am = automake)

Makefile。am ->自动-> Makefile。/(*。我= automake)

INSTALLER runs these:

安装程序运行:

Makefile.in -> configure -> Makefile (*.in = input file)

Makefile。在->配置-> Makefile(*。在=输入文件)

Makefile -> make -> (the new software in your downloads or temporary directory)
Makefile -> make install -> (puts new software in system directory)

Makefile -> make ->(下载或临时目录中的新软件)Makefile ->进行安装->(将新软件放入系统目录)


"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是一个自动生成Makefile的工具。在符合GNU编码标准的文件中。Automake需要使用Autoconf。

Manuals:

手册:


Interesting facts:
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.
While the Makefile.in and Makefile are both only 493 lines of code.
(But, there are also 768 more Makefile.in's in subfolders.)

有趣的事实:主要配置。用于构建LibreOffice的ac有超过12k行代码,(但是还有57个其他配置。ac子文件夹中的文件)。由此我生成的配置超过了41k行代码。而Makefile。在Makefile中,只有493行代码。(但是,还有768个Makefile。在子文件夹)。