你如何“回声”?源目录中的最后一个configure/make build --options?

发布于 2024-11-06 01:03:18 字数 1480 浏览 5 评论 0原文

使用特定选项、标志等进行 GNU 风格的“./configure, make, and install”时...正如您所知,有时这可能是一种黑色艺术..适用于一个软件的东西可能不适用于任何其他软件...

现在,想象一下您已经成功构建了一些包含一些选项的包XYZ.app 就像...

% ./configure --with-1=2 USFLAG="-3 four" OBSCURE_LIB=l/lib/doihave

并继续使用它。伟大的。稍后,您意识到您需要以前省略的编译时选项,或者您可能已经解决了依赖关系问题等...无论出于何种原因,您想要重新编译这个完美的二进制文件。

现在...如何逐字“调用”传递给 ./configure 的所有选项,以便使用这些相同的选项,同时可能添加或减去一些选项,这一次?

我确信这些东西都埋在所有这些 config.xxxx 或 AClocal 或 Makefile.xx 文件中的某个地方,但在我的一生中,我一直无法在 Google 上找到一个直接的答案。

% file /usr/bin/$1 -->  Mach-O 64-bit executable x86_64
% ld /usr/bin/$1   -->  -macosx_version_min not specificed, assuming 10.6
% make -d          -->  * 20 pages of Makefile nonsense.... *
% ./config.log     -->  * shows some history, but nothing interesting. *
% ./config.status  -->  * does a strange sequence oddly similar to a "clean" *
% ./configure -h   -->  * 500 options, none of which is "show-me=your-shit" *

glibtoolize、otool、autoconf、automake、pkg-config...似乎都不愿意提供帮助。 一次千钧一发似乎是 pkg-config 创建的 XYZ.pc 文件的内容。

prefix=/usr/local  \  exec_prefix=${prefix}  \  libdir=${exec_prefix}/lib
includedir=${prefix}/include  \  Libs: -L${libdir} -lxyz-base 
Cflags: -I${includedir} -I${includedir}/xyz

但是,这些看起来像是环境变量,而不是来自实际配置调用的参数... 我厌倦了猜测...找出原始构建参数的真正方法是什么,以便您可以随意再次使用它们...?

When doing a a GNU-style " ./configure, make, and install " - with specific options, flags, etc... As you all know, sometimes this can be a black art.. and what works for one piece of software may not for any other...

Now, imagine that you had successfully built some package XYZ.app with some options like...

% ./configure --with-1=2 USFLAG="-3 four" OBSCURE_LIB=l/lib/doihave

and gone ahead and used it. Great. At a later point, you realize you need a previously omitted compile-time option, or maybe you've resolved a dependency issue, etc... For whatever reason, you want to recompile this perfectly good binary.

Now... how can you "recall" ALL of the options you passed to ./configure, verbatim, so as to use those SAME options, while possibly adding or subtracting some, this time around?

I'm sure this stuff is buried somewhere in all those config.xxxx or AClocal or Makefile.xx files, but for the life of me, I haven'e been able to Google one straight answer.

% file /usr/bin/$1 -->  Mach-O 64-bit executable x86_64
% ld /usr/bin/$1   -->  -macosx_version_min not specificed, assuming 10.6
% make -d          -->  * 20 pages of Makefile nonsense.... *
% ./config.log     -->  * shows some history, but nothing interesting. *
% ./config.status  -->  * does a strange sequence oddly similar to a "clean" *
% ./configure -h   -->  * 500 options, none of which is "show-me=your-shit" *

glibtoolize, otool, autoconf, automake, pkg-config... all seem unwilling to help.
One close-call seems to be the contents of the XYZ.pc file created by pkg-config..

prefix=/usr/local  \  exec_prefix=${prefix}  \  libdir=${exec_prefix}/lib
includedir=${prefix}/include  \  Libs: -L${libdir} -lxyz-base 
Cflags: -I${includedir} -I${includedir}/xyz

However, these just seem like environmental variables, not arguments from the actual config invocation...
I'm sick of guessing... what is the real way to figure out the original build arguments, so that you can use them again, at will...?

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

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

发布评论

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

评论(4

任谁 2024-11-13 01:03:18

令人难以置信的是,不知怎的,其他人都错过了执行此操作的规范方法,这种方法在本线程开始前两年就已经存在了。 :-)

我想知道与OP相同的事情,并且当我读到这篇文章时,我对缺乏适当的(不丑陋的)方法来做到这一点感到失望。

几天后,当我闲着浏览 Autoconf 的发行说明时,我到达了 Autoconf 2.65 的发行说明。你相信吗?

Autoconf 2.65 (2009-11-21) [稳定] 的主要变化

[...]

config.status 现在提供 --config 选项来生成配置。

因此,只需运行 ./config.status --config 就可以完全满足OP的要求。

以下是文档中相应的参考: 17 config.status 调用,以及引用:

<代码>--配置

以可重用的方式打印配置设置,为 shell 引用,然后退出。例如,对于要重用 src-dir 中包的不同构建目录 build-dir 中的配置的调试构建,您可以使用以下内容:

args=`build-dir/config.status --config`
eval src-dir/configure "$args" CFLAGS=-g --srcdir=src-dir

Incredibly, somehow everyone else missed the canonical way to do this, which has been around since 2 years before this thread began. :-)

I wondered the same thing as the OP and was disappointed by the lack of proper (non-ugly) ways to do this when I read this thread.

A few days later, while idly browsing release notes for Autoconf, I reached the release notes for Autoconf 2.65. And would you believe it?

Major changes in Autoconf 2.65 (2009-11-21) [stable]

[...]

config.status now provides a --config option to produce the configuration.

So, just running ./config.status --config does precisely what the OP asked for.

Here is the corresponding reference in the documentation: 17 config.status invocation, and a quote:

--config

Print the configuration settings in reusable way, quoted for the shell, and exit. For example, for a debugging build that otherwise reuses the configuration from a different build directory build-dir of a package in src-dir, you could use the following:

args=`build-dir/config.status --config`
eval src-dir/configure "$args" CFLAGS=-g --srcdir=src-dir
这样的小城市 2024-11-13 01:03:18

config.status 里面有选项; ./config.status --recheck 使用原始选项重新运行 configure。您可以中断该命令并重新发出该命令(它会在运行之前显示该命令),或者您可以编辑 config.status 并将新参数添加到 $ac_configure_extra_args 中。

我确实希望他们能让这件事变得更容易。曾几何时,head config.status 将为您提供原始的configure 命令。 ./config.status --rerun extra args here 就很好了。

config.status has the options in it; ./config.status --recheck re-runs configure with the original options. You could interrupt that and reissue the command (which it will show you before running it), or you could edit config.status and add your new parameters to $ac_configure_extra_args.

I do kinda wish they'd made it easier to do this. Once upon a time head config.status would get you the original configure command. ./config.status --rerun extra args here would have been nice.

月牙弯弯 2024-11-13 01:03:18

我不敢相信没有人提到 config.log - 它为您提供了您正在寻找的内容:

此文件包含编译器在运行时生成的任何消息
运行configure,以在configure出错时帮助调试。

它是由configure创建的,它是
由 GNU Autoconf 2.69 生成。调用命令行为

$ ./configure --prefix /usr/local/syslog-ng/ --enable-linux-caps --enable-spoof-source

I can't believe nobody mentioned config.log - it give you exactly what you are looking for:

This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by configure, which was
generated by GNU Autoconf 2.69. Invocation command line was

$ ./configure --prefix /usr/local/syslog-ng/ --enable-linux-caps --enable-spoof-source

柠檬色的秋千 2024-11-13 01:03:18

如果您仍然拥有构建树,请运行 ./config.status --recheck,然后快速按 CTRL-C,因为它会打印出重新运行之前将运行的内容配置

If you still have the build tree, run ./config.status --recheck, then quickly press CTRL-C as it prints out what it will run before re-running configure.

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