--- SConstruct.orig	2015-09-17 07:46:24.000000000 -0500
+++ SConstruct	2017-09-27 14:56:41.000000000 -0500
@@ -152,7 +152,8 @@
                  True),
     )
 
-env = Environment(variables=opts,
+env = Environment(ENV = {'PATH' : os.environ['PATH']},
+                  variables=opts,
                   tools=('default', 'textfile',),
                   CPPPATH=['.', ],
                   )
@@ -216,7 +217,8 @@
 # from current_version, so don't use the PATCH level to avoid that build and
 # runtime patch levels have to be identical.
 if sys.platform != 'sunos5':
-  env['SHLIBVERSION'] = '%d.%d.%d' % (MAJOR, MINOR, 0)
+  # MacPorts: change PATCH to 0 when MINOR goes from 3 to 4.
+  env['SHLIBVERSION'] = '%d.%d.%d' % (MAJOR, MINOR, PATCH)
 
 LIBNAME = 'libserf-%d' % (MAJOR,)
 if sys.platform != 'win32':
@@ -229,7 +231,7 @@
 
 if sys.platform == 'darwin':
 #  linkflags.append('-Wl,-install_name,@executable_path/%s.dylib' % (LIBNAME,))
-  env.Append(LINKFLAGS=['-Wl,-install_name,%s/%s.dylib' % (thisdir, LIBNAME,)])
+  env.Append(LINKFLAGS=['-Wl,-install_name,%s/%s.dylib' % (libdir, LIBNAME,)])
 
 if sys.platform != 'win32':
   def CheckGnuCC(context):
@@ -419,21 +421,6 @@
 install_static = env.Install(libdir, lib_static)
 install_shared = env.InstallVersionedLib(libdir, lib_shared)
 
-if sys.platform == 'darwin':
-  # Change the shared library install name (id) to its final name and location.
-  # Notes:
-  # If --install-sandbox=<path> is specified, install_shared_path will point
-  # to a path in the sandbox. We can't use that path because the sandbox is
-  # only a temporary location. The id should be the final target path.
-  # Also, we shouldn't use the complete version number for id, as that'll
-  # make applications depend on the exact major.minor.patch version of serf.
-
-  install_shared_path = install_shared[0].abspath
-  target_install_shared_path = os.path.join(libdir, '%s.dylib' % LIBNAME)
-  env.AddPostAction(install_shared, ('install_name_tool -id %s %s'
-                                     % (target_install_shared_path,
-                                        install_shared_path)))
-
 env.Alias('install-lib', [install_static, install_shared,
                           ])
 env.Alias('install-inc', env.Install(incdir, HEADER_FILES))
