summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/qemu/qemu/0010-configure-Add-pkg-config-handling-for-libgcrypt.patch
blob: d7e3fffdd0220612eb04420fa3293b75976c69a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
From c207607cdf3996ad9783c3bffbcd3d65e74c0158 Mon Sep 17 00:00:00 2001
From: He Zhe <zhe.he@windriver.com>
Date: Wed, 28 Aug 2019 19:56:28 +0800
Subject: [PATCH] configure: Add pkg-config handling for libgcrypt

libgcrypt may also be controlled by pkg-config, this patch adds pkg-config
handling for libgcrypt.

Upstream-Status: Denied [https://lists.nongnu.org/archive/html/qemu-devel/2019-08/msg06333.html]

Signed-off-by: He Zhe <zhe.he@windriver.com>

---
 configure | 48 ++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 40 insertions(+), 8 deletions(-)

Index: qemu-5.1.0/configure
===================================================================
--- qemu-5.1.0.orig/configure
+++ qemu-5.1.0/configure
@@ -3084,6 +3084,30 @@ has_libgcrypt() {
     return 0
 }
 
+has_libgcrypt_pkgconfig() {
+    if ! has $pkg_config ; then
+        return 1
+    fi
+
+    if ! $pkg_config --list-all | grep libgcrypt > /dev/null 2>&1 ; then
+        return 1
+    fi
+
+    if test -n "$cross_prefix" ; then
+        host=$($pkg_config --variable=host libgcrypt)
+        if test "${host%-gnu}-" != "${cross_prefix%-gnu}" ; then
+            print_error "host($host) does not match cross_prefix($cross_prefix)"
+            return 1
+        fi
+    fi
+
+    if ! $pkg_config --atleast-version=1.5.0 libgcrypt ; then
+        print_error "libgcrypt version is $($pkg_config --modversion libgcrypt)"
+        return 1
+    fi
+
+    return 0
+}
 
 if test "$nettle" != "no"; then
     pass="no"
@@ -3124,7 +3148,14 @@ fi
 
 if test "$gcrypt" != "no"; then
     pass="no"
-    if has_libgcrypt; then
+    if has_libgcrypt_pkgconfig; then
+        gcrypt_cflags=$($pkg_config --cflags libgcrypt)
+        if test "$static" = "yes" ; then
+            gcrypt_libs=$($pkg_config --libs --static libgcrypt)
+        else
+            gcrypt_libs=$($pkg_config --libs libgcrypt)
+        fi
+    elif has_libgcrypt; then
         gcrypt_cflags=$(libgcrypt-config --cflags)
         gcrypt_libs=$(libgcrypt-config --libs)
         # Debian has removed -lgpg-error from libgcrypt-config
@@ -3134,15 +3165,16 @@ if test "$gcrypt" != "no"; then
         then
             gcrypt_libs="$gcrypt_libs -lgpg-error"
         fi
+    fi
 
-        # Link test to make sure the given libraries work (e.g for static).
-        write_c_skeleton
-        if compile_prog "" "$gcrypt_libs" ; then
-            LIBS="$gcrypt_libs $LIBS"
-            QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
-            pass="yes"
-        fi
+    # Link test to make sure the given libraries work (e.g for static).
+    write_c_skeleton
+    if compile_prog "" "$gcrypt_libs" ; then
+	    LIBS="$gcrypt_libs $LIBS"
+	    QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
+	    pass="yes"
     fi
+
     if test "$pass" = "yes"; then
         gcrypt="yes"
         cat > $TMPC << EOF