On Wednesday 22 August 2007 14:41:46 you wrote: > > AC_CONFIG_FILES([project.conf > > Makefile > > subdir/Makefile]) > > That doesn't always work for several reasons. First off, people > happen to this frequently to pass path information around. Paths are > mostly always defined in term of $prefix (at least). At configure > time, prefix is set to NONE so you can't do it here [1]. Moreover, > several paths are defined in terms of others, eg: > > bindir='${exec_prefix}/bin' > exec_prefix='${prefix}' > prefix='/usr/local' > > So you end up doing several calls to `eval' to simulate the variable > expansion performed by make. Needless to say this is fragile (but > doable).
Indeed, I have tried with AC_CONFIG_FILES or AC_OUTPUT (with corresponding AC_SUBSTs) and I got something like ${prefix}/etc ${prefix}/var substituted in the file. > Back to Dizzy's question: > I think the line should be: > > $(SED) -e 's,$${LOCALSTATEDIR},${localstatedir},g' $(top_srcdir)/conf/ > project.conf.in >$@ > > You don't need to worry about the double-quotes thing because it's > not your shell that expands the value of ${localstatedir} but make. > Actually you could write $(localstatedir) instead and it wouldn't > change anything. Yeah, I had some confusion in my mind. After more debugging and printing of Makefile.in and Makefile contents I also realised what you said that it's replaced by make and not the shell heh. > Actually what happens is that ${LOCALSTATEDIR} is recognized by make > as a non-existant make variable and is (as such) expanded to an empty > string. What you want to do is to escape this variable so that make > ignores it (by using `$$' instead of a single `$'). Had no idea about the $$ trick to escape variables in make, thank you (and Bernd) for the idea. > $ cat >configure.ac > AC_INIT([foo], [0.1]) > AM_INIT_AUTOMAKE([foreign]) > AC_CONFIG_FILES([Makefile]) > AC_OUTPUT > $ cat >Makefile.am > foo: foo.in > ^Ised -e 's,$${LOCALSTATEDIR},${localstatedir},g' $(top_srcdir)/ > foo.in >$@ > $ cat >foo.in > echo '${LOCALSTATEDIR}' > $ autoreconf -i > configure.ac:2: installing `./missing' > configure.ac:2: installing `./install-sh' > $ ./configure > checking for a BSD-compatible install... /opt/local/bin/ginstall -c > checking whether build environment is sane... yes > checking for a thread-safe mkdir -p... /opt/local/bin/mkdir -p > checking for gawk... gawk > checking whether make sets $(MAKE)... yes > configure: creating ./config.status > config.status: creating Makefile > $ make foo > sed -e 's,${LOCALSTATEDIR},/usr/local/var,g' ./foo.in >foo > $ sh foo > /usr/local/var Works very well indeed, the trick was mainly the $$ escape variable for make syntax. Thank you all, you have been very helpful. -- Mihai RUSU Email: [EMAIL PROTECTED] "Linux is obsolete" -- AST