From: Antoine Jacoutot Subject: Re: devel/meson and name_prefix: and LIBname_VERSION To: George Koehler Cc: ports@openbsd.org, "Kirill A. Korinsky" , Pascal Stumpf Date: Wed, 12 Nov 2025 13:36:59 +0100 On Tue, Nov 11, 2025 at 08:08:05PM -0500, George Koehler wrote: > We patch meson to look at LIBname_VERSION (set by SHARED_LIBS in > ports). Our patch doesn't work when a meson.build has > library(name_prefix: ''). Both net/dino and net/libupnpp have patches > removing name_prefix: '' to work around this problem. I offer this > diff for name_prefix. > > A typical library looks like > library('what', sources) > and prepends 'lib', so it is libwhat.so.${LIBwhat_VERSION}. > > A library with named_prefix: might be > library('libwhat', sources, name_prefix: '') > which should have the same name, but might rename some generated > files (like from 'what.pc' to 'libwhat.pc'). The version variable > should be LIBwhat_VERSION, not LIBlibwhat_VERSION. > > I rarely write Python, so it would help if someone checks my code. It > runs before the default self.prefix = 'lib' is set. Given a typical > library without name_prefix, hasattr(self, 'prefix') is false, so it > should pick the same version variable as before. The pick should > change only if there is a name_prefix and the prefixed name begins > with 'lib'. > > This diff has built all the packages on my amd64 desktop, but has never > been in a bulk. I packaged net/libupnpp without its patch-meson_build. > I tried to package net/dino without the 2nd chunk of > patch-libdino_meson_build; it failed because some files changed names > (dino.h to libdino.h and dino.vapi to libdino.vapi) and I had not > updated PLIST. > > Is this good enough to commit? Yes, OK for me. > > Index: Makefile > =================================================================== > RCS file: /cvs/ports/devel/meson/Makefile,v > diff -u -p -r1.151 Makefile > --- Makefile 23 Sep 2025 09:55:38 -0000 1.151 > +++ Makefile 11 Nov 2025 21:57:17 -0000 > @@ -5,6 +5,7 @@ GH_ACCOUNT= mesonbuild > GH_PROJECT= meson > GH_TAGNAME= 1.9.1 > EPOCH= 0 > +REVISION= 0 > > CATEGORIES= devel > > Index: patches/patch-mesonbuild_build_py > =================================================================== > RCS file: /cvs/ports/devel/meson/patches/patch-mesonbuild_build_py,v > diff -u -p -r1.59 patch-mesonbuild_build_py > --- patches/patch-mesonbuild_build_py 25 Aug 2025 07:12:17 -0000 1.59 > +++ patches/patch-mesonbuild_build_py 11 Nov 2025 21:57:17 -0000 > @@ -9,12 +9,17 @@ Index: mesonbuild/build.py > ) > from .options import OptionKey > > -@@ -2584,6 +2585,26 @@ class SharedLibrary(BuildTarget): > +@@ -2584,6 +2585,31 @@ class SharedLibrary(BuildTarget): > if self.darwin_versions is None and self.soversion is not None: > # If unspecified, pick the soversion > self.darwin_versions = (self.soversion, self.soversion) > + if is_openbsd(): > -+ self.libversion = os.getenv('LIB' + self.name + '_VERSION') > ++ libname = self.name > ++ if hasattr(self, 'prefix'): > ++ prefixed_name = self.prefix + self.name > ++ if prefixed_name[:3] == 'lib': > ++ libname = prefixed_name[3:] > ++ self.libversion = os.getenv('LIB' + libname + '_VERSION') > + if (self.libversion is None and > + self.soversion is not None and > + len(self.soversion) != 0 and > @@ -30,13 +35,13 @@ Index: mesonbuild/build.py > + f.write("# SHARED_LIBS+= {:<25} # \n".format("")) > + f.close > + f = open(shared_libs_log, 'a') > -+ f.write("SHARED_LIBS += {:<25} {} # {}\n".format(self.name, \ > ++ f.write("SHARED_LIBS += {:<25} {} # {}\n".format(libname, \ > + self.soversion, self.ltversion_orig)) > + f.close > > # Visual Studio module-definitions file > self.process_vs_module_defs_kw(kwargs) > -@@ -2635,6 +2656,8 @@ class SharedLibrary(BuildTarget): > +@@ -2635,6 +2661,8 @@ class SharedLibrary(BuildTarget): > # filename. If ltversion != soversion we create an soversion alias: > # libfoo.so.0 -> libfoo.so.0.100.0 > # Where libfoo.so.0.100.0 is the actual library > -- Antoine