From 32528e2bb3101302406b3e80f522bf8f3f39f1d3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Wed, 21 Feb 2024 09:16:45 +0100 Subject: [PATCH] meson.build: fix paths to knot-dns libs if exec_prefix != prefix 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 | 1 + meson.build | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index f44cb99a4..667a787d8 100644 --- 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) diff --git a/meson.build b/meson.build index 9ee683d77..c41215436 100644 --- a/meson.build +++ b/meson.build @@ -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, -- 2.47.2