]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
musl: meson: explicitly link with libintl when necessary
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 6 Sep 2025 07:25:41 +0000 (16:25 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 12 Nov 2025 19:44:00 +0000 (04:44 +0900)
On some musl based distributions dgettext() may be provided by libintl.so.
Hence, we need to add dependency in that case.

meson.build
src/home/meson.build

index e5fd89e60cec46b267fbceb45011a12b4047b09b..e3ee957fd5e018c60808d45a78a86b60fc42297b 100644 (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.
index ebecc7b9c2b0c009fa83cc005329d6fd6cecae45..f40f935d556b21b3eb3f8e01aecb65a094696d60 100644 (file)
@@ -115,6 +115,7 @@ modules += [
                 'sources' : pam_systemd_home_sources,
                 'dependencies' : [
                         libcrypt,
+                        libintl,
                         libpam_misc,
                         libpam,
                         threads,