./configure 有什么用(除了检查依赖关系)

发布于 2024-08-16 21:46:15 字数 107 浏览 7 评论 0原文

为什么每个使用makefile的源码包都会附带一个./configure脚本,它有什么作用?据我所知,它实际上生成了 makefile?

makefile 中有什么不能完成的事情吗?

Why does every source package that uses a makefile come with a ./configure script, what does it do? As far as I can tell, it actually generates the makefile?

Is there anything that can't be done in the makefile?

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

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

发布评论

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

评论(5

睡美人的小仙女 2024-08-23 21:46:15

配置通常是“autoconf”系统的结果。它可以生成标头、makefile,实际上是任何东西。 “通常”,因为有些是手工制作的。

这样做的原因是允许源代码在不同的环境中编译。 Unix / Linux 上有许多变体,系统头文件和库略有不同。配置脚本允许代码自动适应。

configure is usually a result of the 'autoconf' system. It can generate headers, makefiles, really anything. 'Usually,' since some are hand-crafted.

The reason for these things is to allow source code to be compiled in disparate environments. There are many variations on Unix / Linux, with slightly different system headers and libraries. configure scripts allow code to auto-adapt.

等风也等你 2024-08-23 21:46:15

配置步骤是一种元构建。它生成适用于您正在运行的特定硬件/发行版的 makefile。例如,它确定 C 或 C++ 编译器的名称并将其嵌入到 makefile 中。

配置步骤还经常采用一组参数,这些参数的值可以确定需要链接哪些库。例如,如果您在启用 SSL 的情况下编译 Apache HTTP,则与不启用 SSL 相比,它需要链接更多的共享库。由于链接是由 makefile 处理的,因此您需要额外的步骤来创建自定义 makefile(而不是要求 make 命令需要数十或数百个选项。

The configure step is a sort of meta build. It generates the makefile that will work on the specific hardware / distribution you're running. For instance it determines the name of the C or C++ compiler and embeds that in the makefile.

The configure step will also frequently take a set of parameters, the values of which may determine what libraries need to be linked against. For instance if you compile Apache HTTP with SSL enabled it needs to link against more shared libraries than if you don't. Since linking is handled by the makefile, you need an extra step to create a custom makefile (rather than requiring the make command to require dozens or hundreds of options.

瑾夏年华 2024-08-23 21:46:15

一切都可以在 makefile 中完成,但某些构建系统是通过其他方式实现的。

我个人不会在我的项目中使用 configure 文件,但我承认我主要导出 Erlang &基于Python的项目。

Everything can be done from within the makefile but some build systems were implemented otherwise.

I don't personally use configure files for my projects but I admit I mostly export Erlang & Python based projects.

寄居者 2024-08-23 21:46:15

我不认为 makefile 是一个脚本,我认为它是 make 实用程序的输入。

configure 脚本(顾名思义)配置 makefile,包括如您所说的解决依赖关系。

如果仅从避免自修改代码的想法来看,配置脚本中的内容并不真正属于makefile。

I don't think of the makefile as a script, I think of it as an input to the make utility.

The configure script (as its name suggests) configures the makefile, including as you say resolving dependencies.

If only from the idea of avoiding self-modifying code, the things in the configure script don't really belong in the makefile.

画骨成沙 2024-08-23 21:46:15

重点是autoconf autohdr automake形成一个集成的系统,使得在unix上的跨平台构建相对str8forward。这些文档真的很糟糕,有很多可怕的陷阱,但另一方面,有很多工作示例

当我第一次遇到这些东西时,我想 - “哈我可以用一个干净的 makefile 来做到这一点”并继续返工来源就是这样。大错误。学习编写和编辑configure.ac和makefile.am文件,你最终会很高兴

回答你的问题。配置对于

  • 函数 foo 在这个平台上可用吗?如果是的话,我需要哪个包含和库

  • 让构建者选择是否希望以简单一致的方式包含 wizzbang 功能

the point is that autoconf autohdr automake form an integrated system the makes cross platform building on unix relatively str8forward. THe docs are really bad and there are lots of horrible gotchas but on the other hand there are a lot of working samples

When I first came across this stuff I thought - "ha I can do that with a nice clean makefile" and proceeded to rework the source that way. Big mistake. Learn to write and edit configure.ac and makefile.am files, you will be happy in the end

To answer your question. Configure is good for

  • is function foo available on this platform and if so which include and library do I need

  • letting the builder choose if they want feature wizzbang included in a nice simple consistent way

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