musl: meson: explicitly link with libintl when necessary

On some musl based distributions dgettext() may be provided by libintl.so.
Hence, we need to add dependency in that case.
This commit is contained in:
Yu Watanabe
2025-09-06 16:25:41 +09:00
parent a4c45279a7
commit bd19ffd9cb
2 changed files with 17 additions and 0 deletions

View File

@@ -1005,6 +1005,22 @@ librt = cc.find_library('rt')
libm = cc.find_library('m')
libdl = cc.find_library('dl')
# On some distributions that use musl (e.g. Alpine), libintl.h may be provided by gettext rather than musl.
# In that case, we need to explicitly link with libintl.so.
if cc.has_function('dgettext',
prefix : '''#include <libintl.h>''',
args : '-D_GNU_SOURCE')
libintl = []
else
libintl = cc.find_library('intl')
if not cc.has_function('dgettext',
prefix : '''#include <libintl.h>''',
args : '-D_GNU_SOURCE',
dependencies : libintl)
error('dgettext() not found')
endif
endif
# 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.
# If it is installed, but not needed, it will be dropped because of --as-needed.

View File

@@ -115,6 +115,7 @@ modules += [
'sources' : pam_systemd_home_sources,
'dependencies' : [
libcrypt,
libintl,
libpam_misc,
libpam,
threads,