blob: d7e3fffdd0220612eb04420fa3293b75976c69a2 [file] [log] [blame]
Andrew Geissler82c905d2020-04-13 13:39:40 -05001From c207607cdf3996ad9783c3bffbcd3d65e74c0158 Mon Sep 17 00:00:00 2001
Brad Bishop79641f22019-09-10 07:20:22 -04002From: He Zhe <zhe.he@windriver.com>
3Date: Wed, 28 Aug 2019 19:56:28 +0800
Andrew Geissler82c905d2020-04-13 13:39:40 -05004Subject: [PATCH] configure: Add pkg-config handling for libgcrypt
Brad Bishop79641f22019-09-10 07:20:22 -04005
6libgcrypt may also be controlled by pkg-config, this patch adds pkg-config
7handling for libgcrypt.
8
9Upstream-Status: Denied [https://lists.nongnu.org/archive/html/qemu-devel/2019-08/msg06333.html]
10
11Signed-off-by: He Zhe <zhe.he@windriver.com>
Andrew Geissler82c905d2020-04-13 13:39:40 -050012
Brad Bishop79641f22019-09-10 07:20:22 -040013---
14 configure | 48 ++++++++++++++++++++++++++++++++++++++++--------
15 1 file changed, 40 insertions(+), 8 deletions(-)
16
Andrew Geissler635e0e42020-08-21 15:58:33 -050017Index: qemu-5.1.0/configure
18===================================================================
19--- qemu-5.1.0.orig/configure
20+++ qemu-5.1.0/configure
21@@ -3084,6 +3084,30 @@ has_libgcrypt() {
Brad Bishop79641f22019-09-10 07:20:22 -040022 return 0
23 }
24
25+has_libgcrypt_pkgconfig() {
26+ if ! has $pkg_config ; then
27+ return 1
28+ fi
29+
30+ if ! $pkg_config --list-all | grep libgcrypt > /dev/null 2>&1 ; then
31+ return 1
32+ fi
33+
34+ if test -n "$cross_prefix" ; then
35+ host=$($pkg_config --variable=host libgcrypt)
36+ if test "${host%-gnu}-" != "${cross_prefix%-gnu}" ; then
37+ print_error "host($host) does not match cross_prefix($cross_prefix)"
38+ return 1
39+ fi
40+ fi
41+
42+ if ! $pkg_config --atleast-version=1.5.0 libgcrypt ; then
43+ print_error "libgcrypt version is $($pkg_config --modversion libgcrypt)"
44+ return 1
45+ fi
46+
47+ return 0
48+}
49
50 if test "$nettle" != "no"; then
51 pass="no"
Andrew Geissler635e0e42020-08-21 15:58:33 -050052@@ -3124,7 +3148,14 @@ fi
Brad Bishop79641f22019-09-10 07:20:22 -040053
54 if test "$gcrypt" != "no"; then
55 pass="no"
56- if has_libgcrypt; then
57+ if has_libgcrypt_pkgconfig; then
58+ gcrypt_cflags=$($pkg_config --cflags libgcrypt)
59+ if test "$static" = "yes" ; then
60+ gcrypt_libs=$($pkg_config --libs --static libgcrypt)
61+ else
62+ gcrypt_libs=$($pkg_config --libs libgcrypt)
63+ fi
64+ elif has_libgcrypt; then
65 gcrypt_cflags=$(libgcrypt-config --cflags)
66 gcrypt_libs=$(libgcrypt-config --libs)
67 # Debian has removed -lgpg-error from libgcrypt-config
Andrew Geissler635e0e42020-08-21 15:58:33 -050068@@ -3134,15 +3165,16 @@ if test "$gcrypt" != "no"; then
Brad Bishop79641f22019-09-10 07:20:22 -040069 then
70 gcrypt_libs="$gcrypt_libs -lgpg-error"
71 fi
72+ fi
73
74- # Link test to make sure the given libraries work (e.g for static).
75- write_c_skeleton
76- if compile_prog "" "$gcrypt_libs" ; then
77- LIBS="$gcrypt_libs $LIBS"
78- QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
79- pass="yes"
80- fi
81+ # Link test to make sure the given libraries work (e.g for static).
82+ write_c_skeleton
83+ if compile_prog "" "$gcrypt_libs" ; then
84+ LIBS="$gcrypt_libs $LIBS"
85+ QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
86+ pass="yes"
87 fi
88+
89 if test "$pass" = "yes"; then
90 gcrypt="yes"
91 cat > $TMPC << EOF