I was chatting with Federico on IRC about a way to avoid duplication between Makefile.am and configure.ac. His particular case had a script file that wanted a few full substitutions (which implies a make-time substitution, per [1]), but he didn't want to have to copy the whole list of AC_SUBST from configure.ac into Makefile.am in his do_subst script, and didn't want to build a file.in.in that goes through configure AC_CONFIG_FILES only to have file.in then go through a make-time expansion. We came up with the autoconf-documented use of $(top_builddir)/config.status --file=- (from [2]). And to demonstrate the ease of use, I've done this preliminary patch against automake itself.
Is this something we are interested in doing (since it _does_ provide a reduced maintenance burden, where adding a new AC_SUBST that does not need make-time expansion can now be done in just one file instead of two)? And if so, should I expand this RFC patch into something that passes the testsuite as well as mentioning it in the automake manual? [For the purposes of my quick test, I started a 'make check', still underway as I type this, and noticed that at least aclocal5.test failed, but everything else through f90only.test is happy so far. But I won't bother to investigate failures unless we decide to go forward with this plan.] [1] https://www.gnu.org/software/automake/manual/html_node/Scripts.html [2] https://www.gnu.org/software/autoconf/manual/autoconf.html#config_002estatus-Invocation diff --git i/Makefile.am w/Makefile.am index 8fe9c0f..0ef39c1 100644 --- i/Makefile.am +++ w/Makefile.am @@ -67,21 +67,11 @@ uninstall-hook: done -## We can't use configure to do the substitution here; we must do it -## by hand. We use a funny notation here to avoid configure -## substitutions in our text. +## We want a handful of substitutions to be fully-expanded by make; +## then use config.status to substitute the remainder where a single +## expansion is sufficient. We use a funny notation here to avoid +## configure substitutions in our text. do_subst = sed \ - -e 's,[@]APIVERSION[@],$(APIVERSION),g' \ - -e 's,[@]PACKAGE[@],$(PACKAGE),g' \ - -e 's,[@]PACKAGE_BUGREPORT[@],$(PACKAGE_BUGREPORT),g' \ - -e 's,[@]PACKAGE_URL[@],$(PACKAGE_URL),g' \ - -e 's,[@]PATH_SEPARATOR[@],$(PATH_SEPARATOR),g' \ - -e 's,[@]PERL[@],$(PERL),g' \ - -e 's,[@]PERL_THREADS[@],$(PERL_THREADS),g' \ - -e 's,[@]SHELL[@],$(SHELL),g' \ - -e 's,[@]am_AUTOCONF[@],$(am_AUTOCONF),g' \ - -e 's,[@]am_AUTOM4TE[@],$(am_AUTOM4TE),g' \ - -e 's,[@]VERSION[@],$(VERSION),g' \ -e 's,[@]configure_input[@],Generated from [email protected]; do not edit by hand.,g' \ -e 's,[@]datadir[@],$(datadir),g' @@ -92,7 +82,7 @@ automake: automake.in aclocal: aclocal.in automake aclocal: Makefile rm -f $@ [email protected] - $(do_subst) $(srcdir)/[email protected] >[email protected] + $(do_subst) $(srcdir)/[email protected] | ./config.status --file=- >[email protected] chmod +x [email protected] chmod a-w [email protected] mv -f [email protected] $@ -- Eric Blake [email protected] +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
