I often up doing something like: AC_ARG_ENABLE(<pkg>, AC_HELP_STRING([--enable-<pkg>], [enable <pkg> support], [], [enable_<pkg>=auto])) PKG_CHECK_MODULES(<PKG>, [<pkg> >= <version>], [if test x"${enable_<pkg>}" = x"yes" || test x"${enable_<pkg>}" = x"auto"; then AC_DEFINE(HAVE_<PKG>, 1, [defined if <pkg> is available]) fi], [test x"${enable_<pkg>}" = x"yes" && AC_MSG_ERROR(<pkg> support needs <pkg> >= <version> installed)]) AC_SUBST(<PKG>_CFLAGS) AC_SUBST(<PKG_LIBS) IMHO it would be create if pkg-config provide a PKG_ macro for this so that one could just do PKG_ARG_ENABLE([<pkg>], [" >= <version>"], AC_DEFINE(HAVE_<PKG>, 1, [defined if <pkg> is available])
I agree this is a common task. However, it's pretty common that the PKG_CHECK_MODULES check is not a simple module name (i.e., a certain feature requires several distinct modules). It would be more flexible if $2 for this new PKG_ARG_ENABLE were the actual $2 used for PKG_CHECK_MODULES, not a simple appendage for $1.
Functional suggestion: don't even bother doing the PKG_CHECK_MODULES if $enable is no. It's a bit confusing when a ./cnofigure script includes messages about not findind some support library if that library isn't needed at all and won't be used (or some associated feature enabled) even if it does exist.
Actually we have a similar macro already...
(In reply to comment #3) > Actually we have a similar macro already... > "We"? For pkg-config-0.23, $ grep AC_DEFUN pkg.m4 AC_DEFUN([PKG_PROG_PKG_CONFIG], AC_DEFUN([PKG_CHECK_EXISTS], AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], AC_DEFUN([PKG_CHECK_MODULES], and none of those appear to do anything similar to AC_ARG_WITH or AC_ARG_ENABLE functionality.
Sorry, we was intended as me and Luca who I CCed here.
Created attachment 19384 [details] m4 macro Here what we are using for lscube and other projects. I hope it could be useful.
Luca posted his macros on the list, and I think they're pretty close to being ready. http://lists.freedesktop.org/archives/pkg-config/2012-May/000837.html I just mostly want to make sure the interface is clean and friendly before committing.
-- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/pkg-config/pkg-config/issues/2.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.