aboutsummaryrefslogtreecommitdiff
path: root/meson.build
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2020-09-16 18:07:29 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2020-09-30 19:11:35 +0200
commit6ec0e15d95da4e80bc890933e3e5bc11f6b54118 (patch)
treea8be05439e7fbc9c574196fca1537328c051742e /meson.build
parentf01496a314d916949ef84426d6cdd34f50447bb7 (diff)
meson: move libmpathpersist test
This is the first compiler/linker test that has been moved to Meson. Add more section headings to keep things clearer. This also fixes static linking to libmpathpersist, which has a dependency on libmultipath but no pkg-config file to describe it. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build81
1 files changed, 74 insertions, 7 deletions
diff --git a/meson.build b/meson.build
index cd3d1ee260..8e9cd67235 100644
--- a/meson.build
+++ b/meson.build
@@ -86,6 +86,14 @@ if 'SPARSE_CFLAGS' in config_host
'compile_commands.json'])
endif
+###########################################
+# Target-specific checks and dependencies #
+###########################################
+
+if targetos != 'linux' and get_option('mpath').enabled()
+ error('Multipath is supported only on Linux')
+endif
+
m = cc.find_library('m', required: false)
util = cc.find_library('util', required: false)
winmm = []
@@ -117,6 +125,11 @@ elif targetos == 'haiku'
cc.find_library('network'),
cc.find_library('bsd')]
endif
+
+################
+# Dependencies #
+################
+
# The path to glib.h is added to all compilation commands. This was
# grandfathered in from the QEMU Makefiles.
add_project_arguments(config_host['GLIB_CFLAGS'].split(),
@@ -223,10 +236,6 @@ if 'CONFIG_SPICE' in config_host
link_args: config_host['SPICE_LIBS'].split())
endif
rt = cc.find_library('rt', required: false)
-libmpathpersist = not_found
-if config_host.has_key('CONFIG_MPATH')
- libmpathpersist = cc.find_library('mpathpersist')
-endif
libdl = not_found
if 'CONFIG_PLUGIN' in config_host
libdl = cc.find_library('dl', required: true)
@@ -258,8 +267,64 @@ if 'CONFIG_CURL' in config_host
endif
libudev = not_found
if targetos == 'linux' and (have_system or have_tools)
- libudev = dependency('libudev', static: enable_static)
+ libudev = dependency('libudev',
+ required: get_option('mpath').enabled(),
+ static: enable_static)
+endif
+
+mpathpersist = not_found
+mpathpersist_new_api = false
+if targetos == 'linux' and have_tools and not get_option('mpath').disabled()
+ mpath_test_source_new = '''
+ #include <libudev.h>
+ #include <mpath_persist.h>
+ unsigned mpath_mx_alloc_len = 1024;
+ int logsink;
+ static struct config *multipath_conf;
+ extern struct udev *udev;
+ extern struct config *get_multipath_config(void);
+ extern void put_multipath_config(struct config *conf);
+ struct udev *udev;
+ struct config *get_multipath_config(void) { return multipath_conf; }
+ void put_multipath_config(struct config *conf) { }
+ int main(void) {
+ udev = udev_new();
+ multipath_conf = mpath_lib_init();
+ return 0;
+ }'''
+ mpath_test_source_old = '''
+ #include <libudev.h>
+ #include <mpath_persist.h>
+ unsigned mpath_mx_alloc_len = 1024;
+ int logsink;
+ int main(void) {
+ struct udev *udev = udev_new();
+ mpath_lib_init(udev);
+ return 0;
+ }'''
+ libmultipath = cc.find_library('multipath',
+ required: get_option('mpath'),
+ static: enable_static)
+ libmpathpersist = cc.find_library('mpathpersist',
+ required: get_option('mpath'),
+ static: enable_static)
+ if libmultipath.found() and libmpathpersist.found() and libudev.found()
+ mpathlibs = [libmultipath, libmpathpersist, libudev]
+ if cc.links(mpath_test_source_new, dependencies: mpathlibs)
+ mpathpersist = declare_dependency(dependencies: mpathlibs)
+ mpathpersist_new_api = true
+ elif cc.links(mpath_test_source_old, dependencies: mpathlibs)
+ mpathpersist = declare_dependency(dependencies: mpathlibs)
+ else
+ if get_option('mpath').enabled()
+ error('Cannot detect libmpathpersist API')
+ else
+ warning('Cannot detect libmpathpersist API, disabling')
+ endif
+ endif
+ endif
endif
+
brlapi = not_found
if 'CONFIG_BRLAPI' in config_host
brlapi = declare_dependency(link_args: config_host['BRLAPI_LIBS'].split())
@@ -441,6 +506,8 @@ has_gettid = cc.has_function('gettid')
# Create config-host.h
config_host_data.set('CONFIG_LIBUDEV', libudev.found())
+config_host_data.set('CONFIG_MPATH', mpathpersist.found())
+config_host_data.set('CONFIG_MPATH_NEW_API', mpathpersist_new_api)
config_host_data.set('CONFIG_SDL', sdl.found())
config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found())
config_host_data.set('CONFIG_VNC', vnc.found())
@@ -1205,7 +1272,7 @@ if have_tools
executable('qemu-pr-helper', files('scsi/qemu-pr-helper.c', 'scsi/utils.c'),
dependencies: [authz, crypto, io, qom, qemuutil,
- libcap_ng, libudev, libmpathpersist],
+ libcap_ng, mpathpersist],
install: true)
endif
@@ -1342,7 +1409,7 @@ summary_info += {'Audio drivers': config_host['CONFIG_AUDIO_DRIVERS']}
summary_info += {'Block whitelist (rw)': config_host['CONFIG_BDRV_RW_WHITELIST']}
summary_info += {'Block whitelist (ro)': config_host['CONFIG_BDRV_RO_WHITELIST']}
summary_info += {'VirtFS support': config_host.has_key('CONFIG_VIRTFS')}
-summary_info += {'Multipath support': config_host.has_key('CONFIG_MPATH')}
+summary_info += {'Multipath support': mpathpersist.found()}
summary_info += {'VNC support': vnc.found()}
if vnc.found()
summary_info += {'VNC SASL support': sasl.found()}