]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
meson.build: fix paths to knot-dns libs if exec_prefix != prefix docs-develop-runt-dnukwv/deployments/3560
authorVladimír Čunát <vladimir.cunat@nic.cz>
Wed, 21 Feb 2024 08:16:45 +0000 (09:16 +0100)
committerOto Šťáva <oto.stava@nic.cz>
Fri, 22 Mar 2024 12:38:48 +0000 (13:38 +0100)
Man, this is complicated.  But I hope that this one will really be
reliable, with `sh` and `wc` being present in basically every POSIX env.

NEWS
meson.build

diff --git a/NEWS b/NEWS
index f44cb99a43c4905ba722768500c66bd1af526921..667a787d888171ab402e6264e2ff7b0cb27f8add 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,7 @@ Bugfixes
 - fix kresctl http request timeout (!1505)
 - fix RPZ if it contains apex NS record (!1516)
 - fix on 32-bit systems with 64-bit time_t (!1510)
+- fix paths to knot-dns libs if exec_prefix != prefix (!1503)
 
 
 Knot Resolver 6.0.6 (2024-02-13)
index 9ee683d77624a70ca9b2cb6c9418ddb60d2e7301..c412154360f033888a37106817c3ab6e0cf9a200 100644 (file)
@@ -194,10 +194,6 @@ conf_data.set_quoted('LIBDIR', lib_dir)
 conf_data.set_quoted('ROOTHINTS', root_hints)
 conf_data.set_quoted('LIBEXT', libext)
 conf_data.set_quoted('OPERATING_SYSTEM', host_machine.system())
-conf_data.set_quoted('libzscanner_SONAME',
-  libzscanner.get_pkgconfig_variable('libdir') / libzscanner.get_pkgconfig_variable('soname'))
-conf_data.set_quoted('libknot_SONAME',
-  libknot.get_pkgconfig_variable('libdir') / libknot.get_pkgconfig_variable('soname'))
 conf_data.set('ENABLE_LIBSYSTEMD', libsystemd.found().to_int())
 conf_data.set('ENABLE_SENDMMSG', sendmmsg.to_int())
 conf_data.set('ENABLE_XDP', xdp.to_int())
@@ -211,6 +207,20 @@ else
   conf_data.set('DBG_ASSERTION_FORK', '(5 * 60 * 1000) /* five minutes */')
 endif
 
+# Getting *runtime* path to knot-dns libs is surprisingly difficult.
+# Partially it's because meson isn't meant for general-purpose programming.
+foreach libname, lib: { 'libknot': libknot, 'libzscanner': libzscanner }
+  l = lib.get_pkgconfig_variable('libdir')
+  p = lib.get_pkgconfig_variable('prefix')
+  ep = lib.get_pkgconfig_variable('exec_prefix')
+  if ep != p # replace `p` with `ep` at the start of `l`
+    assert(l.startswith(p))
+    p_len = run_command('sh', '-c', 'echo "' + p + '" | wc -c', check: true).stdout().to_int()
+    l = ep / l.substring(p_len)
+  endif
+  conf_data.set_quoted(libname + '_SONAME', l / lib.get_pkgconfig_variable('soname'))
+endforeach
+
 kresconfig = configure_file(
   output: 'kresconfig.h',
   configuration: conf_data,