Skip to content

Commit 07b7b5a

Browse files
yuwatabluca
authored andcommitted
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. (cherry picked from commit d625f71) (cherry picked from commit 49fa773)
1 parent f433a28 commit 07b7b5a

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

meson.build

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,8 @@ threads = dependency('threads')
10221022
librt = cc.find_library('rt')
10231023
libm = cc.find_library('m')
10241024
libdl = cc.find_library('dl')
1025-
libcrypt = cc.find_library('crypt')
1025+
libcrypt = dependency('libcrypt')
1026+
libcap = dependency('libcap')
10261027

10271028
# On some architectures, libatomic is required. But on some installations,
10281029
# it is found, but actual linking fails. So let's try to use it opportunistically.
@@ -1046,12 +1047,6 @@ foreach ident : [
10461047
conf.set10('HAVE_' + ident[0].to_upper(), have)
10471048
endforeach
10481049

1049-
libcap = dependency('libcap', required : false)
1050-
if not libcap.found()
1051-
# Compat with Ubuntu 14.04 which ships libcap w/o .pc file
1052-
libcap = cc.find_library('cap')
1053-
endif
1054-
10551050
want_bpf_framework = get_option('bpf-framework')
10561051
bpf_compiler = get_option('bpf-compiler')
10571052
bpf_framework_required = want_bpf_framework == 'true'
@@ -1233,7 +1228,7 @@ conf.set10('ENABLE_POLKIT', install_polkit)
12331228

12341229
want_acl = get_option('acl')
12351230
if want_acl != 'false' and not skip_deps
1236-
libacl = cc.find_library('acl', required : want_acl == 'true')
1231+
libacl = dependency('libacl', required : want_acl == 'true')
12371232
have = libacl.found()
12381233
else
12391234
have = false
@@ -1278,8 +1273,15 @@ conf.set10('HAVE_KMOD', have)
12781273

12791274
want_pam = get_option('pam')
12801275
if want_pam != 'false' and not skip_deps
1281-
libpam = cc.find_library('pam', required : want_pam == 'true')
1282-
libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
1276+
libpam = dependency('pam', required : false)
1277+
if not libpam.found()
1278+
# Debian older than bookworm and Ubuntu older than 22.10 do not provide the .pc file.
1279+
libpam = cc.find_library('pam', required : want_pam == 'true')
1280+
endif
1281+
libpam_misc = dependency('pam_misc', required : false)
1282+
if not libpam_misc.found()
1283+
libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
1284+
endif
12831285
have = libpam.found() and libpam_misc.found()
12841286
else
12851287
have = false
@@ -1405,8 +1407,12 @@ conf.set10('HAVE_QRENCODE', have)
14051407

14061408
want_gcrypt = get_option('gcrypt')
14071409
if want_gcrypt != 'false' and not skip_deps
1408-
libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
1409-
libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1410+
libgcrypt = dependency('libgcrypt', required : want_gcrypt == 'true')
1411+
libgpg_error = dependency('gpg-error', required : false)
1412+
if not libgpg_error.found()
1413+
# CentOS 8 does not provide the .pc file.
1414+
libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
1415+
endif
14101416
have = libgcrypt.found() and libgpg_error.found()
14111417
else
14121418
have = false
@@ -1514,8 +1520,11 @@ conf.set10('HAVE_ZLIB', have)
15141520

15151521
want_bzip2 = get_option('bzip2')
15161522
if want_bzip2 != 'false' and not skip_deps
1517-
libbzip2 = cc.find_library('bz2',
1518-
required : want_bzip2 == 'true')
1523+
libbzip2 = dependency('bzip2', required : false)
1524+
if not libbzip2.found()
1525+
# Debian and Ubuntu do not provide the .pc file.
1526+
libbzip2 = cc.find_library('bz2', required : want_bzip2 == 'true')
1527+
endif
15191528
have = libbzip2.found()
15201529
else
15211530
have = false

0 commit comments

Comments
 (0)