This way meson will try to do the right thing by default but we will
allow users to change this behavior by using -Dname=enabled. This comes
with two benefits compared to the previous behavior:
- no need to install the binaries if developers would like to check
that the code compiles correctly
- package maintainers can drop some build dependencies
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
meson.build | 102 ++++++++++++++++++++++++++++++++--------------------
1 file changed, 63 insertions(+), 39 deletions(-)
diff --git a/meson.build b/meson.build
index 2900b6e1a8..8e8d31953d 100644
--- a/meson.build
+++ b/meson.build
@@ -977,12 +977,6 @@ endif
libparted_version = '1.8.0'
libparted_dep = dependency('libparted', version: '>=' +
libparted_version, required: false)
-if libparted_dep.found()
- parted_prog = find_program('parted', required: false, dirs: libvirt_sbin_path)
- if not parted_prog.found()
- libparted_dep = dependency('', required: false)
- endif
-endif
libpcap_version = '1.5.0'
if not get_option('libpcap').disabled()
@@ -1420,11 +1414,17 @@ if not get_option('driver_libvirtd').disabled()
endif
if not get_option('driver_bhyve').disabled() and host_machine.system() ==
'freebsd'
- bhyve_prog = find_program('bhyve', required:
get_option('driver_bhyve'))
- bhyvectl_prog = find_program('bhyvectl', required:
get_option('driver_bhyve'))
- bhyveload_prog = find_program('bhyveload', required:
get_option('driver_bhyve'))
+ bhyve_enable = true
- if bhyve_prog.found() and bhyvectl_prog.found() and bhyveload_prog.found()
+ if get_option('driver_bhyve').auto()
+ bhyve_prog = find_program('bhyve', required: false)
+ bhyvectl_prog = find_program('bhyvectl', required: false)
+ bhyveload_prog = find_program('bhyveload', required: false)
+
+ bhyve_enable = bhyve_prog.found() and bhyvectl_prog.found() and
bhyveload_prog.found()
+ endif
+
+ if bhyve_enable
conf.set('WITH_BHYVE', 1)
endif
elif get_option('driver_bhyve').enabled()
@@ -1680,8 +1680,17 @@ if conf.has('WITH_LIBVIRTD')
endif
if not get_option('storage_disk').disabled() and devmapper_dep.found() and
libparted_dep.found()
- use_storage = true
- conf.set('WITH_STORAGE_DISK', 1)
+ disk_enable = true
+
+ if get_option('storage_disk').auto()
+ parted_prog = find_program('parted', required: false, dirs:
libvirt_sbin_path)
+ disk_enable = parted_prog.found()
+ endif
+
+ if disk_enable
+ use_storage = true
+ conf.set('WITH_STORAGE_DISK', 1)
+ endif
elif get_option('storage_disk').enabled()
error('You must install libparted and libdevmapper to compile libvirt with disk
storage driver')
endif
@@ -1702,10 +1711,10 @@ if conf.has('WITH_LIBVIRTD')
endif
endif
- if fs_enable
- mount_prog = find_program('mount', required:
get_option('storage_fs'), dirs: libvirt_sbin_path)
- umount_prog = find_program('umount', required:
get_option('storage_fs'), dirs: libvirt_sbin_path)
- mkfs_prog = find_program('mkfs', required:
get_option('storage_fs'), dirs: libvirt_sbin_path)
+ if fs_enable and get_option('storage_fs').auto()
+ mount_prog = find_program('mount', required: false, dirs:
libvirt_sbin_path)
+ umount_prog = find_program('umount', required: false, dirs:
libvirt_sbin_path)
+ mkfs_prog = find_program('mkfs', required: false, dirs: libvirt_sbin_path)
if not mount_prog.found() or not umount_prog.found() or not mkfs_prog.found()
fs_enable = false
@@ -1727,14 +1736,11 @@ if conf.has('WITH_LIBVIRTD')
if not get_option('storage_iscsi').disabled()
iscsi_enable = true
- iscsiadm_prog = find_program('iscsiadm', required: false, dirs:
libvirt_sbin_path)
- if not iscsiadm_prog.found()
- if get_option('storage_iscsi').enabled()
- error('We need iscsiadm for iSCSI storage driver')
- else
- iscsi_enable = false
- endif
+ if get_option('storage_iscsi').auto()
+ iscsiadm_prog = find_program('iscsiadm', required: false, dirs:
libvirt_sbin_path)
+
+ iscsi_enable = iscsiadm_prog.found()
endif
if iscsi_enable
@@ -1758,12 +1764,15 @@ if conf.has('WITH_LIBVIRTD')
'lvchange', 'vgchange', 'vgscan',
'pvs', 'vgs', 'lvs',
]
- foreach name : lvm_progs
- lvm_prog = find_program(name, required: get_option('storage_lvm'), dirs:
libvirt_sbin_path)
- if not lvm_prog.found()
- lvm_enable = false
- endif
- endforeach
+
+ if get_option('storage_lvm').auto()
+ foreach name : lvm_progs
+ lvm_prog = find_program(name, required: false, dirs: libvirt_sbin_path)
+ if not lvm_prog.found()
+ lvm_enable = false
+ endif
+ endforeach
+ endif
if lvm_enable
use_storage = true
@@ -1791,9 +1800,15 @@ if conf.has('WITH_LIBVIRTD')
endif
if not get_option('storage_sheepdog').disabled()
- sheepdogcli_prog = find_program('dog', required:
get_option('storage_sheepdog'), dirs: libvirt_sbin_path)
+ sheepdog_enable = true
- if sheepdogcli_prog.found()
+ if get_option('storage_sheepdog').auto()
+ sheepdogcli_prog = find_program('dog', required: false, dirs:
libvirt_sbin_path)
+
+ sheepdog_enable = sheepdogcli_prog.found()
+ endif
+
+ if sheepdog_enable
use_storage = true
conf.set('WITH_STORAGE_SHEEPDOG', 1)
endif
@@ -1817,12 +1832,15 @@ if conf.has('WITH_LIBVIRTD')
if not get_option('storage_zfs').disabled()
zfs_enable = true
- foreach name : ['zfs', 'zpool']
- zfs_prog = find_program(name, required: get_option('storage_zfs'), dirs:
libvirt_sbin_path)
- if not zfs_prog.found()
- zfs_enable = false
- endif
- endforeach
+
+ if get_option('storage_zfs').auto()
+ foreach name : ['zfs', 'zpool']
+ zfs_prog = find_program(name, required: false, dirs: libvirt_sbin_path)
+ if not zfs_prog.found()
+ zfs_enable = false
+ endif
+ endforeach
+ endif
if zfs_enable
use_storage = true
@@ -1937,8 +1955,14 @@ if not get_option('nss').disabled()
endif
if not get_option('numad').disabled() and numactl_dep.found()
- numad_prog = find_program('numad', required: get_option('numad'), dirs:
libvirt_sbin_path)
- if numad_prog.found()
+ numad_enable = true
+
+ if get_option('numad').auto()
+ numad_prog = find_program('numad', required: false, dirs: libvirt_sbin_path)
+ numad_enable = numad_prog.found()
+ endif
+
+ if numad_enable
conf.set('WITH_NUMAD', 1)
endif
elif get_option('numad').enabled()
--
2.31.1