什么是“./configure”命令?
我通常会看到 ./configure
来构建一些东西。它看起来是由工具生成的脚本。今天,我意识到我不知道那是什么。
这是什么?这个脚本的作用是什么?是谁制作的?我怎样才能做出这样的东西?
I usually see ./configure
to build something. It looks a script produced by a tool. And today, I realized that I don't know what that is.
What's this? What's the role of this script, and who does make this? And how can I make something like that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
每个系统都是不同的。例如,有不同的编译器和编译器版本,您的系统工具可能支持某些标志(或不支持),您可能安装或未安装某些库,等等。有很多东西在计算机上有所不同,可能会影响编译项目的方式。
configure
脚本尝试找出所有这些事情,并在不满足先决条件时发出抱怨(例如,当缺少编译器或缺少库时)。然后,它会生成一个特定于您系统的Makefile,只需输入make
就能(希望)在您的系统上正确构建项目。在
configure
之前,我们必须手动调整Makefile(通常可调整部分被偏移到单独的Makefile中)。这意味着您需要了解有关系统的很多信息,并且通常需要修改 Makefile。这是一个很大的障碍,特别是因为几乎每个项目的做法都不同。 GNUautoconf
和automake
(解析Makefile.am
和configure.ac
文件以生成Makefile .in
和configure
脚本)确实简化了这里的事情(特别是如果你正在做一些奇怪的事情,比如交叉编译,几乎没有项目关心添加支持;如果你正在做例如,以干净的方式使用autoconf
/automake
而不是免费获得交叉编译支持)。Every system is different. For example, there are different compilers and compiler versions, the tools of your system might support certain flags (or not), you might have certain libraries installed or not, etc. pp. There a lots of things that are different on computers that might influence how to compile a project.
The
configure
script tries to figure out all these things and complain if prerequisites aren't met (for example, when the compiler is missing or when a library is missing). It then generates a Makefile that is specific to your system, and just typingmake
will (hopefully) build the project correctly on your system.Prior to
configure
, we had to hand-tune the Makefiles (often the tunable parts were offset into a separate Makefile). This meant that you needed to know a lot about your system and often that you needed to modify the Makefiles. It was a big hurdle, especially since almost every project did it differently. GNUautoconf
andautomake
(which parse theMakefile.am
andconfigure.ac
files to generateMakefile.in
andconfigure
scripts) really simplified things here (especially if you're doing exotic things like cross-compiling for which almost no project cares to add support; if you're doingautoconf
/automake
in a clean manner than you get cross-compile support for free, for example).它通常是由 GNU autoconf 创建的脚本。其他构建工具也可能使用相同的名称。 Autoconf 是一个相当复杂的工具,但网上有一些简短的教程。我喜欢这个:http://www.edwardrosten.com/code/autoconf/index。 html
It's usually a script created by GNU autoconf. Other build tools might use the same name too. Autoconf is quite a complex tool, but there's several short tutorials available on the web. I like this one: http://www.edwardrosten.com/code/autoconf/index.html
http://en.wikipedia.org/wiki/GNU_build_system
http://en.wikipedia.org/wiki/GNU_build_system