So, I'm working on overhauling a very old configure.in to a modern configure.ac, and I've come to a bit of a stumbling block.
I'm trying to use an AS_IF statement to do 1-3 things depending on the results from PKG_CHECK_MODULES and AC_ARG_ENABLE, but I can't seem to coerce them into the AS_IF action-if-true slot.
My current setup is as follows:
# Check for libbar
PKG_CHECK_MODULES([BAR],[bar],[bar_found=yes],[bar_found=no])
AC_ARG_ENABLE([bar],
AS_HELP_STRING([--enable-bar],[enable support for bar [default=yes]]))
AS_IF([test x$enable_bar = xyes],
[AS_IF(
[test x$bar_found = xyes],
[AC_DEFINE([HAVE_BAR_SUPPORT],[1],[Define if bar support is enabled])],
[AC_MSG_ERROR([*** bar requested but not found ***])])
]
)
AS_IF([test x$enable_bar = xyes],
[AS_IF(
[test x$bar_found = xyes],
[AX_APPEND_LINK_FLAGS([$BAR_LIBS],[LDFLAGS])],
[AC_MSG_ERROR([*** bar requested but not found ***])])
]
)
AS_IF([test x$enable_bar = xyes],
[AS_IF(
[test x$bar_found = xyes],
[AX_APPEND_COMPILE_FLAGS([$BAR_CFLAGS],[CFLAGS])],
[AC_MSG_ERROR([*** bar requested but not found ***])])
]
)
So as you can see, it works, but it is overly verbose. I'd like to be able to handle all the action-if-true stuff in a single AS_IF
AS_IF is just an expansion for if ...; then ...; else ...; fi
So you can add as much code within the block as you want, as long as it's all separated by newlines:
AS_IF([test x$enable_bar = xyes], [
AS_IF([test x$xbar_found], [
AC_DEFINE(...)
AX_APPEND_LINK_FLAGS(...)
AX_APPEND_COMPILE_FLAGS(...)
], [
AC_MSG_ERROR(...)
])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With