1
0
mirror of https://github.com/systemd/systemd synced 2024-07-08 20:15:55 +00:00

meson: first try dependency(), then fallback to find_library()

This also drops the fallback for libacl, libcap, libcrypt, and libgcrypt,
as recent Ubuntu (at least, 20.04 LTS and newer) and Debian (at least, buster
and newer) have relevant .pc files.

Fixes #28161.
This commit is contained in:
Yu Watanabe 2023-06-27 04:53:13 +09:00
parent 08423f6d30
commit d625f717db

View File

@ -1060,7 +1060,8 @@ threads = dependency('threads')
librt = cc.find_library('rt')
libm = cc.find_library('m')
libdl = cc.find_library('dl')
libcrypt = cc.find_library('crypt')
libcrypt = dependency('libcrypt')
libcap = dependency('libcap')
# On some architectures, libatomic is required. But on some installations,
# it is found, but actual linking fails. So let's try to use it opportunistically.
@ -1084,12 +1085,6 @@ foreach ident : [
conf.set10('HAVE_' + ident[0].to_upper(), have)
endforeach
libcap = dependency('libcap', required : false)
if not libcap.found()
# Compat with Ubuntu 14.04 which ships libcap w/o .pc file
libcap = cc.find_library('cap')
endif
want_bpf_framework = get_option('bpf-framework')
bpf_compiler = get_option('bpf-compiler')
bpf_framework_required = want_bpf_framework == 'true'
@ -1270,7 +1265,7 @@ conf.set10('ENABLE_POLKIT', install_polkit)
want_acl = get_option('acl')
if want_acl != 'false' and not skip_deps
libacl = cc.find_library('acl', required : want_acl == 'true')
libacl = dependency('libacl', required : want_acl == 'true')
have = libacl.found()
else
have = false
@ -1327,8 +1322,15 @@ conf.set10('HAVE_XENCTRL', have)
want_pam = get_option('pam')
if want_pam != 'false' and not skip_deps
libpam = cc.find_library('pam', required : want_pam == 'true')
libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
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
@ -1457,8 +1459,12 @@ conf.set10('HAVE_QRENCODE', have)
want_gcrypt = get_option('gcrypt')
if want_gcrypt != 'false' and not skip_deps
libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
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
@ -1568,8 +1574,11 @@ conf.set10('HAVE_ZLIB', have)
want_bzip2 = get_option('bzip2')
if want_bzip2 != 'false' and not skip_deps
libbzip2 = cc.find_library('bz2',
required : want_bzip2 == 'true')
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