diff mbox

configure: For libgcrypt if pkg-config is available use it

Message ID 20170104145652.30442-1-nathan@nathanrossi.com
State New
Headers show

Commit Message

Nathan Rossi Jan. 4, 2017, 2:56 p.m. UTC
If libgcrypt info is available with pkg-config use it over using the
libgcrypt-config. pkg-config is preferred due to is compatibility with
cross-compilation (where you cannot execute the targets version of
libgcrypt-config).

This change makes configure check for libgcrypt in pkg-config first,
then falling back to use libgcrypt-config if available. This follows a
similar process to how libsdl is handled.

Signed-off-by: Nathan Rossi <nathan@nathanrossi.com>
---
 configure | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

Comments

Daniel P. Berrangé Jan. 4, 2017, 3:27 p.m. UTC | #1
On Thu, Jan 05, 2017 at 12:56:52AM +1000, Nathan Rossi wrote:
> If libgcrypt info is available with pkg-config use it over using the
> libgcrypt-config. pkg-config is preferred due to is compatibility with
> cross-compilation (where you cannot execute the targets version of
> libgcrypt-config).

It can be made to work, but you need to modify $PATH to ensure it finds
the build target libgcrypt-config first.

eg on Fedora you'd do this with mingw32

   PATH=/usr/i686-w64-mingw32/sys-root/mingw/bin:$PATH ./configure ...

> This change makes configure check for libgcrypt in pkg-config first,
> then falling back to use libgcrypt-config if available. This follows a
> similar process to how libsdl is handled.

AFAIK, no version of libgcrypt has ever shipped a pkg-config file. Their
maintainers have explicitly rejected patches adding that, ironically
because they claim pkg-config doesn't handle cross-compilation and
libgcrypt-config does :-)

https://lists.gnupg.org/pipermail/gcrypt-devel/2007-February/001109.html
https://lists.gnupg.org/pipermail/gcrypt-devel/2015-September/003569.html


So overall, I don't think this patch is needed/desirable for QEMU.

Regards,
Daniel
Nathan Rossi Jan. 4, 2017, 4:01 p.m. UTC | #2
On 5 January 2017 at 01:27, Daniel P. Berrange <berrange@redhat.com> wrote:
> On Thu, Jan 05, 2017 at 12:56:52AM +1000, Nathan Rossi wrote:
>> If libgcrypt info is available with pkg-config use it over using the
>> libgcrypt-config. pkg-config is preferred due to is compatibility with
>> cross-compilation (where you cannot execute the targets version of
>> libgcrypt-config).
>
> It can be made to work, but you need to modify $PATH to ensure it finds
> the build target libgcrypt-config first.
>
> eg on Fedora you'd do this with mingw32
>
>    PATH=/usr/i686-w64-mingw32/sys-root/mingw/bin:$PATH ./configure ...
>
>> This change makes configure check for libgcrypt in pkg-config first,
>> then falling back to use libgcrypt-config if available. This follows a
>> similar process to how libsdl is handled.
>
> AFAIK, no version of libgcrypt has ever shipped a pkg-config file. Their
> maintainers have explicitly rejected patches adding that, ironically
> because they claim pkg-config doesn't handle cross-compilation and
> libgcrypt-config does :-)
>
> https://lists.gnupg.org/pipermail/gcrypt-devel/2007-February/001109.html
> https://lists.gnupg.org/pipermail/gcrypt-devel/2015-September/003569.html
>

Sorry for the noise. Turns out Yocto/OE patches support in to
libgcrypt for pkg-config, I did not realize (too many different things
in play :| ).

Regards,
Nathan

>
> So overall, I don't think this patch is needed/desirable for QEMU.
>
> Regards,
> Daniel
> --
> |: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
> |: http://libvirt.org              -o-             http://virt-manager.org :|
> |: http://entangle-photo.org       -o-    http://search.cpan.org/~danberr/ :|
diff mbox

Patch

diff --git a/configure b/configure
index 218df87d21..6558121de8 100755
--- a/configure
+++ b/configure
@@ -2386,9 +2386,17 @@  has_libgcrypt_config() {
 }
 
 if test "$gcrypt" != "no"; then
-    if has_libgcrypt_config; then
-        gcrypt_cflags=$(libgcrypt-config --cflags)
-        gcrypt_libs=$(libgcrypt-config --libs)
+    gcrypt_config=""
+    # If libgcrypt in pkg-config use it over using libgcrypt-config
+    if $pkg_config --exists "libgcrypt"; then
+      gcrypt_config="$pkg_config libgcrypt"
+    elif has_libgcrypt_config; then
+      gcrypt_config="libgcrypt-config"
+    fi
+
+    if test -n "$gcrypt_config"; then
+        gcrypt_cflags=$($gcrypt_config --cflags)
+        gcrypt_libs=$($gcrypt_config --libs)
         # Debian has remove -lgpg-error from libgcrypt-config
         # as it "spreads unnecessary dependencies" which in
         # turn breaks static builds...