def VersionedSharedLibrary(target = None, source= None, env=None):
    """Build a shared library. If the environment has SHLIBVERSION
defined make a versioned shared library and create the appropriate
symlinks for the platform we are on"""
    Verbose = False
    try:
        version = env.subst('$SHLIBVERSION')
    except KeyError:
        version = None

    # libname includes the version number if one was given
    libname = target[0].name
    platform = env.subst('$PLATFORM')
    shlib_suffix = env.subst('$SHLIBSUFFIX')
    shlink_flags = SCons.Util.CLVar(env.subst('$SHLINKFLAGS'))
    if Verbose:
        print "VersionShLib: libname      = ",libname
        print "VersionShLib: platform     = ",platform
        print "VersionShLib: shlib_suffix = ",shlib_suffix
        print "VersionShLib: target = ",str(target[0])

    if version:
        # set the shared library link flags
        if platform == 'posix':
            shlink_flags += [ '-Wl,-Bsymbolic' ]
            # OpenBSD doesn't usually use SONAME for libraries
            if not sys.platform.startswith('openbsd'):
                # continue setup of shlink flags for all other POSIX systems
                suffix_re = re.escape(shlib_suffix + '.' + version)
                (major, age, revision) = version.split(".")
                # soname will have only the major version number in it
                soname = re.sub(suffix_re, shlib_suffix, libname) + '.' + major
                shlink_flags += [ '-Wl,-soname=%s' % soname ]
                if Verbose:
                    print " soname ",soname,", shlink_flags ",shlink_flags
        elif platform == 'cygwin':
            shlink_flags += [ '-Wl,-Bsymbolic',
                              '-Wl,--out-implib,${TARGET.base}.a' ]
        elif platform == 'darwin':
            shlink_flags += [ '-current_version', '%s' % version,
                              '-compatibility_version', '%s' % version,
                              '-undefined', 'dynamic_lookup' ]
        if Verbose:
            print "VersionShLib: shlink_flags = ",shlink_flags
        envlink = env.Clone()
        envlink['SHLINKFLAGS'] = shlink_flags
    else:
        envlink = env

    result = SCons.Defaults.ShLinkAction(target, source, envlink)

    if version:
        # here we need the full pathname so the links end up in the right directory
        libname = target[0].path
        linknames = VersionShLibLinkNames(version, libname, env)
        if Verbose:
            print "VerShLib: linknames ",linknames
        # Here we just need the file name w/o path as the target of the link
        lib_ver = target[0].name
        # make symlink of adjacent names in linknames
        for count in range(len(linknames)):
            linkname = linknames[count]
            if count > 0:
                try:
                    os.remove(lastlinkname)
                except:
                    pass
                os.symlink(os.path.basename(linkname),lastlinkname)
                if Verbose:
                    print "VerShLib: made sym link of %s -> %s" % (lastlinkname,linkname)
            lastlinkname = linkname
        # finish chain of sym links with link to the actual library
        if len(linknames)>0:
            try:
                os.remove(lastlinkname)
            except:
                pass
            os.symlink(lib_ver,lastlinkname)
            if Verbose:
                print "VerShLib: made sym link of %s -> %s" % (linkname, lib_ver)
    return result

# Fix http://scons.tigris.org/issues/show_bug.cgi?id=2903 :
# Ensure we still depend on SCons.Defaults.ShLinkAction command line which is $SHLINKCOM.
# This was tricky because we don't want changing LIBPATH to cause a rebuild, but
# changing other link args should.  LIBPATH has $( ... $) around it but until this
# fix, when the varlist was added to the build sig those ignored parts weren't getting
# ignored.
dataset/ETHPy150Open kayhayen/Nuitka/nuitka/build/inline_copy/lib/scons-2.3.2/SCons/Tool/__init__.py/VersionedSharedLibrary/original