def METHOD_NAME(
    pkg,
    configure_dir=None,
    configure_args=None,
    configure_script=None,
    build_dir=None,
    extra_args=[],
    generator=None,
    env={},
    sysroot=True,
):
    if not configure_script:
        configure_script = pkg.configure_script
    if generator is None:
        generator = pkg.configure_gen
    if not build_dir:
        build_dir = pkg.make_dir
    if configure_dir:
        cscript = pkg.chroot_cwd / configure_dir / configure_script
        rscript = pkg.cwd / configure_dir / configure_script
    else:
        cscript = pkg.chroot_cwd / configure_script
        rscript = pkg.cwd / configure_script
    (pkg.cwd / build_dir).mkdir(parents=True, exist_ok=True)
    cargs = [
        "--prefix=/usr",
        "--sysconfdir=/etc",
        "--sbindir=/usr/bin",
        "--bindir=/usr/bin",
        "--libdir=/usr/lib",
        "--mandir=/usr/share/man",
        "--infodir=/usr/share/info",
        "--localstatedir=/var",
    ]
    # autoconf cache
    eenv = dict(benv)
    eenv["MAKE"] = make.Make(pkg).get_command()
    # caches taken from openembedded
    cachedir = paths.cbuild() / "misc/autoconf_cache"
    if pkg.profile().triplet:
        with pkg.profile("host") as pf:
            cargs.append("--build=" + pf.triplet)
        cargs.append("--host=" + pkg.profile().triplet)
    if pkg.profile().cross:
        if sysroot:
            cargs.append("--with-sysroot=" + str(pkg.profile().sysroot))
            cargs.append("--with-libtool-sysroot=" + str(pkg.profile().sysroot))
        # base cache
        _read_cache(cachedir, "common-linux", eenv)
        _read_cache(cachedir, "musl-linux", eenv)
        # endian cache
        _read_cache(cachedir, "endian-" + pkg.profile().endian, eenv)
        # machine cache
        cl = {
            "armv7l": ["arm-common", "arm-linux"],
            "aarch64": ["aarch64-linux"],
            "ppc64le": ["powerpc-common", "powerpc-linux", "powerpc64-linux"],
            "ppc64": ["powerpc-common", "powerpc-linux", "powerpc64-linux"],
            "x86_64": ["x86_64-linux"],
        }.get(pkg.profile().arch, [])
        for ln in cl:
            _read_cache(cachedir, ln, eenv)
    else:
        _read_cache(cachedir, "musl-linux", eenv)
    eenv.update(pkg.configure_env)
    eenv.update(env)
    # generate configure
    if generator:
        pkg.do(*generator, env=eenv)
    rscript.chmod(0o755)
    if configure_args is None:
        configure_args = pkg.configure_args
    pkg.do(
        cscript,
        *cargs,
        *configure_args,
        *extra_args,
        wrksrc=build_dir,
        env=eenv,
    )