automake and ./configure (was: installation paths, option definition)

Christian Stimming stimming at tuhh.de
Sat Sep 3 16:39:11 EDT 2005


Just to finish that other automake/configure discussion:

Am Freitag, 2. September 2005 18:19 schrieb Neil Williams:
> > (And just one nitpicking remark: The auto-generation of a header from a
> > header.in file is done by "./configure", not by "automake" -- automake
> > basically only creates a "Makefile.in" from a "Makefile.am", but the
> > processing of the *.in files is always done by ./configure.)
>
> Not in this case, nor in lots of cases within GnuCash. We use a Guile
> convention in lots of areas that does no substitution during configure,
> only in the Makefile.am using a customised sed routine.
>
> qsf-dir.h: qsf-dir.h.in
>         rm -f $@.tmp
>         sed < $< > $@.tmp \
>                 -e 's:@-QSF_SCHEMA_DIR-@:${QSF_SCHEMA_DIR}:g'
>         mv $@.tmp $@
>
> That has been in place for schema validation for some months and also
> passes an installation path by a header file. No problems with that one.
> It's actually more flexible because the output can be updated without a
> complete ./autogen.sh.

Ahh, okay, didn't know that. However, it is still not "automake" that will 
generate the file qsf-dir.h. Instead, you now added a manual "creation rule" 
to the Makefile.am which will appear unchanged in the Makefile. This creation 
rule will then be executed when you run "make". So what happens here is that 
"make" will create the qsf-dir.h according to this manuale creation rule 
which is defined in the Makefile.am. It is not automake that creates your 
header but make. 

You can reach exactly the same effect but without the manual creation rule if  
you do the following steps: 

1. Make sure all your desired substitution variables (e.g. QSF_SCHEMA_DIR) are 
listed in the configure.in file as AC_SUBST [e.g. AC_SUBST(QSF_SCHEMA_DIR) ]
2. In your file qsf-dir.h.in, list these variables with surrounding @...@ but 
not @-...-@ (e.g. #define blabla @QSF_SCHEMA_DIR@)
3. Add the input file in your configure.in file to the long list in AC_OUTPUT 
(e.g. src/bla/bla/qsf-dir.h.in)
4. Add the resulting *output* file in that directory's Makefile.am to any  
variable that ensures that this file is distributed, e.g. 
noinst_HEADERS=qsf-dir.h and probably also BUILT_SOURCES=qsf-dir.h

This way, you gain the following: 1. You don't need to add the multi-line 
manual creation rule to the Makefile.am anymore, and 2. ./configure will make 
sure that you have all AC_SUBST variables available. And 3. the rule won't 
fail if "sed" happens to be called in some weird unusual way which we don't 
know but ./configure on that platform will know.

I don't quite understand why the manual rule was added in the first place. 
Maybe there was a reason, maybe not. In any case such installation paths 
change if and only if ./configure has been run, so having the resulting path 
created only by ./configure is just the exact right thing to do. The file 
gnucash.keys is surely one that can direcly be added to configure.in. And 
unless you have a very specific reason to go for a manual rule, you should  
simply add those files as AC_OUTPUT to configure.in.

Christian


More information about the gnucash-devel mailing list