$OpenBSD: patch-mesonbuild_build_py,v 1.15 2019/06/20 21:03:03 ajacoutot Exp $

Index: mesonbuild/build.py
--- mesonbuild/build.py.orig
+++ mesonbuild/build.py
@@ -26,7 +26,7 @@ from . import mlog
 from .mesonlib import (
     File, MesonException, MachineChoice, PerMachine, OrderedSet, listify,
     extract_as_list, typeslistify, stringlistify, classify_unity_sources,
-    get_filenames_templates_dict, substitute_values, has_path_sep,
+    get_filenames_templates_dict, substitute_values, has_path_sep, is_openbsd
 )
 from .compilers import Compiler, is_object, clink_langs, sort_clink, lang_suffixes, get_macos_dylib_install_name
 from .linkers import StaticLinker
@@ -1789,6 +1789,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:
@@ -1854,6 +1869,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)
