blob: a8ab7daa4252d8b33238cb7920056215edfb93a3 [file] [log] [blame]
Andrew Geissler84ad7c52020-06-27 00:00:16 -05001From 5214dd4461f2090ef0965b4d2518f49927d61cbc Mon Sep 17 00:00:00 2001
2From: He Zhe <zhe.he@windriver.com>
3Date: Wed, 28 Aug 2019 19:56:28 +0800
4Subject: [Qemu-devel] [PATCH] configure: Add pkg-config handling for libgcrypt
5
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>
12---
13 configure | 48 ++++++++++++++++++++++++++++++++++++++++--------
14 1 file changed, 40 insertions(+), 8 deletions(-)
15
16diff --git a/configure b/configure
17index e44e454..0f362a7 100755
18--- a/configure
19+++ b/configure
20@@ -2875,6 +2875,30 @@ has_libgcrypt() {
21 return 0
22 }
23
24+has_libgcrypt_pkgconfig() {
25+ if ! has $pkg_config ; then
26+ return 1
27+ fi
28+
29+ if ! $pkg_config --list-all | grep libgcrypt > /dev/null 2>&1 ; then
30+ return 1
31+ fi
32+
33+ if test -n "$cross_prefix" ; then
34+ host=$($pkg_config --variable=host libgcrypt)
35+ if test "${host%-gnu}-" != "${cross_prefix%-gnu}" ; then
36+ print_error "host($host) does not match cross_prefix($cross_prefix)"
37+ return 1
38+ fi
39+ fi
40+
41+ if ! $pkg_config --atleast-version=1.5.0 libgcrypt ; then
42+ print_error "libgcrypt version is $($pkg_config --modversion libgcrypt)"
43+ return 1
44+ fi
45+
46+ return 0
47+}
48
49 if test "$nettle" != "no"; then
50 pass="no"
51@@ -2902,7 +2926,14 @@ fi
52
53 if test "$gcrypt" != "no"; then
54 pass="no"
55- if has_libgcrypt; then
56+ if has_libgcrypt_pkgconfig; then
57+ gcrypt_cflags=$($pkg_config --cflags libgcrypt)
58+ if test "$static" = "yes" ; then
59+ gcrypt_libs=$($pkg_config --libs --static libgcrypt)
60+ else
61+ gcrypt_libs=$($pkg_config --libs libgcrypt)
62+ fi
63+ elif has_libgcrypt; then
64 gcrypt_cflags=$(libgcrypt-config --cflags)
65 gcrypt_libs=$(libgcrypt-config --libs)
66 # Debian has removed -lgpg-error from libgcrypt-config
67@@ -2912,15 +2943,16 @@ if test "$gcrypt" != "no"; then
68 then
69 gcrypt_libs="$gcrypt_libs -lgpg-error"
70 fi
71+ fi
72
73- # Link test to make sure the given libraries work (e.g for static).
74- write_c_skeleton
75- if compile_prog "" "$gcrypt_libs" ; then
76- LIBS="$gcrypt_libs $LIBS"
77- QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
78- pass="yes"
79- fi
80+ # Link test to make sure the given libraries work (e.g for static).
81+ write_c_skeleton
82+ if compile_prog "" "$gcrypt_libs" ; then
83+ LIBS="$gcrypt_libs $LIBS"
84+ QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
85+ pass="yes"
86 fi
87+
88 if test "$pass" = "yes"; then
89 gcrypt="yes"
90 cat > $TMPC << EOF
91--
922.7.4
93