Add a PKG_HAVE_MODULES macro that does what you mean.

PKG_HAVE_MODULES is a wrapper around PKG_CHECK_MODULES which is non-fatal if the requested modules were not found and which calls AC_DEFINE and AM_CONDITIONAL as you'd expect.
This commit is contained in:
Dag-Erling Smørgrav 2017-03-22 23:18:41 +01:00
parent eda74454db
commit 75fe73025a
1 changed files with 18 additions and 0 deletions

View File

@ -341,3 +341,21 @@ PKG_HAVE_WITH_MODULES([$1],[$2],[$3],[$4])
AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"],
[AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])])
])dnl PKG_HAVE_DEFINE_WITH_MODULES
dnl PKG_HAVE_MODULES(VARIABLE-PREFIX, MODULES,
dnl [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
dnl ------------------------------------------
dnl
dnl Convenience macro to run AM_CONDITIONAL and AC_DEFINE after
dnl PKG_CHECK_MODULES. HAVE_[VARIABLE-PREFIX] is exported as make
dnl and preprocessor variable.
AC_DEFUN([PKG_HAVE_MODULES],
[
PKG_CHECK_MODULES([$1], [$2],
[m4_n([AS_TR_SH([ac_cv_have_]m4_tolower([$1]))=yes]) $3],
[m4_n([AS_TR_SH([ac_cv_have_]m4_tolower([$1]))=no]) $4])
AS_IF([test x"$AS_TR_SH([ac_cv_have_]m4_tolower([$1]))" = x"yes"],
[AC_DEFINE([HAVE_][$1], 1, [Have ]m4_tolower([$1])[ available])])
AM_CONDITIONAL([HAVE_][$1],
[test x"$AS_TR_SH([ac_cv_have_]m4_tolower([$1]))" = x"yes"])
])dnl PKG_HAVE_MODULES