[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: $sysconfdir substitution
From: |
Gavin Smith |
Subject: |
Re: $sysconfdir substitution |
Date: |
Fri, 10 Jun 2016 20:30:28 +0100 |
On 10 June 2016 at 08:05, Peter Johansson <address@hidden> wrote:
> Hi Kip,
>
> I have the following rule in my Makefile.am to generate a C header file.
>
> configmake.h: Makefile
> $(AM_V_GEN)echo '#define BINDIR "$(bindir)"' > $@
>
> You could have a similar rule to generate a file suitable to source into
> your script.
This works because the variable "bindir" is completely expanded in the
Makefile rules.
The Texinfo project has similar code to substitute for variables in a
AC_CONFIG_FILE-like way in an output file:
do_subst = sed \
-e 's,address@hidden@],$(PACKAGE_VERSION),g' \
-e 's,address@hidden@],$(PACKAGE_NAME),g' \
-e 's,address@hidden@],$(PACKAGE_URL),g' \
-e 's,address@hidden@],$(sysconfdir),g' \
-e 's,address@hidden@],$(prefix),g' \
-e 's,address@hidden@],$(datarootdir),g' \
-e 's,address@hidden@],$(datadir),g' \
-e 's,address@hidden@],$(pkglibdir),g' \
-e 's,address@hidden@],$(PACKAGE),g' \
-e 's,address@hidden@],$(USE_EXTERNAL_LIBINTL),g' \
-e 's,address@hidden@],$(USE_EXTERNAL_EASTASIANWIDTH),g' \
-e 's,address@hidden@],$(USE_EXTERNAL_UNIDECODE),g' \
-e 's,address@hidden@],$(TEXINFO_DTD_VERSION),g' \
-e 's,address@hidden@],$(enable_xs),g' \
-e '1 s,/usr/bin/env perl,$(PERL),g'
texi2any: texi2any.pl $(top_builddir)/config.status
$(do_subst) $(srcdir)/texi2any.pl >$@
chmod a+x $@
The gist of this is that it's using sed to generate one file from
another, substituting in the values of some Makefile variables. I
don't know if it's possible or advisable to use this in combination
with AC_CONFIG_FILES, but using it instead of AC_CONFIG_FILES would
certainly work.