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