From: Jan Janssen Date: Wed, 9 Aug 2023 17:52:57 +0000 (+0200) Subject: meson: Convert options to meson features (find_library fallback) X-Git-Tag: v255-rc1~657^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a0c9ac9ae4f81501f72cea7706f4aeac2d227888;p=thirdparty%2Fsystemd.git meson: Convert options to meson features (find_library fallback) This uses a two-step approach to make sure we can fall back to find_library(), while also skipping the detection if the features are explicitly disabled. --- diff --git a/meson.build b/meson.build index aee3dffe121..507c9e2a1e8 100644 --- a/meson.build +++ b/meson.build @@ -1178,18 +1178,13 @@ if have conf.set_quoted('SMACK_DEFAULT_PROCESS_LABEL', get_option('smack-default-process-label')) endif -want_polkit = get_option('polkit') -install_polkit = false -install_polkit_pkla = false -if want_polkit != 'false' and not skip_deps - install_polkit = true - - libpolkit = dependency('polkit-gobject-1', - required : false) - if libpolkit.found() and libpolkit.version().version_compare('< 0.106') - message('Old polkit detected, will install pkla files') - install_polkit_pkla = true - endif +feature = get_option('polkit') +libpolkit = dependency('polkit-gobject-1', + required : feature.disabled() ? feature : false) +install_polkit = feature.allowed() +install_polkit_pkla = libpolkit.found() and libpolkit.version().version_compare('< 0.106') +if install_polkit_pkla + message('Old polkit detected, will install pkla files') endif conf.set10('ENABLE_POLKIT', install_polkit) @@ -1217,24 +1212,19 @@ libxenctrl = dependency('xencontrol', required : get_option('xenctrl')) conf.set10('HAVE_XENCTRL', libxenctrl.found()) -want_pam = get_option('pam') -if want_pam != 'false' and not skip_deps - libpam = dependency('pam', required : false) - if not libpam.found() - # Debian older than bookworm and Ubuntu older than 22.10 do not provide the .pc file. - libpam = cc.find_library('pam', required : want_pam == 'true') - endif - libpam_misc = dependency('pam_misc', required : false) - if not libpam_misc.found() - libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true') - endif - have = libpam.found() and libpam_misc.found() -else - have = false - libpam = [] - libpam_misc = [] +feature = get_option('pam') +libpam = dependency('pam', + required : feature.disabled() ? feature : false) +if not libpam.found() + # Debian older than bookworm and Ubuntu older than 22.10 do not provide the .pc file. + libpam = cc.find_library('pam', required : feature) +endif +libpam_misc = dependency('pam_misc', + required : feature.disabled() ? feature : false) +if not libpam_misc.found() + libpam_misc = cc.find_library('pam_misc', required : feature) endif -conf.set10('HAVE_PAM', have) +conf.set10('HAVE_PAM', libpam.found() and libpam_misc.found()) libmicrohttpd = dependency('libmicrohttpd', version : '>= 0.9.33', @@ -1326,18 +1316,17 @@ libqrencode = dependency('libqrencode', required : get_option('qrencode')) conf.set10('HAVE_QRENCODE', libqrencode.found()) -want_gcrypt = get_option('gcrypt') -if want_gcrypt != 'false' and not skip_deps - libgcrypt = dependency('libgcrypt', required : want_gcrypt == 'true') - libgpg_error = dependency('gpg-error', required : false) - if not libgpg_error.found() - # CentOS 8 does not provide the .pc file. - libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true') - endif - have = libgcrypt.found() and libgpg_error.found() -else - have = false +feature = get_option('gcrypt') +libgcrypt = dependency('libgcrypt', + required : feature) +libgpg_error = dependency('gpg-error', + required : feature.disabled() ? feature : false) +if not libgpg_error.found() + # CentOS 8 does not provide the .pc file. + libgpg_error = cc.find_library('gpg-error', required : feature) endif + +have = libgcrypt.found() and libgpg_error.found() if not have # link to neither of the libs if one is not found libgcrypt = [] @@ -1395,19 +1384,14 @@ libz = dependency('zlib', required : get_option('zlib')) conf.set10('HAVE_ZLIB', libz.found()) -want_bzip2 = get_option('bzip2') -if want_bzip2 != 'false' and not skip_deps - libbzip2 = dependency('bzip2', required : false) - if not libbzip2.found() - # Debian and Ubuntu do not provide the .pc file. - libbzip2 = cc.find_library('bz2', required : want_bzip2 == 'true') - endif - have = libbzip2.found() -else - have = false - libbzip2 = [] +feature = get_option('bzip2') +libbzip2 = dependency('bzip2', + required : feature.disabled() ? feature : false) +if not libbzip2.found() + # Debian and Ubuntu do not provide the .pc file. + libbzip2 = cc.find_library('bz2', required : feature) endif -conf.set10('HAVE_BZIP2', have) +conf.set10('HAVE_BZIP2', libbzip2.found()) libxz = dependency('liblzma', required : get_option('xz')) diff --git a/meson_options.txt b/meson_options.txt index 894116f750b..9d73203da6a 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -362,7 +362,7 @@ option('smack-run-label', type : 'string', description : 'run systemd --system itself with a specific SMACK label') option('smack-default-process-label', type : 'string', description : 'default SMACK label for executed processes') -option('polkit', type : 'combo', choices : ['auto', 'true', 'false'], +option('polkit', type : 'feature', deprecated : { 'true' : 'enabled', 'false' : 'disabled' }, description : 'polkit support') option('ima', type : 'boolean', description : 'IMA support') @@ -379,7 +379,7 @@ option('kmod', type : 'feature', deprecated : { 'true' : 'enabled', 'false' : 'd description : 'support for loadable modules') option('xenctrl', type : 'feature', deprecated : { 'true' : 'enabled', 'false' : 'disabled' }, description : 'support for Xen kexec') -option('pam', type : 'combo', choices : ['auto', 'true', 'false'], +option('pam', type : 'feature', deprecated : { 'true' : 'enabled', 'false' : 'disabled' }, description : 'PAM support') option('passwdqc', type : 'combo', choices : ['auto', 'true', 'false'], description : 'libpasswdqc support') @@ -403,7 +403,7 @@ option('libiptc', type : 'feature', deprecated : { 'true' : 'enabled', 'false' : description : 'libiptc support') option('qrencode', type : 'feature', deprecated : { 'true' : 'enabled', 'false' : 'disabled' }, description : 'libqrencode support') -option('gcrypt', type : 'combo', choices : ['auto', 'true', 'false'], +option('gcrypt', type : 'feature', deprecated : { 'true' : 'enabled', 'false' : 'disabled' }, description : 'gcrypt support') option('gnutls', type : 'feature', deprecated : { 'true' : 'enabled', 'false' : 'disabled' }, description : 'gnutls support') @@ -421,7 +421,7 @@ option('elfutils', type : 'feature', deprecated : { 'true' : 'enabled', 'false' description : 'elfutils support') option('zlib', type : 'feature', deprecated : { 'true' : 'enabled', 'false' : 'disabled' }, description : 'zlib compression support') -option('bzip2', type : 'combo', choices : ['auto', 'true', 'false'], +option('bzip2', type : 'feature', deprecated : { 'true' : 'enabled', 'false' : 'disabled' }, description : 'bzip2 compression support') option('xz', type : 'feature', deprecated : { 'true' : 'enabled', 'false' : 'disabled' }, description : 'xz compression support') diff --git a/mkosi.presets/base/mkosi.build b/mkosi.presets/base/mkosi.build index 89124bcb1c9..02769bac005 100755 --- a/mkosi.presets/base/mkosi.build +++ b/mkosi.presets/base/mkosi.build @@ -116,13 +116,13 @@ if [ ! -f "$BUILDDIR"/build.ninja ]; then -D rfkill=true -D xdg-autostart=true -D translations=true - -D polkit=true + -D polkit=enabled -D acl=enabled -D audit=enabled -D blkid=enabled -D fdisk=enabled -D kmod=enabled - -D pam=true + -D pam=enabled -D pwquality=true -D microhttpd=enabled -D libcryptsetup=true @@ -130,7 +130,7 @@ if [ ! -f "$BUILDDIR"/build.ninja ]; then -D idn=true -D libidn2=true -D qrencode=enabled - -D gcrypt=true + -D gcrypt=enabled -D gnutls=enabled -D openssl=enabled -D cryptolib=openssl