Bug 13884 - Add a m4 function to pkg.m4 and calls both AC_ARG_ENABLE AND PKG_CHECK_MODULES
Summary: Add a m4 function to pkg.m4 and calls both AC_ARG_ENABLE AND PKG_CHECK_MODULES
Status: RESOLVED MOVED
Alias: None
Product: pkg-config
Classification: Unclassified
Component: src (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Dan Nicholson
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-01 13:12 UTC by Petteri Räty
Modified: 2018-08-25 12:52 UTC (History)
3 users (show)

See Also:
i915 platform:
i915 features:


Attachments
m4 macro (2.24 KB, text/plain)
2008-10-04 22:36 UTC, Luca Barbato
Details

Description Petteri Räty 2008-01-01 13:12:04 UTC
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])
Comment 1 Daniel Macks 2008-03-24 19:16:13 UTC
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.
Comment 2 Daniel Macks 2008-03-24 19:19:13 UTC
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.
Comment 3 Diego Elio Pettenò 2008-10-04 09:19:37 UTC
Actually we have a similar macro already...
Comment 4 Daniel Macks 2008-10-04 10:43:36 UTC
(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.
Comment 5 Diego Elio Pettenò 2008-10-04 10:45:58 UTC
Sorry, we was intended as me and Luca who I CCed here.
Comment 6 Luca Barbato 2008-10-04 22:36:01 UTC
Created attachment 19384 [details]
m4 macro

Here what we are using for lscube and other projects. I hope it could be useful.
Comment 7 Dan Nicholson 2012-11-06 14:44:00 UTC
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.
Comment 8 GitLab Migration User 2018-08-25 12:52:25 UTC
-- 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.