On Wed, 24 Oct 2012, Philip Hazel wrote:
> OK, that seems to work and is cleaner. I have committed the patch.
> Please try it out and see if it works for you. It copies the files
> configure and *.in into the temporary directory, so it should cope with
> the addition of any new .in files in future.
I'm afraid it's a bit more complicated than that. I tried to make this
work (in an out-of-source build), but configure complained about not
having install-sh, then about config.sub... it began to turn into a wild
goose chase. So I tried copying all of $(DISTFILES), but that contains
absolute and relative filepaths that make the operation non-trivial.
Ultimately, it's easier to move config.status out of the way temporarily,
and I've implemented that in a way that is robust to failure of the
ancillary ./configure run. The attached patch tweaks the rule to this:
config.h.generic: configure.ac
rm -rf $@ _generic
mkdir _generic
cs=$(srcdir)/config.status; test ! -f $$cs || mv -f $$cs $$cs.aside
cd _generic && $(abs_top_srcdir)/configure || :
cs=$(srcdir)/config.status; test ! -f $$cs.aside || mv -f $$cs.aside $$cs
test -f _generic/config.h
perl -pe '<insert Perl here>' _generic/config.h >$@
rm -rf _generic
(I used the "cs" shell variable to cut down the verbiage a bit.)
Also, with regard to these two forms:
cd _generic && $(abs_top_srcdir)/configure
(cd _generic; $(abs_top_srcdir)/configure)
The parens are not necessary, because make(1) executes each line of a
recipe in its own subshell. Also, using "&&" is more robust, because if
for whatever reason the "cd _generic" fails, the second part of the
command will not run.
--Daniel
--
Daniel Richard G. || danielg@??? || Software Developer
Teragram Linguistic Technologies (a division of SAS)
http://www.teragram.com/Index: Makefile.am
===================================================================
--- Makefile.am (revision 1174)
+++ Makefile.am (working copy)
@@ -147,8 +147,10 @@
config.h.generic: configure.ac
rm -rf $@ _generic
mkdir _generic
- cp configure *.in _generic
- (cd _generic; ./configure srcdir=.)
+ cs=$(srcdir)/config.status; test ! -f $$cs || mv -f $$cs $$cs.aside
+ cd _generic && $(abs_top_srcdir)/configure || :
+ cs=$(srcdir)/config.status; test ! -f $$cs.aside || mv -f $$cs.aside $$cs
+ test -f _generic/config.h
perl -pe 'if(/^#define\s(?!PACKAGE)(\w+)/){print"#ifndef $$1\n$$_#endif\n";$$_="";}' _generic/config.h >$@
rm -rf _generic