对配置脚本和 Makefile.in 感到困惑 [英] Confused about configure script and Makefile.in

查看:24
本文介绍了对配置脚本和 Makefile.in 感到困惑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在学习如何使用 autoconf/automake 工具链.我似乎对这里的工作流程有一个大致的了解 - 基本上你有一个 configure.ac 脚本,它生成一个可执行的 configure 文件.生成的 configure 脚本然后由最终用户执行以生成 Makefile,因此可以构建/安装程序.

I'm currently learning how to use the autoconf/automake toolchain. I seem to have a general understanding of the workflow here - basically you have a configure.ac script which generates an executable configure file. The generated configure script is then executed by the end user to generate Makefiles, so the program can be built/installed.

因此,典型最终用户的安装基本上是:

So the installation for a typical end-user is basically:

./configure
make
make install
make clean

好的,现在我感到困惑的地方是:

Okay, now here's where I'm confused:

作为开发人员,我注意到自动生成的配置脚本有时无法运行,并且会出现以下错误:

As a developer, I've noticed that the auto-generated configure script sometimes won't run, and will error with:

config.status: error: cannot find input file: `somedir/Makefile.in' 

这让我很困惑,因为我认为配置脚本应该生成Makefile.in.所以在谷歌上搜索一些答案,我发现这可以通过 autogen.sh 脚本来解决,该脚本基本上重置"了 autoconf 环境的状态.典型的 autogen.sh 脚本类似于:

This confuses me, because I thought the configure script is supposed to generate the Makefile.in. So Googling around for some answers, I've discovered that this can be fixed with an autogen.sh script, which basically "resets" the state of the autoconf environment. A typical autogen.sh script would be something like:

aclocal 
&& automake --add-missing 
&& autoconf

好吧好吧.但作为一个终生下载了无数 tarball 的最终用户,我从未必须使用 autogen.sh 脚本.我所做的只是解压缩 tarball,然后执行通常的 configure/make/make install/make clean 例程.

Okay fine. But as an end-user who's downloaded countless tarballs throughout my life, I've never had to use an autogen.sh script. All I did was uncompress the tarball, and do the usual configure/make/make install/make clean routine.

但是作为现在使用 autoconf的开发人员,除非您运行autogen,否则configure似乎实际上不会运行.sh 首先.所以我觉得这很令人困惑,因为我认为最终用户不应该运行 autogen.sh.

But as a developer who's now using autoconf, it seems that configure doesn't actually run unless you run autogen.sh first. So I find this very confusing, because I thought the end-user shouldn't have to run autogen.sh.

那么为什么我必须先运行 autogen.sh - 以便配置脚本找到 Makefile.in?为什么配置脚本不简单地生成它?

So why do I have to run autogen.sh first - in order for the configure script to find Makefile.in? Why doesn't the configure script simply generate it?

推荐答案

为了真正理解 autotools 实用程序,您必须记住它们来自哪里:它们来自一个开源世界,那里有 (a) 开发人员从源代码存储库(CVS、Git 等)工作并创建包含源代码的 tar 文件或类似文件并将该 tar 文件放在下载站点上,以及 (b) 获取源代码 tar 文件的最终用户,在他们的系统上编译该源代码并使用生成的二进制文件.显然,(a) 组的人也编译代码并使用生成的二进制文件,但 (b) 组的人通常没有或不需要 (a) 组的人需要的所有开发工具.

In order to really understand the autotools utilities you have to remember where they come from: they come from an open source world where there are (a) developers who are working from a source code repository (CVS, Git, etc.) and creating a tar file or similar containing source code and putting that tar file up on a download site, and (b) end-users who are getting the source code tar file, compiling that source code on their system and using the resulting binary. Obviously the folks in group (a) also compile the code and use the resulting binary, but the folks in group (b) don't have or need, often, all the tools for development that the folks in group (a) need.

因此,工具的使用是针对这种分裂的,即 (b) 组中的人无法访问 autoconf、automake 等.

So the use of the tools is geared towards this split, where the people in group (b) don't have access to autoconf, automake, etc.

在使用 autoconf 时,人们通常将 configure.ac 文件(输入到 autoconf)检入源代码管理,但不检入 autoconf 的输出,configure脚本(当然有些项目会检查 configure 脚本:这取决于你).

When using autoconf, people generally check in the configure.ac file (input to autoconf) into source control but do not check in the output of autoconf, the configure script (some projects do check in the configure script of course: it's up to you).

在使用 automake 时,人们通常检查 Makefile.am 文件(输入到 automake)但不检查 automake 的输出:Makefile.in.

When using automake, people generally check in the Makefile.am file (input to automake) but do not check in the output of automake: Makefile.in.

configure 脚本基本上会在您的系统中查看包可能需要或不需要的各种可选元素,可以在何处找到它们等.一旦找到此信息,它就可以使用它将各种 XXX.in 文件(通常但不仅限于 Makefile.in)转换为 XXX 文件(例如,Makefile).

The configure script basically looks at your system for various optional elements that the package may or may not need, where they can be found, etc. Once it finds this information, it can use it to convert various XXX.in files (typically, but not solely, Makefile.in) into XXX files (for example, Makefile).

所以步骤通常是这样的:编写 configure.acMakefile.am 并签入.要从源代码控制签出构建项目,请运行 autoconf从 configure.ac 生成 configure.运行 automake 从 Makefile.am 生成 Makefile.in.运行 configure 以从 Makefile.in 生成 Makefile.运行 make 来构建产品.

So the steps generally go like this: write configure.ac and Makefile.am and check them in. To build the project from source code control checkout, run autoconf to generate configure from configure.ac. Run automake to generate Makefile.in from Makefile.am. Run configure to generate Makefile from Makefile.in. Run make to build the product.

当你想发布源代码时(如果你正在开发一个发布源代码的开源产品),你运行 autoconf 和 automake,然后将源代码与 configureMakefile.in 文件,因此构建源代码版本的人只需要 make 和编译器,不需要任何自动工具.

When you want to release the source code (if you're developing an open source product that makes source code releases) you run autoconf and automake, then bundle up the source code with the configure and Makefile.in files, so that people building your source code release just need make and a compiler and don't need any autotools.

因为运行 autoconf 和 automake(和 libtool,如果你使用它)的顺序可能很棘手,所以像 autogen.sh 和 autoreconf 等脚本被签入源代码管理,供开发人员从源代码​​管理构建使用,但是从源代码发布 tar 文件等构建的人不需要/使用这些.

Because the order of running autoconf and automake (and libtool if you use it) can be tricky there are scripts like autogen.sh and autoreconf, etc. which are checked into source control to be used by developers building from source control, but these are not needed/used by people building from the source code release tar file etc.

Autoconf 和 automake 经常一起使用,但如果您想编写自己的 Makefile.in,您可以在没有 automake 的情况下使用 autoconf.

Autoconf and automake are often used together but you can use autoconf without automake, if you want to write your own Makefile.in.

这篇关于对配置脚本和 Makefile.in 感到困惑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆