automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RFC: cool hack for simplifying do_subst generation of scripts


From: Eric Blake
Subject: RFC: cool hack for simplifying do_subst generation of scripts
Date: Thu, 12 Jan 2012 12:16:14 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111222 Thunderbird/9.0

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,address@hidden@],$(APIVERSION),g' \
-  -e 's,address@hidden@],$(PACKAGE),g' \
-  -e 's,address@hidden@],$(PACKAGE_BUGREPORT),g' \
-  -e 's,address@hidden@],$(PACKAGE_URL),g' \
-  -e 's,address@hidden@],$(PATH_SEPARATOR),g' \
-  -e 's,address@hidden@],$(PERL),g' \
-  -e 's,address@hidden@],$(PERL_THREADS),g' \
-  -e 's,address@hidden@],$(SHELL),g' \
-  -e 's,address@hidden@],$(am_AUTOCONF),g' \
-  -e 's,address@hidden@],$(am_AUTOM4TE),g' \
-  -e 's,address@hidden@],$(VERSION),g' \
   -e 's,address@hidden@],Generated from address@hidden; do not edit by
hand.,g' \
   -e 's,address@hidden@],$(datadir),g'

@@ -92,7 +82,7 @@ automake: automake.in
 aclocal: aclocal.in
 automake aclocal: Makefile
        rm -f $@ address@hidden
-       $(do_subst) $(srcdir)/address@hidden >address@hidden
+       $(do_subst) $(srcdir)/address@hidden | ./config.status --file=- 
>address@hidden
        chmod +x address@hidden
        chmod a-w address@hidden
        mv -f address@hidden $@

-- 
Eric Blake   address@hidden    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]