aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-04-13 01:01:09 -0400
committerJack Lloyd <[email protected]>2016-04-13 01:01:09 -0400
commit7aac6b2fc3a4c754eafb3f50c3de5c188b22d67c (patch)
tree249aae9d4fbd71cc964e4a5f8cc1eff36a7fd770
parent088e85ea774e9035c0b951c27a1a00d0793fa01e (diff)
parentb850420855a56d862ca9c05ca1c0acbddae8475e (diff)
Merge GH #468
Resolves problems with shared lib on OS X caused by incorrect dylib naming Fixes GH #467
-rwxr-xr-xconfigure.py11
-rw-r--r--src/build-data/cc/clang.txt6
-rw-r--r--src/build-data/makefile/gmake_dso.in3
-rw-r--r--src/build-data/makefile/header.in1
-rwxr-xr-xsrc/scripts/install.py15
5 files changed, 32 insertions, 4 deletions
diff --git a/configure.py b/configure.py
index 4739a8937..aeff794a8 100755
--- a/configure.py
+++ b/configure.py
@@ -100,6 +100,9 @@ class BuildConfigurationInformation(object):
version_vc_rev = botan_version.release_vc_rev
version_string = '%d.%d.%d' % (version_major, version_minor, version_patch)
+ # This is used on Darwin for dylib versioning
+ version_packed = version_major * 1000 + version_minor
+
"""
Constructor
"""
@@ -1263,6 +1266,8 @@ def create_template_vars(build_config, options, modules, cc, arch, osinfo):
'so_abi_rev': build_config.version_so_rev,
'version': build_config.version_string,
+ 'version_packed': build_config.version_packed,
+
'release_type': build_config.version_release_type,
'distribution_info': options.distribution_info,
@@ -1381,8 +1386,10 @@ def create_template_vars(build_config, options, modules, cc, arch, osinfo):
}
if options.os == 'darwin' and options.build_shared_lib:
- vars['cli_post_link_cmd'] = 'install_name_tool -change "/$(SONAME_ABI)" "@executable_path/$(SONAME_ABI)" $(CLI)'
- vars['test_post_link_cmd'] = 'install_name_tool -change "/$(SONAME_ABI)" "@executable_path/$(SONAME_ABI)" $(TEST)'
+ # In order that these executables work from the build directory,
+ # we need to change the install names
+ vars['cli_post_link_cmd'] = 'install_name_tool -change "$(INSTALLED_LIB_DIR)/$(SONAME_ABI)" "@executable_path/$(SONAME_ABI)" $(CLI)'
+ vars['test_post_link_cmd'] = 'install_name_tool -change "$(INSTALLED_LIB_DIR)/$(SONAME_ABI)" "@executable_path/$(SONAME_ABI)" $(TEST)'
else:
vars['cli_post_link_cmd'] = ''
vars['test_post_link_cmd'] = ''
diff --git a/src/build-data/cc/clang.txt b/src/build-data/cc/clang.txt
index cfeb8087b..2585190c4 100644
--- a/src/build-data/cc/clang.txt
+++ b/src/build-data/cc/clang.txt
@@ -27,8 +27,8 @@ visibility_attribute '__attribute__((visibility("default")))'
makefile_style gmake
<so_link_commands>
-darwin -> "$(CXX) -dynamiclib -fPIC -install_name $(LIBDIR)/$(SONAME_ABI)"
-darwin-debug -> "$(CXX) -dynamiclib -fPIC -install_name $(LIBDIR)/$(SONAME_ABI)"
+darwin -> "$(CXX) -dynamiclib -fPIC -install_name $(INSTALLED_LIB_DIR)/$(SONAME_ABI) -current_version $(DARWIN_CURRENT_VER) -compatibility_version $(DARWIN_COMPATIBILITY_VER)"
+darwin-debug -> "$(CXX) -dynamiclib -fPIC -install_name $(INSTALLED_LIB_DIR)/$(SONAME_ABI) -current_version $(DARWIN_CURRENT_VER) -compatibility_version $(DARWIN_COMPATIBILITY_VER)"
# The default works for GNU ld and several other Unix linkers
default -> "$(CXX) -shared -fPIC -Wl,-soname,$(SONAME_ABI)"
@@ -36,6 +36,8 @@ default-debug -> "$(CXX) -shared -fPIC -Wl,-soname,$(SONAME_ABI)"
</so_link_commands>
<binary_link_commands>
+darwin -> "$(LINKER) -headerpad_max_install_names"
+darwin-debug -> "$(LINKER) -headerpad_max_install_names"
linux -> "$(LINKER) -Wl,-rpath=\$$ORIGIN"
linux-debug -> "$(LINKER) -Wl,-rpath=\$$ORIGIN"
default -> "$(LINKER)"
diff --git a/src/build-data/makefile/gmake_dso.in b/src/build-data/makefile/gmake_dso.in
index fa167b780..13f7b0a3b 100644
--- a/src/build-data/makefile/gmake_dso.in
+++ b/src/build-data/makefile/gmake_dso.in
@@ -2,6 +2,9 @@ SONAME_PATCH = %{soname_patch}
SONAME_ABI = %{soname_abi}
SONAME_BASE = %{soname_base}
+DARWIN_COMPATIBILITY_VER = %{version_packed}.%{so_abi_rev}.0
+DARWIN_CURRENT_VER = %{version_packed}.%{so_abi_rev}.%{version_patch}
+
SHARED_LIB = %{out_dir}/$(SONAME_PATCH)
$(SHARED_LIB): $(LIBOBJS)
diff --git a/src/build-data/makefile/header.in b/src/build-data/makefile/header.in
index 6e432440c..f62f5ea0d 100644
--- a/src/build-data/makefile/header.in
+++ b/src/build-data/makefile/header.in
@@ -19,6 +19,7 @@ CLI_FLAGS = $(CXXFLAGS) $(WARN_FLAGS)
TEST_FLAGS = $(CXXFLAGS) $(WARN_FLAGS)
SCRIPTS_DIR = %{scripts_dir}
+INSTALLED_LIB_DIR = %{destdir}/%{libdir}
CLI_POST_LINK_CMD = %{cli_post_link_cmd}
TEST_POST_LINK_CMD = %{test_post_link_cmd}
diff --git a/src/scripts/install.py b/src/scripts/install.py
index d1d62b6c5..1d4d27b76 100755
--- a/src/scripts/install.py
+++ b/src/scripts/install.py
@@ -15,6 +15,7 @@ import os
import shutil
import string
import sys
+import subprocess
def parse_command_line(args):
@@ -174,6 +175,20 @@ def main(args = None):
copy_executable(os.path.join(out_dir, app_exe), os.path.join(bin_dir, app_exe))
+ # On Darwin, if we are using shared libraries and we install, we should fix
+ # up the library name, otherwise the botan command won't work; ironically
+ # we only need to do this because we previously changed it from a setting
+ # that would be correct for installation to one that lets us run it from
+ # the build directory
+ if str(cfg['os']) == 'darwin' and bool(cfg['build_shared_lib']):
+ soname_abi = process_template('%{soname_abi}')
+
+ subprocess.check_call(['install_name_tool',
+ '-change',
+ os.path.join('@executable_path', soname_abi),
+ os.path.join(lib_dir, soname_abi),
+ os.path.join(bin_dir, app_exe)])
+
if 'botan_pkgconfig' in cfg:
pkgconfig_dir = os.path.join(options.destdir, options.libdir, options.pkgconfigdir)
makedirs(pkgconfig_dir)