]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
meson: Require the sys/vfs.h header for libmount and fstrim
authorJordan Williams <jordan@jwillikers.com>
Mon, 8 Apr 2024 16:17:12 +0000 (11:17 -0500)
committerJordan Williams <jordan@jwillikers.com>
Tue, 9 Apr 2024 21:00:17 +0000 (16:00 -0500)
libmount and fstrim both include sys/vfs.h unconditionally.
To avoid an error at compile time, require this header for their
respective feature options to be enabled.
This avoids building them on systems without sys/vfs.h, such as macOS.

Fixes #2932.

Signed-off-by: Jordan Williams <jordan@jwillikers.com>
meson.build

index 21822f0bd426ea0e863edaf74d5077a09fcd385d..3c2e8607499558fee0e6ce984fc52515ed998cf0 100644 (file)
@@ -102,7 +102,12 @@ conf.set('HAVE_MOUNTFD_API', have_mountfd_api ? 1 : false)
 have_struct_statx = cc.sizeof('struct statx', prefix : '#include <sys/stat.h>') > 0
 conf.set('HAVE_STRUCT_STATX', have_struct_statx ? 1 : false)
 
-build_libmount = get_option('build-libmount').require(get_option('build-libblkid').allowed()).allowed()
+have_sys_vfs_header = cc.has_header('sys/vfs.h')
+
+build_libmount = get_option('build-libmount').require(
+  get_option('build-libblkid').allowed() \
+  and have_sys_vfs_header \
+).allowed()
 
 conf.set('HAVE_LIBMOUNT', build_libmount ? 1 : false)
 conf.set('USE_LIBMOUNT_SUPPORT_NAMESPACES', 1)
@@ -1501,7 +1506,7 @@ if opt and not is_disabler(exe)
   bashcompletions += ['tunelp']
 endif
 
-opt = not get_option('build-fstrim').disabled()
+opt = get_option('build-fstrim').require(have_sys_vfs_header).allowed()
 exe = executable(
   'fstrim',
   fstrim_sources,