Would it be feasible to include a macro in pkg.m4 to access pkg-config variables with autoconf? The following is what I have locally, but I find it useful and would like to request similar functionality in pkg-config itself (if you agree that it makes sense). Thanks. # PKG_CHECK_VAR([VARIABLE-PREFIX], [MODULES], [VARIABLE], # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # ------------------------------------------------------- AC_DEFUN([PKG_CHECK_VAR], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1][_][$3], [value of $3 for $1, overriding pkg-config])dnl _PKG_CONFIG([$1][_][$3], [variable="][$3]["], [$2])dnl AS_VAR_COPY([$1][_][$3], [pkg_cv_][$1][_][$3])dnl AS_VAR_IF([$1][_][$3], [""], [$5], [$4])dnl ])# PKG_CHECK_VAR
Sorry for taking so long to reply. It's not really high priority, but this looks nice. If you can get it into a git patch and add documentation in both comments in pkg.m4 and in pkg-config(1), I can probably apply it. I have one comment below. (In reply to comment #0) > Would it be feasible to include a macro in pkg.m4 to access pkg-config > variables with autoconf? The following is what I have locally, but I find > it useful and would like to request similar functionality in pkg-config > itself (if you agree that it makes sense). Thanks. > > # PKG_CHECK_VAR([VARIABLE-PREFIX], [MODULES], [VARIABLE], > # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) Is the VARIABLE-PREFIX ($1) necessary? It seems like just using the name as provided would be fine in this case since the user can decide to prefix it with the package name or not. The reason we do this for PKG_CHECK_MODULES is since we're setting two variables. Here you're just setting one. Also, I'd make the comment say MODULE instead of MODULES since pkg-config returning the variable setting from multiple modules is pretty useless. > # ------------------------------------------------------- > AC_DEFUN([PKG_CHECK_VAR], > [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl > AC_ARG_VAR([$1][_][$3], [value of $3 for $1, overriding pkg-config])dnl > > _PKG_CONFIG([$1][_][$3], [variable="][$3]["], [$2])dnl > AS_VAR_COPY([$1][_][$3], [pkg_cv_][$1][_][$3])dnl Does the AC_ARG_VAR actually work here if we blindly AS_VAR_COPY? Looking again at _PKG_CONFIG, I guess it takes care of using the variable set in the environment and assigning it to pkg_cv_$1. So, this seems fine. What do you think? With the change above and more documentation, I'd be happy to add this. Otherwise, you'll have to convince me why VARIABLE-PREFIX is useful.
You're right; there was no technical reason to use a variable prefix. It was just for consistency with PKG_CHECK_MODULES. I've put the changes into git, which is available here: https://github.com/dm0-/pkg-config . Thanks.
I squashed the two commits, added the bug to the commit message and made the documentation a little more detailed. Pushed in commit 5b463c9. Thanks for the patch!
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.