Eric Blake
2012-12-22 15:18:35 UTC
[adding autoconf, as this question technically is independent of automake]
test "x$" = "xdevel"
or
test "x$devel" = "xdevel"
based on the macro value. Probably not what you wanted.
is known at m4 time, we might as well use that information to generate
the smallest possible configure.
But if you _insist_ on delaying the decision until shell time, even
though the condition being tested is known at m4 time, then you probably
want to use something like this:
AS_IF([test "x]dc_version_suffix[" = "xdevel"], [
AC_DEFINE([USE_REVISION], [1], [Use the revision number.])
])
which expands the literal contents of the macro in place, so that your
configure will then either contain:
test "x" = "xdevel"
or
test "xdevel" = "xdevel"
Or, if you _want_ a shell variable rather than an m4 variable as the
source of your decision, then be sure you set up that shell variable:
[dc_version_suffix]=dc_version_suffix
AS_IF([[test "x$dc_version_suffix" = "xdevel"]], [
AC_DEFINE([USE_REVISION], [1], [Use the revision number.])
])
where the extra quoting is necessary to ensure that your configure file
will look like either:
dc_version_suffix=
test "x$dc_version_suffix" = "xdevel"
or
dc_version_suffix=devel
test "x$dc_version_suffix" = "xdevel"
Using a different shell variable name than the m4 macro name will make
it easier to type, without quite so much quoting:
version_suffix=dc_version_suffix
AS_IF([test "x$version_suffix" = "xdevel"], [
AC_DEFINE([USE_REVISION], [1], [Use the revision number.])
])
something at m4 time, but deferring the action on that decision until
configure time.
Hi,
m4_define([dc_version_suffix],[devel])
m4_define([dc_version_suffix],[])
And then try to conditionally call AC_DEFINE based on whether the
AS_IF([test "x$dc_version_suffix" = "xdevel"], [
AC_DEFINE(ENABLE_PTY, [1], [Enable pseudo terminal support.])
])
This will expand to either:m4_define([dc_version_suffix],[devel])
m4_define([dc_version_suffix],[])
And then try to conditionally call AC_DEFINE based on whether the
AS_IF([test "x$dc_version_suffix" = "xdevel"], [
AC_DEFINE(ENABLE_PTY, [1], [Enable pseudo terminal support.])
])
test "x$" = "xdevel"
or
test "x$devel" = "xdevel"
based on the macro value. Probably not what you wanted.
However if I use m4_isset, then it does kind of work, except that the
USE_REVISION macro in the config.h is either defined, or not present at
all.
m4_ifset([dc_version_suffix],[
AC_DEFINE(USE_REVISION, [1], [Use the revision number.])
])
Indeed, this actually does what _I_ would want - since dc_version_suffixUSE_REVISION macro in the config.h is either defined, or not present at
all.
m4_ifset([dc_version_suffix],[
AC_DEFINE(USE_REVISION, [1], [Use the revision number.])
])
is known at m4 time, we might as well use that information to generate
the smallest possible configure.
But if you _insist_ on delaying the decision until shell time, even
though the condition being tested is known at m4 time, then you probably
want to use something like this:
AS_IF([test "x]dc_version_suffix[" = "xdevel"], [
AC_DEFINE([USE_REVISION], [1], [Use the revision number.])
])
which expands the literal contents of the macro in place, so that your
configure will then either contain:
test "x" = "xdevel"
or
test "xdevel" = "xdevel"
Or, if you _want_ a shell variable rather than an m4 variable as the
source of your decision, then be sure you set up that shell variable:
[dc_version_suffix]=dc_version_suffix
AS_IF([[test "x$dc_version_suffix" = "xdevel"]], [
AC_DEFINE([USE_REVISION], [1], [Use the revision number.])
])
where the extra quoting is necessary to ensure that your configure file
will look like either:
dc_version_suffix=
test "x$dc_version_suffix" = "xdevel"
or
dc_version_suffix=devel
test "x$dc_version_suffix" = "xdevel"
Using a different shell variable name than the m4 macro name will make
it easier to type, without quite so much quoting:
version_suffix=dc_version_suffix
AS_IF([test "x$version_suffix" = "xdevel"], [
AC_DEFINE([USE_REVISION], [1], [Use the revision number.])
])
Does anyone know how to implement this correctly?
It really depends on what you are trying to accomplish by decidingsomething at m4 time, but deferring the action on that decision until
configure time.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org