$OpenBSD: patch-mesonbuild_build_py,v 1.12 2018/09/25 06:51:44 ajacoutot Exp $

Index: mesonbuild/build.py
--- mesonbuild/build.py.orig
+++ mesonbuild/build.py
@@ -23,7 +23,7 @@ from . import dependencies
 from . import mlog
 from .mesonlib import File, MesonException, listify, extract_as_list, OrderedSet
 from .mesonlib import typeslistify, stringlistify, classify_unity_sources
-from .mesonlib import get_filenames_templates_dict, substitute_values
+from .mesonlib import get_filenames_templates_dict, substitute_values, is_openbsd
 from .mesonlib import for_windows, for_darwin, for_cygwin, for_android, has_path_sep
 from .compilers import is_object, clink_langs, sort_clink, lang_suffixes
 from .interpreterbase import FeatureNew
@@ -1605,6 +1605,21 @@ class SharedLibrary(BuildTarget):
             elif self.soversion:
                 # If unspecified, pick the soversion
                 self.darwin_versions = 2 * [self.soversion]
+        if is_openbsd():
+            self.libversion = os.getenv('LIB' + self.name + '_VERSION')
+            if self.libversion is not None:
+                self.ltversion_orig = self.ltversion if self.ltversion is not None else self.soversion
+                self.ltversion = self.libversion.format(self)
+                self.soversion = self.ltversion
+                shared_libs_log = os.path.join(self.environment.get_build_dir(), 'shared_libs.log')
+                if not os.path.isfile(shared_libs_log):
+                    f = open(shared_libs_log, 'w+')
+                    f.write("# SHARED_LIBS+= {:<25}<obsd version> # <orig version>\n".format("<libname>"))
+                    f.close
+                f = open(shared_libs_log, 'a')
+                f.write("SHARED_LIBS += {:<25} {} # {}\n".format(self.name, \
+                        self.soversion, self.ltversion_orig))
+                f.close
 
         # Visual Studio module-definitions file
         if 'vs_module_defs' in kwargs:
@@ -1670,6 +1685,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
+        if is_openbsd() and self.libversion is not None:
+            return {}
         if self.suffix == 'so' and self.ltversion and self.ltversion != self.soversion:
             alias_tpl = self.filename_tpl.replace('ltversion', 'soversion')
             ltversion_filename = alias_tpl.format(self)
