def METHOD_NAME(self, spec, prefix):
    # Clean up environment to avoid configure problems
    os.environ.pop("LINKMPI", "")
    os.environ.pop("NERSC_HOST", "")
    os.environ.pop("NONCLIKLIKE", "")
    os.environ.pop("PICO", "")
    os.environ.pop("PRECISION", "")
    os.environ.pop("RECOMBINATION", "")
    os.environ.pop("WMAP", "")
    # Set up Planck data if requested
    clikdir = join_path("data", "clik")
    try:
        os.remove(clikdir)
    except OSError:
        pass
    if "+planck" in spec:
        os.symlink(join_path(os.environ["CLIK_DATA"], "plc_2.0"), clikdir)
    else:
        os.environ.pop("CLIK_DATA", "")
        os.environ.pop("CLIK_PATH", "")
        os.environ.pop("CLIK_PLUGIN", "")
    # Choose compiler
    # Note: Instead of checking the compiler vendor, we should
    # rewrite the Makefile to use Spack's options all the time
    if spec.satisfies("%gcc"):
        if not spec.satisfies("%gcc@6:"):
            raise InstallError(
                "When using GCC, " "CosmoMC requires version gcc@6: for building"
            )
        choosecomp = "ifortErr=1"  # choose gfortran
    elif spec.satisfies("%intel"):
        if not spec.satifies("%intel@14:"):
            raise InstallError(
                "When using the Intel compiler, "
                "CosmoMC requires version intel@14: for building"
            )
        choosecomp = "ifortErr=0"  # choose ifort
    else:
        raise InstallError("Only GCC and Intel compilers are supported")
    # Configure MPI
    if "+mpi" in spec:
        wantmpi = "BUILD=MPI"
        mpif90 = "MPIF90C=%s" % spec["mpi"].mpifc
    else:
        wantmpi = "BUILD=NOMPI"
        mpif90 = "MPIF90C="
    # Choose BLAS and LAPACK
    lapack = "LAPACKL=%s" % (spec["lapack"].libs + spec["blas"].libs).ld_flags
    # Build
    make(choosecomp, wantmpi, mpif90, lapack)
    # Install
    mkdirp(prefix.bin)
    METHOD_NAME("cosmomc", prefix.bin)
    root = join_path(prefix.share, "cosmomc")
    mkdirp(root)
    entries = [
        "batch1",
        "batch2",
        "batch3",
        "camb",
        "chains",
        "clik_latex.paramnames",
        "clik_units.paramnames",
        "cosmomc.cbp",
        "data",
        "distgeneric.ini",
        "distparams.ini",
        "disttest.ini",
        "docs",
        "job_script",
        "job_script_MOAB",
        "job_script_SLURM",
        "paramnames",
        "params_generic.ini",
        "planck_covmats",
        "scripts",
        # don't copy 'source'
        "test.ini",
        "test_pico.ini",
        "test_planck.ini",
        "tests",
    ]
    if "+python" in spec:
        entries += ["python"]
    for entry in entries:
        if os.path.isfile(entry):
            METHOD_NAME(entry, root)
        else:
            install_tree(entry, join_path(root, entry))
    for dirpath, dirnames, filenames in os.walk(prefix):
        for filename in fnmatch.filter(filenames, "*~"):
            os.remove(os.path.join(dirpath, filename))