什么是 Makefile.am 和 Makefile.in?

发布于 2024-08-26 10:16:58 字数 47 浏览 4 评论 0原文

这两个文件多出现在开源项目中。

它们的用途是什么?它们如何工作?

These two files are mostly seen in open source projects.

What are they for, and how do they work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

蓬勃野心 2024-09-02 10:16:58

Makefile.am 是程序员定义的文件,由 automake 使用来生成 Makefile.in 文件(.am< /code> 代表automake)。
通常在源 tarball 中看到的 configure 脚本将使用 Makefile.in 生成 Makefile

configure 脚本本身是从程序员定义的文件生成的,该文件名为configure.acconfigure.in(已弃用)。我更喜欢 .ac (用于 autoconf),因为它与生成的 Makefile.in 文件不同这样我就可以拥有诸如 make dist-clean 之类的规则,它运行 rm -f *.in 。由于它是生成的文件,因此通常不会存储在 Git、SVN、Mercurial 或 CVS 等修订系统中,而是存储在 .ac 文件中。

详细了解 GNU Autotools
了解 makeMakefile 首先,然后了解 automake, autoconflibtool 等。

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.

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.

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

握住你手 2024-09-02 10:16:58

简单示例

无耻地改编自: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], [[email protected]])
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

bin_PROGRAMS = autotools_hello_world
autotools_hello_world_SOURCES = main.c

src/main.c

#include <config.h>
#include <stdio.h>

int main (void) {
  puts ("Hello world from " PACKAGE_STRING);
  return 0;
}

用法

autoreconf --install
mkdir build
cd build
../configure
make
sudo make install
autotools_hello_world
sudo make uninstall

此输出:

Hello world from automake_hello_world 1.0

注释

  • 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

SUBDIRS = src
dist_doc_DATA = README.md

README.md

Some doc.

configure.ac

AC_INIT([automake_hello_world], [1.0], [[email protected]])
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

bin_PROGRAMS = autotools_hello_world
autotools_hello_world_SOURCES = 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. It only needs to be run the first time.

  • make install installs:

    • the binary to /usr/local/bin
    • README.md to /usr/local/share/doc/automake_hello_world

On GitHub for you to try it out.

我的鱼塘能养鲲 2024-09-02 10:16:58

DEVELOPER 运行 autoconfautomake

  1. autoconf -- 创建可交付的配置脚本
    (安装程序稍后将运行以生成Makefile
  1. automake - 创建可发布的 Makefile.in数据文件
    配置稍后将读取以生成Makefile

安装程序运行 configuremakesudo 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


输入/输出映射

下面的符号大致为: 输入 -->节目-->输出

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。”

手册:

免费在线教程:


示例:

用于构建 LibreOffice 的主要 configure.ac 代码超过 12k 行,(但子文件夹中还有 57 个其他 configure.ac 文件.)

由此我生成的 configure 代码超过 41k 行。

Makefile.in 和 < makefile 都只有 493 行代码。 (但是,子文件夹中还有 768 个 Makefile.in。)

DEVELOPER runs autoconf and automake:

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

INSTALLER runs configure, make and 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


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:

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.)

忘东忘西忘不掉你 2024-09-02 10:16:58

参考 :

Makefile.am -- automake 的用户输入文件

configure.in -- autoconf 的用户输入文件


autoconf 从 configure.in 生成配置

automake 从 Makefile.am 生成 Makefile.in

configure 从 Makefile 生成 Makefile Makefile.in

例如:

$]
configure.in Makefile.in
$] sudo autoconf
configure configure.in Makefile.in ... 
$] sudo ./configure
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:

$]
configure.in Makefile.in
$] sudo autoconf
configure configure.in Makefile.in ... 
$] sudo ./configure
Makefile Makefile.in
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文