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

查看:70
本文介绍了对配置脚本和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

好的.但是,作为终生下载我一生中无数压缩包的最终用户,我从不必须使用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.sh,否则configure似乎并没有真正运行.因此,我觉得这很令人困惑,因为我认为最终用户不必运行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-为了使configure脚本找到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?

推荐答案

为了真正理解自动工具实用程序,您必须记住它们的来源:它们来自开源世界,那里有(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).

使用自动制作时,人们通常检入Makefile.am文件(输入到自动制作中),但不检入自动制作的输出: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天全站免登陆