I am writing my configure.ac
script, and have a few custom enable arguments which define macros in my C code if enabled. An example:
AC_ARG_ENABLE([example],
AS_HELP_STRING([--enable-example], [This is an example]))
AS_IF([test "x$enable_example" = "xyes"], [
AC_DEFINE(EXAMPLE_MACRO, 1, [This is a definition example])
])
Now say I have an enable option which, if enabled, must disable the effects of --enable-example
option. I have the normal setup:
AC_ARG_ENABLE([another-feature],
AS_HELP_STRING([--another-feature], [This is a feature which enables something, but disables --enable-example]))
AS_IF([test "x$enable_another_feature" = "xyes"], [
AC_DEFINE(ANOTHER_FEATURE_MACRO, 1, [This is another feature definition])
])
Now I need to be able to undefine the EXAMPLE_MACRO
macro, but I can't find anything to undo the AC_DEFINE
. Am I missing something?
Why not simply delay the AC_DEFINE
function calls? Note, I'm not a big fan of the AS_IF
macro...
if test "x$enable_another_feature" = xyes ; then
# enable_example="no" # (optional)
AC_DEFINE([ANOTHER_FEATURE_MACRO], [1])
elif test "x$enable_example" = xyes ; then
AC_DEFINE([EXAMPLE_MACRO], [1])
fi
If the AC_DEFINE
is not executed, the corresponding #define ...
is not instantiated in the config header. Discussed here.