什么是“./configure”命令?

发布于 2024-12-04 09:01:15 字数 121 浏览 0 评论 0原文

我通常会看到 ./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 技术交流群。

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

发布评论

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

评论(3

夏至、离别 2024-12-11 09:01:16

每个系统都是不同的。例如,有不同的编译器和编译器版本,您的系统工具可能支持某些标志(或不支持),您可能安装或未安装某些库,等等。有很多东西在计算机上有所不同,可能会影响编译项目的方式。

configure 脚本尝试找出所有这些事情,并在不满足先决条件时发出抱怨(例如,当缺少编译器或缺少库时)。然后,它会生成一个特定于系统的Makefile,只需输入make就能(希望)在您的系统上正确构建项目。

configure之前,我们必须手动调整Makefile(通常可调整部分被偏移到单独的Makefile中)。这意味着您需要了解有关系统的很多信息,并且通常需要修改 Makefile。这是一个很大的障碍,特别是因为几乎每个项目的做法都不同。 GNU autoconfautomake (解析 Makefile.amconfigure.ac 文件以生成 Makefile .inconfigure 脚本)确实简化了这里的事情(特别是如果你正在做一些奇怪的事情,比如交叉编译,几乎没有项目关心添加支持;如果你正在做例如,以干净的方式使用 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 typing make 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. GNU autoconf and automake (which parse the Makefile.am and configure.ac files to generate Makefile.in and configure 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 doing autoconf/automake in a clean manner than you get cross-compile support for free, for example).

笑脸一如从前 2024-12-11 09:01:16

它通常是由 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

奈何桥上唱咆哮 2024-12-11 09:01:16

GNU Autoconf
Autoconf 根据configure.ac 文件的内容生成配置脚本,该文件描述了特定的源代码主体。配置脚本在运行时会扫描构建环境并生成从属 config.status 脚本,该脚本又将其他输入文件(最常见的是 Makefile.in)转换为适合该构建环境的输出文件 (Makefile)。最后make程序使用Makefile从源代码生成可执行程序。

http://en.wikipedia.org/wiki/GNU_build_system

GNU Autoconf
Autoconf generates a configure script based on the contents of a configure.ac file which characterizes a particular body of source code. The configure script, when run, scans the build environment and generates a subordinate config.status script which, in turn, converts other input files and most commonly Makefile.in into output files (Makefile) which are appropriate for that build environment. Finally the make program uses Makefile to generate executable programs from source code.

http://en.wikipedia.org/wiki/GNU_build_system

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