diff options
author | Karel Zak <kzak@redhat.com> | 2024-04-08 09:43:15 +0200 |
---|---|---|
committer | Karel Zak <kzak@redhat.com> | 2024-04-08 09:43:15 +0200 |
commit | df72ff49ed5dabb388c4a7c914c272ffd4264471 (patch) | |
tree | ff3022ba3b7ef6152dbd07a9ad8887eff2e06fef | |
parent | 5ce970df73acacbc56f2eb9152ccc56e43fd0f3e (diff) | |
parent | b6799ccbc08aea69a26cdaa97ab436bfae2ae27f (diff) | |
download | util-linux-df72ff49ed5dabb388c4a7c914c272ffd4264471.tar.gz |
Merge branch 'meson-make-libmount-optional' of https://github.com/jwillikers/util-linux
* 'meson-make-libmount-optional' of https://github.com/jwillikers/util-linux:
meson: Only build libmount when required
meson: Use libblkid as a dependency
meson: Use libmount as a dependency
-rw-r--r-- | libblkid/meson.build | 20 | ||||
-rw-r--r-- | libfdisk/meson.build | 4 | ||||
-rw-r--r-- | libmount/meson.build | 44 | ||||
-rw-r--r-- | libmount/python/meson.build | 11 | ||||
-rw-r--r-- | meson.build | 163 | ||||
-rw-r--r-- | meson_options.txt | 14 |
6 files changed, 143 insertions, 113 deletions
diff --git a/libblkid/meson.build b/libblkid/meson.build index 5a28bdfcb8..8d1d880aa1 100644 --- a/libblkid/meson.build +++ b/libblkid/meson.build @@ -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) @@ -145,13 +150,12 @@ lib_blkid = both_libraries( 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 diff --git a/libfdisk/meson.build b/libfdisk/meson.build index eaab9e1389..57dda5cfa9 100644 --- a/libfdisk/meson.build +++ b/libfdisk/meson.build @@ -60,8 +60,8 @@ lib_fdisk_static = static_library( 'fdisk_static', link_whole : lib__fdisk, link_with : [lib_common, - lib_blkid.get_static_lib(), lib_uuid.get_static_lib()], + dependencies : [blkid_static_dep], install : false) lib_fdisk = library( @@ -71,8 +71,8 @@ lib_fdisk = library( version : libfdisk_version, link_args : ['-Wl,--version-script=@0@'.format(libfdisk_sym_path)], link_with : [lib_common, - lib_blkid, lib_uuid], + dependencies : [blkid_dep], install : build_libfdisk) fdisk_dep = declare_dependency(link_with: lib_fdisk, include_directories: '.') diff --git a/libmount/meson.build b/libmount/meson.build index d1262e7f04..6b16aab94d 100644 --- a/libmount/meson.build +++ b/libmount/meson.build @@ -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() @@ -70,16 +76,16 @@ lib__mount = static_library( '_mount', lib_mount_sources, include_directories : [dir_include, - dir_libmount, - dir_libblkid]) + dir_libmount], + dependencies : [blkid_dep]) lib_mount_static = static_library( 'mount_static', link_whole : lib__mount, - link_with : [lib_common, - lib_blkid.get_static_lib()], - dependencies : [realtime_libs], + link_with : [lib_common], + dependencies : [blkid_static_dep, realtime_libs], install : false) +mount_static_dep = declare_dependency(link_with: lib_mount_static, include_directories: '.') lib__mount_deps = [ lib_selinux, @@ -90,25 +96,21 @@ lib_mount = library( 'mount', link_whole : lib__mount, include_directories : [dir_include, - dir_libmount, - dir_libblkid], + dir_libmount], link_depends : libmount_sym, version : libmount_version, link_args : ['-Wl,--version-script=@0@'.format(libmount_sym_path)], - link_with : [lib_common, - lib_blkid], - dependencies : lib__mount_deps, + link_with : [lib_common], + dependencies : lib__mount_deps + blkid_dep, 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 = [ @@ -136,9 +138,9 @@ if program_tests exe = executable( test_name, 'src/' + libmount_test_src_override.get(libmount_test, libmount_test) + '.c', - include_directories : [dir_include, dir_libblkid], - link_with : [lib__mount, lib_common, lib_blkid_static], - dependencies : lib__mount_deps, + include_directories : [dir_include], + link_with : [lib__mount, lib_common], + dependencies : lib__mount_deps + blkid_static_dep, c_args : ['-DTEST_PROGRAM'], ) # the test-setup expects the helpers in the toplevel build-directory diff --git a/libmount/python/meson.build b/libmount/python/meson.build index e1a79d187d..0957bca06b 100644 --- a/libmount/python/meson.build +++ b/libmount/python/meson.build @@ -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 = ''' @@ -21,10 +15,9 @@ if build_python python.extension_module( 'pylibmount', pylibmount_sources, - include_directories : [dir_include, dir_libmount], + include_directories : [dir_include], subdir : 'libmount', - link_with : lib_mount, - dependencies : python.dependency(), + dependencies : [mount_dep, python.dependency()], c_args : [ '-Wno-cast-function-type', diff --git a/meson.build b/meson.build index 0e386dd1a9..e65cd9582f 100644 --- a/meson.build +++ b/meson.build @@ -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' @@ -973,9 +980,7 @@ subdir('term-utils') subdir('po') includes = [dir_include, - dir_libblkid, dir_libsmartcols, - dir_libmount, dir_libfdisk, dir_libuuid, dir_liblastlog2, @@ -1499,15 +1504,17 @@ if opt and not is_disabler(exe) bashcompletions += ['tunelp'] endif +opt = not get_option('build-fstrim').disabled() exe = executable( 'fstrim', fstrim_sources, include_directories : includes, - link_with : [lib_common, - lib_mount], + 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'] @@ -1563,8 +1570,8 @@ exe = executable( 'blkdiscard', blkdiscard_sources, include_directories : includes, - link_with : [lib_common, - lib_blkid], + link_with : [lib_common], + dependencies : [blkid_dep], install_dir : sbindir, install : true) exes += exe @@ -1654,8 +1661,8 @@ exe = executable( 'eject', eject_sources, include_directories : includes, - link_with : [lib_common, - lib_mount], + link_with : [lib_common], + dependencies : [mount_dep], install_dir : usrbin_exec_dir, install : opt, build_by_default : opt) @@ -1726,16 +1733,18 @@ if not is_disabler(exe) bashcompletions += ['prlimit'] endif +opt = not get_option('build-lsns').disabled() exe = executable( 'lsns', lsns_sources, include_directories : includes, link_with : [lib_common, - lib_smartcols, - lib_mount], + 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'] @@ -1747,9 +1756,8 @@ exe = executable( mount_sources, include_directories : includes, link_with : [lib_common, - lib_smartcols, - lib_mount], - dependencies : lib_selinux, + lib_smartcols], + dependencies : [lib_selinux, mount_dep], install_mode : 'rwsr-xr-x', install : opt, build_by_default : opt) @@ -1757,8 +1765,8 @@ exe2 = executable( 'umount', umount_sources, include_directories : includes, - link_with : [lib_common, - lib_mount], + link_with : [lib_common], + dependencies : [mount_dep], install_mode : 'rwsr-xr-x', install : opt, build_by_default : opt) @@ -1777,8 +1785,8 @@ exe = executable( include_directories : includes, link_args : ['--static'], link_with : [lib_common, - lib_smartcols_static, - lib_mount_static], + lib_smartcols_static], + dependencies : [mount_static_dep], install : opt2, build_by_default : opt2) if opt2 and not is_disabler(exe) @@ -1791,8 +1799,8 @@ exe = executable( umount_sources, include_directories : includes, link_args : ['--static'], - link_with : [lib_common, - lib_mount_static], + link_with : [lib_common], + dependencies : [mount_static_dep], install : opt2, build_by_default : opt2) if opt2 and not is_disabler(exe) @@ -1801,32 +1809,34 @@ endif # setuid? +opt = not get_option('build-swapon').disabled() exe = executable( 'swapon', swapon_sources, include_directories : includes, link_with : [lib_common, - lib_blkid, - lib_mount, 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, include_directories : includes, - link_with : [lib_common, - lib_blkid, - lib_mount], + 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'] @@ -1876,7 +1886,7 @@ exe = executable( 'mountpoint', mountpoint_sources, include_directories : includes, - link_with : [lib_mount], + dependencies : [mount_dep], install : opt, build_by_default : opt) if opt and not is_disabler(exe) @@ -1936,6 +1946,7 @@ exe = executable( unshare_sources, include_directories : includes, link_with : [lib_common], + dependencies : [mount_dep], install_dir : usrbin_exec_dir, install : opt, build_by_default : opt) @@ -1951,6 +1962,7 @@ exe = executable( unshare_sources, include_directories : includes, link_with : [lib_common], + dependencies : [mount_dep], install_dir : usrbin_exec_dir, install : opt, build_by_default : opt) @@ -2124,9 +2136,8 @@ exe = executable( mkswap_sources, include_directories : includes, link_with : [lib_common, - lib_blkid, lib_uuid], - dependencies: [lib_selinux], + dependencies: [blkid_dep, lib_selinux], install_dir : sbindir, install : true) if not is_disabler(exe) @@ -2140,8 +2151,8 @@ exe = executable( swaplabel_sources, include_directories : includes, link_with : [lib_common, - lib_blkid, lib_uuid], + dependencies : [blkid_dep], install_dir : sbindir, install : true) if not is_disabler(exe) @@ -2155,10 +2166,8 @@ exe = executable( 'fsck', fsck_sources, include_directories : includes, - link_with : [lib_common, - lib_blkid, - lib_mount], - dependencies : realtime_libs, + link_with : [lib_common], + dependencies : [blkid_dep, mount_dep, realtime_libs], install_dir : sbindir, install : opt, build_by_default : opt) @@ -2345,9 +2354,8 @@ exe = executable( link_with : [lib_common, lib_fdisk, lib_smartcols, - lib_tcolors, - lib_mount], - dependencies : [curses_libs], + lib_tcolors], + dependencies : [curses_libs, mount_dep], install_dir : sbindir, install : opt, build_by_default : opt) @@ -2389,8 +2397,8 @@ exe4 = executable( partx_sources, include_directories : includes, link_with : [lib_common, - lib_blkid, lib_smartcols], + dependencies : [blkid_dep], install_dir : usrsbin_exec_dir, install : opt, build_by_default : opt) @@ -2436,8 +2444,8 @@ exe4 = executable( include_directories : includes, link_args : ['--static'], link_with : [lib_common, - lib_blkid.get_static_lib(), lib_smartcols.get_static_lib()], + dependencies : [blkid_static_dep], install_dir : usrsbin_exec_dir, install : opt, build_by_default : opt) @@ -2726,33 +2734,35 @@ exes += exe manadocs += ['misc-utils/whereis.1.adoc'] bashcompletions += ['whereis'] +opt = not get_option('build-lslocks').disabled() exe = executable( 'lslocks', lslocks_sources, include_directories : includes, link_with : [lib_common, - lib_mount, 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, include_directories : includes, link_with : [lib_common, - lib_blkid, - lib_mount, lib_tcolors, lib_smartcols], - dependencies : lib_udev, - install : true) -if not is_disabler(exe) + dependencies : [blkid_dep, lib_udev, mount_dep], + install : opt, + build_by_default : opt) +if opt and not is_disabler(exe) exes += exe manadocs += ['misc-utils/lsblk.8.adoc'] bashcompletions += ['lsblk'] @@ -2840,8 +2850,8 @@ exe = executable( 'blkid', blkid_sources, include_directories : includes, - link_with : [lib_common, - lib_blkid], + link_with : [lib_common], + dependencies : [blkid_dep], install_dir : sbindir, install : opt, build_by_default : opt) @@ -2856,8 +2866,8 @@ exe = executable( 'blkid.static', blkid_sources, include_directories : includes, - link_with : [lib_common, - lib_blkid_static], + link_with : [lib_common], + dependencies : [blkid_static_dep], install_dir : sbindir, install : opt, build_by_default : opt) @@ -2869,7 +2879,7 @@ exe = executable( 'sample-mkfs', 'libblkid/samples/mkfs.c', include_directories : includes, - link_with : lib_blkid) + dependencies : [blkid_dep]) if not is_disabler(exe) exes += exe endif @@ -2878,7 +2888,7 @@ exe = executable( 'sample-partitions', 'libblkid/samples/partitions.c', include_directories : includes, - link_with : lib_blkid) + dependencies : [blkid_dep]) if not is_disabler(exe) exes += exe endif @@ -2887,7 +2897,7 @@ exe = executable( 'sample-superblocks', 'libblkid/samples/superblocks.c', include_directories : includes, - link_with : lib_blkid) + dependencies : [blkid_dep]) if not is_disabler(exe) exes += exe endif @@ -2896,7 +2906,7 @@ exe = executable( 'sample-topology', 'libblkid/samples/topology.c', include_directories : includes, - link_with : lib_blkid) + dependencies : [blkid_dep]) if not is_disabler(exe) exes += exe endif @@ -2905,7 +2915,7 @@ exe = executable( 'test_blkid_fuzz_sample', 'libblkid/src/fuzz.c', include_directories: includes, - link_with: lib_blkid, + dependencies : [blkid_dep], build_by_default: program_tests) if not is_disabler(exe) exes += exe @@ -2917,7 +2927,7 @@ exe = executable( 'findfs', findfs_sources, include_directories : includes, - link_with : [lib_blkid], + dependencies : [blkid_dep], install_dir : sbindir, install : true) if not is_disabler(exe) @@ -2931,8 +2941,8 @@ exe = executable( wipefs_sources, include_directories : includes, link_with : [lib_common, - lib_blkid, lib_smartcols], + dependencies : [blkid_dep], install_dir : sbindir, install : true) if not is_disabler(exe) @@ -2941,17 +2951,17 @@ if not is_disabler(exe) bashcompletions += ['wipefs'] endif +opt = not get_option('build-findmnt').disabled() exe = executable( 'findmnt', findmnt_sources, include_directories : includes, link_with : [lib_common, - lib_blkid, - lib_mount, lib_smartcols], - dependencies : [lib_udev], - install : true) -if not is_disabler(exe) + dependencies : [blkid_dep, lib_udev, mount_dep], + install : opt, + build_by_default : opt) +if opt and not is_disabler(exe) exes += exe manadocs += ['misc-utils/findmnt.8.adoc'] bashcompletions += ['findmnt'] @@ -3374,7 +3384,8 @@ endif ############################################################ libfdisk_tests_cflags = ['-DTEST_PROGRAM'] -libfdisk_tests_ldadd = [lib_fdisk_static, lib_uuid, lib_blkid] +libfdisk_tests_ldadd = [lib_fdisk_static, lib_uuid] +libfdisk_tests_ldadd_deps = [blkid_dep] exe = executable( 'test_fdisk_ask', @@ -3382,6 +3393,7 @@ exe = executable( c_args : libfdisk_tests_cflags, include_directories : lib_fdisk_includes, link_with : libfdisk_tests_ldadd, + dependencies : libfdisk_tests_ldadd_deps, build_by_default: program_tests) if not is_disabler(exe) exes += exe @@ -3393,6 +3405,7 @@ exe = executable( c_args : libfdisk_tests_cflags, include_directories : lib_fdisk_includes, link_with : libfdisk_tests_ldadd, + dependencies : libfdisk_tests_ldadd_deps, build_by_default: program_tests) if not is_disabler(exe) exes += exe @@ -3404,6 +3417,7 @@ exe = executable( c_args : libfdisk_tests_cflags, include_directories : lib_fdisk_includes, link_with : libfdisk_tests_ldadd, + dependencies : libfdisk_tests_ldadd_deps, build_by_default: program_tests) if not is_disabler(exe) exes += exe @@ -3415,6 +3429,7 @@ exe = executable( c_args : libfdisk_tests_cflags, include_directories : lib_fdisk_includes, link_with : libfdisk_tests_ldadd, + dependencies : libfdisk_tests_ldadd_deps, build_by_default: program_tests) if not is_disabler(exe) exes += exe @@ -3426,6 +3441,7 @@ exe = executable( c_args : libfdisk_tests_cflags, include_directories : lib_fdisk_includes, link_with : libfdisk_tests_ldadd, + dependencies : libfdisk_tests_ldadd_deps, build_by_default: program_tests) if not is_disabler(exe) exes += exe @@ -3437,6 +3453,7 @@ exe = executable( c_args : libfdisk_tests_cflags, include_directories : lib_fdisk_includes, link_with : libfdisk_tests_ldadd, + dependencies : libfdisk_tests_ldadd_deps, build_by_default: program_tests) if not is_disabler(exe) exes += exe diff --git a/meson_options.txt b/meson_options.txt index 1bc0bc2ecf..95cfb820da 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -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', |