]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
meson: Only build libmount when required
authorJordan Williams <jordan@jwillikers.com>
Fri, 5 Apr 2024 14:49:17 +0000 (07:49 -0700)
committerJordan Williams <jordan@jwillikers.com>
Fri, 5 Apr 2024 15:56:24 +0000 (08:56 -0700)
It is not currently possible to build any part of util-linux without
building libmount when using Meson.
The libuuid library is commonly used on macOS, where it is not possible
to build libmount.
To address this, this PR makes it possible to build without libmount and
 libblkid.

Options have been added to allow toggling whether to build targets that
require libmount.
This makes it possible to fully disable building libmount.

The python object had to be defined outside of the meson.build file in
libmount/python since this may no longer be included.
The python object is used for tests.

Signed-off-by: Jordan Williams <jordan@jwillikers.com>
libblkid/meson.build
libmount/meson.build
libmount/python/meson.build
meson.build
meson_options.txt

index b2161c6214144ada86fad0bc1007bafc34663b0c..8d1d880aa1d45842eaf423584fb945650b3cc2d8 100644 (file)
@@ -1,4 +1,9 @@
 dir_libblkid = include_directories('.', 'src')
+if not build_libblkid
+  blkid_dep = disabler()
+  blkid_static_dep = disabler()
+  subdir_done()
+endif
 
 defs = configuration_data()
 defs.set('LIBBLKID_DATE', libblkid_date)
@@ -147,12 +152,10 @@ blkid_dep = declare_dependency(link_with: lib_blkid, include_directories: '.')
 lib_blkid_static = lib_blkid.get_static_lib()
 blkid_static_dep = declare_dependency(link_with: lib_blkid_static, include_directories: '.')
 
-if build_libblkid
-  pkgconfig.generate(lib_blkid,
-                     description : 'Block device id library',
-                     subdirs : 'blkid',
-                     version : pc_version)
-  if meson.version().version_compare('>=0.54.0')
-    meson.override_dependency('blkid', blkid_dep)
-  endif
+pkgconfig.generate(lib_blkid,
+                    description : 'Block device id library',
+                    subdirs : 'blkid',
+                    version : pc_version)
+if meson.version().version_compare('>=0.54.0')
+  meson.override_dependency('blkid', blkid_dep)
 endif
index 2534191faf90c25299e19f07aba6992435493cd8..6b16aab94dc036a06a4716d71af7ab0487bacfe1 100644 (file)
@@ -1,3 +1,9 @@
+if not build_libmount
+  mount_dep = disabler()
+  mount_static_dep = disabler()
+  subdir_done()
+endif
+
 dir_libmount = include_directories('.', 'src')
 
 defs = configuration_data()
@@ -99,14 +105,12 @@ lib_mount = library(
   install : build_libmount)
 mount_dep = declare_dependency(link_with: lib_mount, include_directories: '.')
 
-if build_libmount
-  pkgconfig.generate(lib_mount,
-                     description : 'mount library',
-                     subdirs : 'libmount',
-                     version : pc_version)
-  if meson.version().version_compare('>=0.54.0')
-    meson.override_dependency('mount', mount_dep)
-  endif
+pkgconfig.generate(lib_mount,
+                    description : 'mount library',
+                    subdirs : 'libmount',
+                    version : pc_version)
+if meson.version().version_compare('>=0.54.0')
+  meson.override_dependency('mount', mount_dep)
 endif
 
 libmount_tests = [
index 702ca8f378ab9045138ade856ea2cd63c637dd90..0957bca06b01111598ee8326c9bf68216c838882 100644 (file)
@@ -1,9 +1,3 @@
-python_module = import('python')
-
-python = python_module.find_installation(
-    get_option('python'),
-    required : get_option('build-python'),
-    disabler : true)
 build_python = python.found()
 
 pylibmount_sources = '''
index 6c459473086d592bc6d8d0f5574dc24b75d0101b..0095ad6f7c988d34ab6d34b69aa84ff9c47d6c37 100644 (file)
@@ -78,7 +78,7 @@ conf.set_quoted('ADJTIME_PATH', '/etc/adjtime') # yes, both are used :(
 conf.set_quoted('_PATH_VENDORDIR', vendordir)
 conf.set('USE_VENDORDIR', vendordir == '' ? false : 1)
 
-build_libblkid = not get_option('build-libblkid').disabled()
+build_libblkid = not get_option('build-libblkid').require(get_option('build-libmount').allowed()).disabled()
 conf.set('HAVE_LIBBLKID', build_libblkid ? 1 : false)
 summary('libblkid', build_libblkid ? 'enabled' : 'disabled', section : 'components')
 
@@ -101,7 +101,8 @@ 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 = not get_option('build-libmount').disabled()
+build_libmount = get_option('build-libmount').require(get_option('build-libblkid').allowed()).allowed()
+
 conf.set('HAVE_LIBMOUNT', build_libmount ? 1 : false)
 conf.set('USE_LIBMOUNT_SUPPORT_NAMESPACES', 1)
 conf.set('USE_LIBMOUNT_MOUNTFD_SUPPORT', have_mountfd_api ? 1 : false)
@@ -111,7 +112,7 @@ build_libsmartcols = not get_option('build-libsmartcols').disabled()
 conf.set('HAVE_LIBSMARTCOLS', build_libsmartcols ? 1 : false)
 summary('libsmartcols', build_libsmartcols ? 'enabled' : 'disabled', section : 'components')
 
-build_libfdisk = not get_option('build-libfdisk').disabled()
+build_libfdisk = not get_option('build-libfdisk').require(get_option('build-libblkid').allowed()).disabled()
 conf.set('HAVE_LIBFDISK', build_libfdisk ? 1 : false)
 summary('libfdisk', build_libfdisk ? 'enabled' : 'disabled', section : 'components')
 
@@ -905,6 +906,12 @@ bison_gen = generator(
   output : ['@BASENAME@.tab.c', '@BASENAME@.tab.h'],
   arguments : ['@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@'])
 
+python_module = import('python')
+python = python_module.find_installation(
+    get_option('python'),
+    required : true,
+    disabler : true)
+
 meson_make_symlink = meson.current_source_dir() + '/tools/meson-make-symlink.sh'
 meson_make_manpage_stub = meson.current_source_dir() + '/tools/meson-make-manpage-stub.sh'
 
@@ -1497,6 +1504,7 @@ if opt and not is_disabler(exe)
   bashcompletions += ['tunelp']
 endif
 
+opt = not get_option('build-fstrim').disabled()
 exe = executable(
   'fstrim',
   fstrim_sources,
@@ -1504,8 +1512,9 @@ exe = executable(
   link_with : [lib_common],
   dependencies : [mount_dep],
   install_dir : sbindir,
-  install : true)
-if not is_disabler(exe)
+  install : opt,
+  build_by_default : opt)
+if opt and not is_disabler(exe)
   exes += exe
   manadocs += ['sys-utils/fstrim.8.adoc']
   bashcompletions += ['fstrim']
@@ -1724,6 +1733,7 @@ if not is_disabler(exe)
   bashcompletions += ['prlimit']
 endif
 
+opt = not get_option('build-lsns').disabled()
 exe = executable(
   'lsns',
   lsns_sources,
@@ -1732,8 +1742,9 @@ exe = executable(
                lib_smartcols],
   dependencies : [mount_dep],
   install_dir : usrbin_exec_dir,
-  install : true)
-if not is_disabler(exe)
+  install : opt,
+  build_by_default : opt)
+if opt and not is_disabler(exe)
   exes += exe
   manadocs += ['sys-utils/lsns.8.adoc']
   bashcompletions += ['lsns']
@@ -1798,6 +1809,7 @@ endif
 
 # setuid?
 
+opt = not get_option('build-swapon').disabled()
 exe = executable(
   'swapon',
   swapon_sources,
@@ -1806,13 +1818,15 @@ exe = executable(
                lib_smartcols],
   dependencies : [blkid_dep, mount_dep],
   install_dir : sbindir,
-  install : true)
-if not is_disabler(exe)
+  install : opt,
+  build_by_default : opt)
+if opt and not is_disabler(exe)
   exes += exe
   manadocs += ['sys-utils/swapon.8.adoc']
   bashcompletions += ['swapon']
 endif
 
+opt = not get_option('build-swapoff').disabled()
 exe = executable(
   'swapoff',
   swapoff_sources,
@@ -1820,8 +1834,9 @@ exe = executable(
   link_with : [lib_common],
   dependencies : [blkid_dep, mount_dep],
   install_dir : sbindir,
-  install : true)
-if not is_disabler(exe)
+  install : opt,
+  build_by_default : opt)
+if opt and not is_disabler(exe)
   exes += exe
   manlinks += {'swapoff.8': 'swapon.8'}
   bashcompletions += ['swapoff']
@@ -2719,6 +2734,7 @@ exes += exe
 manadocs += ['misc-utils/whereis.1.adoc']
 bashcompletions += ['whereis']
 
+opt = not get_option('build-lslocks').disabled()
 exe = executable(
   'lslocks',
   lslocks_sources,
@@ -2727,13 +2743,15 @@ exe = executable(
                lib_smartcols],
   dependencies : [mount_dep],
   install_dir : usrbin_exec_dir,
-  install : true)
-if not is_disabler(exe)
+  install : opt,
+  build_by_default : opt)
+if opt and not is_disabler(exe)
   exes += exe
   manadocs += ['misc-utils/lslocks.8.adoc']
   bashcompletions += ['lslocks']
 endif
 
+opt = not get_option('build-lsblk').disabled()
 exe = executable(
   'lsblk',
   lsblk_sources,
@@ -2742,8 +2760,9 @@ exe = executable(
                lib_tcolors,
                lib_smartcols],
   dependencies : [blkid_dep, lib_udev, mount_dep],
-  install : true)
-if not is_disabler(exe)
+  install : opt,
+  build_by_default : opt)
+if opt and not is_disabler(exe)
   exes += exe
   manadocs += ['misc-utils/lsblk.8.adoc']
   bashcompletions += ['lsblk']
@@ -2932,6 +2951,7 @@ if not is_disabler(exe)
   bashcompletions += ['wipefs']
 endif
 
+opt = not get_option('build-findmnt').disabled()
 exe = executable(
   'findmnt',
   findmnt_sources,
@@ -2939,8 +2959,9 @@ exe = executable(
   link_with : [lib_common,
                lib_smartcols],
   dependencies : [blkid_dep, lib_udev, mount_dep],
-  install : true)
-if not is_disabler(exe)
+  install : opt,
+  build_by_default : opt)
+if opt and not is_disabler(exe)
   exes += exe
   manadocs += ['misc-utils/findmnt.8.adoc']
   bashcompletions += ['findmnt']
index 1bc0bc2ecfc695c2c8cf5c6edfc051972b5722d7..95cfb820daaf3469ee0b308a14f596d613d57f70 100644 (file)
@@ -53,10 +53,16 @@ option('build-fdisks', type : 'feature',
        description : 'build fdisk(8), sfdisk(8) and cfdisk(8)')
 option('build-mount', type : 'feature',
        description : 'build mount(8) and umount(8)')
+option('build-swapon', type : 'feature',
+       description : 'build swapon')
+option('build-swapoff', type : 'feature',
+       description : 'build swapoff')
 option('build-losetup', type : 'feature',
        description : 'build losetup')
 option('build-zramctl', type : 'feature',
        description : 'build zramctl')
+option('build-lsns', type : 'feature',
+       description : 'build lsns')
 option('build-fsck', type : 'feature',
        description : 'build fsck')
 option('build-partx', type : 'feature',
@@ -101,6 +107,12 @@ option('build-cal', type : 'feature',
        description : 'build cal')
 option('build-logger', type : 'feature',
        description : 'build logger')
+option('build-lsblk', type : 'feature',
+       description : 'build lsblk')
+option('build-lslocks', type : 'feature',
+       description : 'build lslocks')
+option('build-findmnt', type : 'feature',
+       description : 'build findmnt')
 option('build-lsfd', type : 'feature',
        description : 'build lsfd')
 option('build-switch_root', type : 'feature',
@@ -123,6 +135,8 @@ option('build-rfkill', type : 'feature',
        description : 'build rfkill')
 option('build-tunelp', type : 'feature',
        description : 'build tunelp')
+option('build-fstrim', type : 'feature',
+       description : 'build fstrim')
 option('build-kill', type : 'feature',
        description : 'build kill')
 option('build-last', type : 'feature',