--- SConstruct.orig	2016-05-09 23:15:49 UTC
+++ SConstruct
@@ -26,7 +26,7 @@ try:
     if platform == 'linux-gcc':
         CXX = 'g++' # not quite right, but env is not yet available.
         import commands
-        version = commands.getoutput('%s -dumpversion' %CXX)
+        version = 'FreeBSD'
         platform = 'linux-gcc-%s' %version
         print "Using platform '%s'" %platform
         LD_LIBRARY_PATH = os.environ.get('LD_LIBRARY_PATH', '')
@@ -65,7 +65,7 @@ def make_environ_vars():
 	return vars
 	
 
-env = Environment( ENV = make_environ_vars(),
+env = Environment( ENV = os.environ,
                    toolpath = ['scons-tools'],
                    tools=[] ) #, tools=['default'] )
 
@@ -121,6 +121,7 @@ elif platform.startswith('linux-gcc'):
     env.Tool( 'default' )
     env.Append( LIBS = ['pthread'], CCFLAGS = os.environ.get("CXXFLAGS", "-Wall"), LINKFLAGS=os.environ.get("LDFLAGS", "") )
     env['SHARED_LIB_ENABLED'] = True
+    env['CXX'] = os.environ['CXX']
 else:
     print "UNSUPPORTED PLATFORM."
     env.Exit(1)
@@ -147,6 +148,11 @@ env['JSONCPP_VERSION'] = JSONCPP_VERSION
 env['BUILD_DIR'] = env.Dir(build_dir)
 env['ROOTBUILD_DIR'] = env.Dir(rootbuild_dir)
 env['DIST_DIR'] = DIST_DIR
+
+# Set SHLIBVERSION for env.InstallVersionedLib(). We use the version number
+# without the "-rcXX" part.
+env['SHLIBVERSION'] = JSONCPP_VERSION.partition('-')[0]
+
 if 'TarGz' in env['BUILDERS']:
 	class SrcDistAdder:
 		def __init__( self, env ):
@@ -164,11 +170,11 @@ env['SRCDIST_ADD'] = SrcDistAdder( env )
 env['SRCDIST_TARGET'] = os.path.join( DIST_DIR, 'jsoncpp-src-%s.tar.gz' % env['JSONCPP_VERSION'] )
                       
 env_testing = env.Clone( )
-env_testing.Append( LIBS = ['json_${LIB_NAME_SUFFIX}'] )
+env_testing.Append( LIBS = ['jsoncpp'] )
 
 def buildJSONExample( env, target_sources, target_name ):
     env = env.Clone()
-    env.Append( CPPPATH = ['#'] )
+    #env.Append( CPPPATH = ['#'] )
     exe = env.Program( target=target_name,
                        source=target_sources )
     env['SRCDIST_ADD']( source=[target_sources] )
@@ -187,14 +193,14 @@ def buildUnitTests( env, target_sources,
     env.AlwaysBuild( check_alias_target )
 
 def buildLibrary( env, target_sources, target_name ):
-    static_lib = env.StaticLibrary( target=target_name + '_${LIB_NAME_SUFFIX}',
+    static_lib = env.StaticLibrary( target=target_name,
                                     source=target_sources )
     global lib_dir
     env.Install( lib_dir, static_lib )
     if env['SHARED_LIB_ENABLED']:
-        shared_lib = env.SharedLibrary( target=target_name + '_${LIB_NAME_SUFFIX}',
+        shared_lib = env.SharedLibrary( target=target_name,
                                         source=target_sources )
-        env.Install( lib_dir, shared_lib )
+        env.InstallVersionedLib( lib_dir, shared_lib )
     env['SRCDIST_ADD']( source=[target_sources] )
 
 Export( 'env env_testing buildJSONExample buildLibrary buildJSONTests buildUnitTests' )
