Discussion:
Transferring variables from configure.ac to Makefile.am
Russell Wallace
2016-03-24 19:42:40 UTC
Permalink
I think I sort of see how to set variables within configure.ac, and do some
minimal calculations on them. But how do you transfer the value of a
variable set in configure.ac, to Makefile.am where it will be actually used?
Nick Bowler
2016-03-24 19:52:24 UTC
Permalink
Hi Russell,
Post by Russell Wallace
I think I sort of see how to set variables within configure.ac, and do some
minimal calculations on them. But how do you transfer the value of a
variable set in configure.ac, to Makefile.am where it will be actually used?
Any shell variable can be marked as an "output variable" by using AC_SUBST;
the value is then substituted into configure outputs. See "Setting Output
Variables"[1] in the Autoconf manual for the details.

It sounds like you are using Automake so this process should be pretty much
automatic: by default, automake automatically adds the appropriate magic to
set make variables with the same name, so you can just use the variable in
make as you normally would.

Example:

configure.ac:
FOO=bar
AC_SUBST([FOO])

Makefile.am:
my_stuff = $(FOO)

[1] https://www.gnu.org/software/autoconf/manual/autoconf.html#Setting-Output-Variables

Cheers,
Nick

Loading...