def _get_shlib_stem(target, source, env, for_signature: bool) -> str:
    """Get the base name of a shared library.

    Args:
        target: target node containing the lib name
        source: source node, not used
        env: environment context for running subst
        for_signature: whether this is being done for signature generation

    Returns:
        the library name without prefix/suffix
    """
    verbose = False

    target_name = str(target.name)
    shlibprefix = env.subst("$SHLIBPREFIX")
    shlibsuffix = env.subst("$_SHLIBSUFFIX")

    if verbose and not for_signature:
        print(
            "_get_shlib_stem: target_name:%s shlibprefix:%s shlibsuffix:%s"
            % (target_name, shlibprefix, shlibsuffix)
        )


    if shlibsuffix and target_name.endswith(shlibsuffix):
        target_name = target_name[: -len(shlibsuffix)]

    if shlibprefix and target_name.startswith(shlibprefix):
        # skip pathological case were target _is_ the prefix
        if target_name != shlibprefix:
            target_name = target_name[len(shlibprefix) :]


    if verbose and not for_signature:
        print("_get_shlib_stem: target_name:%s AFTER" % (target_name,))

    return target_name