From b4c7973d495daaa6e011a0ba1a87274252e7b71e Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 26 Jan 2024 13:28:07 +0100 Subject: [PATCH] meson: fix build with missing libudev-devel --- spa/meson.build | 3 ++- spa/plugins/alsa/alsa.c | 5 +++++ spa/plugins/alsa/meson.build | 8 ++++++-- spa/plugins/libcamera/meson.build | 2 +- spa/plugins/meson.build | 5 ++--- spa/plugins/v4l2/meson.build | 9 +++++++-- spa/plugins/v4l2/v4l2.c | 5 +++++ 7 files changed, 28 insertions(+), 9 deletions(-) diff --git a/spa/meson.build b/spa/meson.build index 2fb5811bc..ff07f9ddb 100644 --- a/spa/meson.build +++ b/spa/meson.build @@ -106,7 +106,8 @@ if get_option('spa-plugins').allowed() cdata.set('HAVE_ALSA_COMPRESS_OFFLOAD', compress_offload_option.allowed()) # common dependencies - libudev_dep = dependency('libudev', required: alsa_dep.found() or get_option('udev').enabled() or get_option('v4l2').enabled()) + libudev_dep = dependency('libudev', required: get_option('udev').enabled()) + cdata.set('HAVE_LIBUDEV', libudev_dep.found()) summary({'Udev': libudev_dep.found()}, bool_yn: true, section: 'Backend') subdir('plugins') diff --git a/spa/plugins/alsa/alsa.c b/spa/plugins/alsa/alsa.c index 252e131d0..1bc836097 100644 --- a/spa/plugins/alsa/alsa.c +++ b/spa/plugins/alsa/alsa.c @@ -40,8 +40,13 @@ int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *factory = &spa_alsa_sink_factory; break; case 2: +#ifdef HAVE_LIBUDEV *factory = &spa_alsa_udev_factory; break; +#else + (*index)++; + SPA_FALLTHROUGH; +#endif case 3: *factory = &spa_alsa_pcm_device_factory; break; diff --git a/spa/plugins/alsa/meson.build b/spa/plugins/alsa/meson.build index 5eb2a1810..4282e0bbf 100644 --- a/spa/plugins/alsa/meson.build +++ b/spa/plugins/alsa/meson.build @@ -1,11 +1,10 @@ subdir('acp') subdir('mixer') -spa_alsa_dependencies = [ spa_dep, alsa_dep, libudev_dep, mathlib, epoll_shim_dep, libinotify_dep ] +spa_alsa_dependencies = [ spa_dep, alsa_dep, mathlib, epoll_shim_dep, libinotify_dep ] spa_alsa_sources = ['alsa.c', 'alsa.h', - 'alsa-udev.c', 'alsa-acp-device.c', 'alsa-pcm-device.c', 'alsa-pcm-sink.c', @@ -14,6 +13,11 @@ spa_alsa_sources = ['alsa.c', 'alsa-seq-bridge.c', 'alsa-seq.c'] +if libudev_dep.found() +spa_alsa_sources += [ 'alsa-udev.c' ] +spa_alsa_dependencies += [ libudev_dep ] +endif + if compress_offload_option.allowed() spa_alsa_sources += ['alsa-compress-offload-sink.c', 'alsa-compress-offload-device.c', diff --git a/spa/plugins/libcamera/meson.build b/spa/plugins/libcamera/meson.build index 5f36b286c..9f396aba2 100644 --- a/spa/plugins/libcamera/meson.build +++ b/spa/plugins/libcamera/meson.build @@ -8,6 +8,6 @@ libcamera_sources = [ libcameralib = shared_library('spa-libcamera', libcamera_sources, include_directories : [ configinc ], - dependencies : [ spa_dep, libudev_dep, libcamera_dep, pthread_lib ], + dependencies : [ spa_dep, libcamera_dep, pthread_lib ], install : true, install_dir : spa_plugindir / 'libcamera') diff --git a/spa/plugins/meson.build b/spa/plugins/meson.build index 210004691..97ba78af7 100644 --- a/spa/plugins/meson.build +++ b/spa/plugins/meson.build @@ -45,10 +45,9 @@ if have_vulkan endif v4l2_header_found = cc.has_header('linux/videodev2.h', required: get_option('v4l2')) -v4l2_supported = libudev_dep.found() and v4l2_header_found summary({'V4L2 kernel header': v4l2_header_found}, bool_yn: true, section: 'Backend') -summary({'V4L2 enabled': v4l2_supported}, bool_yn: true, section: 'Backend') -if v4l2_supported +summary({'V4L2 enabled': v4l2_header_found}, bool_yn: true, section: 'Backend') +if v4l2_header_found subdir('v4l2') endif if libcamera_dep.found() diff --git a/spa/plugins/v4l2/meson.build b/spa/plugins/v4l2/meson.build index 648583f32..1dfe92cf8 100644 --- a/spa/plugins/v4l2/meson.build +++ b/spa/plugins/v4l2/meson.build @@ -1,10 +1,15 @@ v4l2_sources = ['v4l2.c', 'v4l2-device.c', - 'v4l2-udev.c', 'v4l2-source.c'] +v4l2_dependencies = [ spa_dep, libinotify_dep ] + +if libudev_dep.found() +v4l2_sources += [ 'v4l2-udev.c' ] +v4l2_dependencies += [ libudev_dep ] +endif v4l2lib = shared_library('spa-v4l2', v4l2_sources, - dependencies : [ spa_dep, libudev_dep, libinotify_dep ], + dependencies : v4l2_dependencies, install : true, install_dir : spa_plugindir / 'v4l2') diff --git a/spa/plugins/v4l2/v4l2.c b/spa/plugins/v4l2/v4l2.c index 843fbb1b6..ed39f3bd5 100644 --- a/spa/plugins/v4l2/v4l2.c +++ b/spa/plugins/v4l2/v4l2.c @@ -29,8 +29,13 @@ int spa_handle_factory_enum(const struct spa_handle_factory **factory, *factory = &spa_v4l2_source_factory; break; case 1: +#ifdef HAVE_LIBUDEV *factory = &spa_v4l2_udev_factory; break; +#else + (*index)++; + SPA_FALLTHROUGH; +#endif case 2: *factory = &spa_v4l2_device_factory; break;