Skip to content

Commit 5761251

Browse files
committed
configure, meson: convert crypto detection to meson
Reviewed-by: Richard Henderson <[email protected]> Reviewed-by: Daniel P. Berrangé <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 4c1f23c commit 5761251

File tree

5 files changed

+90
-232
lines changed

5 files changed

+90
-232
lines changed

configure

Lines changed: 10 additions & 178 deletions
Original file line numberDiff line numberDiff line change
@@ -404,10 +404,9 @@ seccomp="auto"
404404
glusterfs="auto"
405405
gtk="auto"
406406
tls_priority="NORMAL"
407-
gnutls="$default_feature"
408-
nettle="$default_feature"
409-
gcrypt="$default_feature"
410-
qemu_private_xts="yes"
407+
gnutls="auto"
408+
nettle="auto"
409+
gcrypt="auto"
411410
auth_pam="$default_feature"
412411
vte="$default_feature"
413412
virglrenderer="$default_feature"
@@ -1372,17 +1371,17 @@ for opt do
13721371
;;
13731372
--tls-priority=*) tls_priority="$optarg"
13741373
;;
1375-
--disable-gnutls) gnutls="no"
1374+
--disable-gnutls) gnutls="disabled"
13761375
;;
1377-
--enable-gnutls) gnutls="yes"
1376+
--enable-gnutls) gnutls="enabled"
13781377
;;
1379-
--disable-nettle) nettle="no"
1378+
--disable-nettle) nettle="disabled"
13801379
;;
1381-
--enable-nettle) nettle="yes"
1380+
--enable-nettle) nettle="enabled"
13821381
;;
1383-
--disable-gcrypt) gcrypt="no"
1382+
--disable-gcrypt) gcrypt="disabled"
13841383
;;
1385-
--enable-gcrypt) gcrypt="yes"
1384+
--enable-gcrypt) gcrypt="enabled"
13861385
;;
13871386
--disable-auth-pam) auth_pam="no"
13881387
;;
@@ -2800,156 +2799,6 @@ EOF
28002799
fi
28012800
fi
28022801

2803-
##########################################
2804-
# GNUTLS probe
2805-
2806-
if test "$gnutls" != "no"; then
2807-
pass="no"
2808-
if $pkg_config --exists "gnutls >= 3.5.18"; then
2809-
gnutls_cflags=$($pkg_config --cflags gnutls)
2810-
gnutls_libs=$($pkg_config --libs gnutls)
2811-
# Packaging for the static libraries is not always correct.
2812-
# At least ubuntu 18.04 ships only shared libraries.
2813-
write_c_skeleton
2814-
if compile_prog "" "$gnutls_libs" ; then
2815-
pass="yes"
2816-
fi
2817-
fi
2818-
if test "$pass" = "no" && test "$gnutls" = "yes"; then
2819-
feature_not_found "gnutls" "Install gnutls devel >= 3.1.18"
2820-
else
2821-
gnutls="$pass"
2822-
fi
2823-
fi
2824-
2825-
2826-
# If user didn't give a --disable/enable-gcrypt flag,
2827-
# then mark as disabled if user requested nettle
2828-
# explicitly
2829-
if test -z "$gcrypt"
2830-
then
2831-
if test "$nettle" = "yes"
2832-
then
2833-
gcrypt="no"
2834-
fi
2835-
fi
2836-
2837-
# If user didn't give a --disable/enable-nettle flag,
2838-
# then mark as disabled if user requested gcrypt
2839-
# explicitly
2840-
if test -z "$nettle"
2841-
then
2842-
if test "$gcrypt" = "yes"
2843-
then
2844-
nettle="no"
2845-
fi
2846-
fi
2847-
2848-
has_libgcrypt() {
2849-
if ! has "libgcrypt-config"
2850-
then
2851-
return 1
2852-
fi
2853-
2854-
if test -n "$cross_prefix"
2855-
then
2856-
host=$(libgcrypt-config --host)
2857-
if test "$host-" != $cross_prefix
2858-
then
2859-
return 1
2860-
fi
2861-
fi
2862-
2863-
maj=`libgcrypt-config --version | awk -F . '{print $1}'`
2864-
min=`libgcrypt-config --version | awk -F . '{print $2}'`
2865-
2866-
if test $maj != 1 || test $min -lt 8
2867-
then
2868-
return 1
2869-
fi
2870-
2871-
return 0
2872-
}
2873-
2874-
2875-
if test "$nettle" != "no"; then
2876-
pass="no"
2877-
if $pkg_config --exists "nettle >= 3.4"; then
2878-
nettle_cflags=$($pkg_config --cflags nettle)
2879-
nettle_libs=$($pkg_config --libs nettle)
2880-
# Link test to make sure the given libraries work (e.g for static).
2881-
write_c_skeleton
2882-
if compile_prog "" "$nettle_libs" ; then
2883-
if test -z "$gcrypt"; then
2884-
gcrypt="no"
2885-
fi
2886-
pass="yes"
2887-
fi
2888-
fi
2889-
if test "$pass" = "yes"
2890-
then
2891-
cat > $TMPC << EOF
2892-
#include <nettle/xts.h>
2893-
int main(void) {
2894-
return 0;
2895-
}
2896-
EOF
2897-
if compile_prog "$nettle_cflags" "$nettle_libs" ; then
2898-
qemu_private_xts=no
2899-
fi
2900-
fi
2901-
if test "$pass" = "no" && test "$nettle" = "yes"; then
2902-
feature_not_found "nettle" "Install nettle devel >= 2.7.1"
2903-
else
2904-
nettle="$pass"
2905-
fi
2906-
fi
2907-
2908-
if test "$gcrypt" != "no"; then
2909-
pass="no"
2910-
if has_libgcrypt; then
2911-
gcrypt_cflags=$(libgcrypt-config --cflags)
2912-
gcrypt_libs=$(libgcrypt-config --libs)
2913-
# Debian has removed -lgpg-error from libgcrypt-config
2914-
# as it "spreads unnecessary dependencies" which in
2915-
# turn breaks static builds...
2916-
if test "$static" = "yes"
2917-
then
2918-
gcrypt_libs="$gcrypt_libs -lgpg-error"
2919-
fi
2920-
2921-
# Link test to make sure the given libraries work (e.g for static).
2922-
write_c_skeleton
2923-
if compile_prog "" "$gcrypt_libs" ; then
2924-
pass="yes"
2925-
fi
2926-
fi
2927-
if test "$pass" = "yes"; then
2928-
gcrypt="yes"
2929-
cat > $TMPC << EOF
2930-
#include <gcrypt.h>
2931-
int main(void) {
2932-
gcry_cipher_hd_t handle;
2933-
gcry_cipher_open(&handle, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_XTS, 0);
2934-
return 0;
2935-
}
2936-
EOF
2937-
if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
2938-
qemu_private_xts=no
2939-
fi
2940-
elif test "$gcrypt" = "yes"; then
2941-
feature_not_found "gcrypt" "Install gcrypt devel >= 1.5.0"
2942-
else
2943-
gcrypt="no"
2944-
fi
2945-
fi
2946-
2947-
2948-
if test "$gcrypt" = "yes" && test "$nettle" = "yes"
2949-
then
2950-
error_exit "Only one of gcrypt & nettle can be enabled"
2951-
fi
2952-
29532802
##########################################
29542803
# libtasn1 - only for the TLS creds/session test suite
29552804

@@ -5705,24 +5554,6 @@ if test "$gdbus_codegen" != "" ; then
57055554
echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
57065555
fi
57075556
echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
5708-
if test "$gnutls" = "yes" ; then
5709-
echo "CONFIG_GNUTLS=y" >> $config_host_mak
5710-
echo "GNUTLS_CFLAGS=$gnutls_cflags" >> $config_host_mak
5711-
echo "GNUTLS_LIBS=$gnutls_libs" >> $config_host_mak
5712-
fi
5713-
if test "$gcrypt" = "yes" ; then
5714-
echo "CONFIG_GCRYPT=y" >> $config_host_mak
5715-
echo "GCRYPT_CFLAGS=$gcrypt_cflags" >> $config_host_mak
5716-
echo "GCRYPT_LIBS=$gcrypt_libs" >> $config_host_mak
5717-
fi
5718-
if test "$nettle" = "yes" ; then
5719-
echo "CONFIG_NETTLE=y" >> $config_host_mak
5720-
echo "NETTLE_CFLAGS=$nettle_cflags" >> $config_host_mak
5721-
echo "NETTLE_LIBS=$nettle_libs" >> $config_host_mak
5722-
fi
5723-
if test "$qemu_private_xts" = "yes" ; then
5724-
echo "CONFIG_QEMU_PRIVATE_XTS=y" >> $config_host_mak
5725-
fi
57265557
if test "$tasn1" = "yes" ; then
57275558
echo "CONFIG_TASN1=y" >> $config_host_mak
57285559
fi
@@ -6439,6 +6270,7 @@ if test "$skip_meson" = no; then
64396270
-Dcurl=$curl -Dglusterfs=$glusterfs -Dbzip2=$bzip2 -Dlibiscsi=$libiscsi \
64406271
-Dlibnfs=$libnfs -Diconv=$iconv -Dcurses=$curses -Dlibudev=$libudev\
64416272
-Drbd=$rbd -Dlzo=$lzo -Dsnappy=$snappy -Dlzfse=$lzfse \
6273+
-Dgnutls=$gnutls -Dnettle=$nettle -Dgcrypt=$gcrypt \
64426274
-Dzstd=$zstd -Dseccomp=$seccomp -Dvirtfs=$virtfs -Dcap_ng=$cap_ng \
64436275
-Dattr=$attr -Ddefault_devices=$default_devices \
64446276
-Ddocs=$docs -Dsphinx_build=$sphinx_build -Dinstall_blobs=$blobs \

crypto/meson.build

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,48 +22,31 @@ crypto_ss.add(files(
2222
'tlssession.c',
2323
))
2424

25-
if 'CONFIG_NETTLE' in config_host
26-
crypto_ss.add(files('hash-nettle.c', 'hmac-nettle.c', 'pbkdf-nettle.c'))
27-
elif 'CONFIG_GCRYPT' in config_host
28-
crypto_ss.add(files('hash-gcrypt.c', 'pbkdf-gcrypt.c'))
29-
crypto_ss.add(files('hmac-gcrypt.c'))
25+
if nettle.found()
26+
crypto_ss.add(nettle, files('hash-nettle.c', 'hmac-nettle.c', 'pbkdf-nettle.c'))
27+
elif gcrypt.found()
28+
crypto_ss.add(gcrypt, files('hash-gcrypt.c', 'hmac-gcrypt.c', 'pbkdf-gcrypt.c'))
3029
else
3130
crypto_ss.add(files('hash-glib.c', 'hmac-glib.c', 'pbkdf-stub.c'))
3231
endif
32+
if xts == 'private'
33+
crypto_ss.add(files('xts.c'))
34+
endif
3335

3436
crypto_ss.add(when: 'CONFIG_SECRET_KEYRING', if_true: files('secret_keyring.c'))
35-
crypto_ss.add(when: 'CONFIG_QEMU_PRIVATE_XTS', if_true: files('xts.c'))
3637
crypto_ss.add(when: 'CONFIG_AF_ALG', if_true: files('afalg.c', 'cipher-afalg.c', 'hash-afalg.c'))
37-
crypto_ss.add(when: 'CONFIG_GNUTLS', if_true: files('tls-cipher-suites.c'))
38-
39-
if 'CONFIG_NETTLE' in config_host
40-
crypto_ss.add(nettle)
41-
elif 'CONFIG_GCRYPT' in config_host
42-
crypto_ss.add(gcrypt)
43-
endif
44-
45-
if 'CONFIG_GNUTLS' in config_host
46-
crypto_ss.add(gnutls)
47-
endif
48-
38+
crypto_ss.add(when: gnutls, if_true: files('tls-cipher-suites.c'))
4939

5040
util_ss.add(files('aes.c'))
5141
util_ss.add(files('init.c'))
5242

53-
if 'CONFIG_GCRYPT' in config_host
54-
util_ss.add(files('random-gcrypt.c'))
55-
elif 'CONFIG_GNUTLS' in config_host
56-
util_ss.add(files('random-gnutls.c'))
43+
if gcrypt.found()
44+
util_ss.add(gcrypt, files('random-gcrypt.c'))
45+
elif gnutls.found()
46+
util_ss.add(gnutls, files('random-gnutls.c'))
5747
elif 'CONFIG_RNG_NONE' in config_host
5848
util_ss.add(files('random-none.c'))
5949
else
6050
util_ss.add(files('random-platform.c'))
6151
endif
6252

63-
if 'CONFIG_GCRYPT' in config_host
64-
util_ss.add(gcrypt)
65-
endif
66-
67-
if 'CONFIG_GNUTLS' in config_host
68-
util_ss.add(gnutls)
69-
endif

0 commit comments

Comments
 (0)