summaryrefslogtreecommitdiff
path: root/SConstruct
diff options
context:
space:
mode:
authorFred Wright <fw@fwright.net>2019-03-20 15:01:29 -0700
committerFred Wright <fw@fwright.net>2019-03-20 15:01:29 -0700
commit19ee7ead6be107f50bc51ba47386694546e71ebf (patch)
tree6f47c06f913254479376d38678b047f6221573a1 /SConstruct
parent564200f62f9111609bb95626447a30f57db05ddd (diff)
downloadgpsd-19ee7ead6be107f50bc51ba47386694546e71ebf.tar.gz
Fix shared library installs on OSX.
Shared libraries on OSX need to have their IDs set to their full paths in order to get the proper paths into executables. Ideally, SCons would take care of this, but doesn't. It's necessary to use the OSX install_name_tool on an installed library to fix that. This adds code to do that, verifying that install_name_tool actually exists, and falling back to installing without it (the former behavior) otherwise. However, the CheckProg function didn't exist in some old versions of SCons, so if it's missing (on OSX), the code just assumes that the tool is present and hopes for the best. The version of SCons provided by MacPorts is known to have CheckProg. TESTED: Ran installs on OSX 10.9, 10.13, and 10.5 (PPC), as well as Ubuntu 14.04. Verified that the tool is used and has the intended effect when present on OSX. Verified that the install works without using it on OSX without it, as well as Linux without it, including when a dummy version is present on Linux. Did *not* test with an old SCons.
Diffstat (limited to 'SConstruct')
-rw-r--r--SConstruct18
1 files changed, 17 insertions, 1 deletions
diff --git a/SConstruct b/SConstruct
index 595a3aab..a7022341 100644
--- a/SConstruct
+++ b/SConstruct
@@ -1008,6 +1008,18 @@ else:
if option not in config.env['CFLAGS']:
config.CheckCompilerOption(option)
+# OSX needs to set the ID for installed shared libraries. See if this is OSX
+# and whether we have the tool.
+
+if sys.platform.startswith('darwin'):
+ try:
+ tool = config.CheckProg('install_name_tool')
+ except AttributeError:
+ tool = 'install_name_tool' # Just assume it's there if old SCons
+else:
+ tool = None
+env['osx_lib_tool'] = tool
+
# Set up configuration for target Python
PYTHON_LIBDIR_CALL = 'sysconfig.get_python_lib()'
@@ -1233,7 +1245,11 @@ else:
SHLIBVERSION=version)
def LibraryInstall(env, libdir, sources, version):
- return env.InstallVersionedLib(libdir, sources, SHLIBVERSION=version)
+ inst = env.InstallVersionedLib(libdir, sources, SHLIBVERSION=version)
+ if env['osx_lib_tool']:
+ toolcmd = '%s -id $TARGET $TARGET' % env['osx_lib_tool']
+ env.AddPostAction(inst, toolcmd)
+ return inst
compiled_gpslib = Library(env=env,
target="gps",