def METHOD_NAME(self, spec, prefix):
    libs = ""
    if "+X" in spec:
        libs += " " + self.spec["libx11"].libs.ld_flags
    if "+png" in spec:
        libs += " " + self.spec["libpng"].libs.ld_flags
    sub = {}
    if spec.satisfies("%gcc"):
        fib = " -fallow-invalid-boz" if spec.satisfies("%gcc@10:") else ""
        sub = {
            "@CCOMPL@": spack_cc,
            "@CFLAGC@": "-Wall -fPIC -DPG_PPU -O -std=c89 "
            + "-Wno-error=implicit-function-declaration",
            "@CFLAGD@": "-O2 -fPIC",
            "@FCOMPL@": spack_fc,
            "@FFLAGC@": "-Wall -fPIC -O -ffixed-line-length-none" + fib,
            "@FFLAGD@": "-fPIC " + libs + " -fno-backslash",
            "@LIBS@": libs + " -lgfortran",
            "@SHARED_LD@": spack_cc + " -shared -o $SHARED_LIB",
            "@SHARED_LIB_LIBS@": libs + " -lgfortran",
        }
    elif spec.satisfies("%intel"):
        sub = {
            "@CCOMPL@": spack_cc,
            "@CFLAGC@": "-O2 -fPIC -DPG_PPU",
            "@CFLAGD@": "-O2 -lifcore -lifport",
            "@FCOMPL@": spack_fc,
            "@FFLAGC@": "-fPIC",
            "@FFLAGD@": libs + " -nofor-main",
            "@LIBS@": libs + " -nofor-main -lifcore -lifport",
            "@SHARED_LD@": spack_cc + " -shared -o $SHARED_LIB",
            "@SHARED_LIB_LIBS@": libs + " -nofor-main -lifcore -lifport",
        }
    conf = join_path(self.stage.source_path, "sys_linux/g77_gcc.conf")
    drivers_list = join_path(self.stage.source_path, "drivers.list")
    # eg. change contents of drivers_list file like:
    # '! XWDRIV 1 /XWINDOW' ->  'XWDRIV 1 /XWINDOW'
    enable_driver = lambda s: filter_file(s, s[2:], drivers_list)
    if "+X" in spec:
        enable_driver("! XWDRIV 1 /XWINDOW")
        enable_driver("! XWDRIV 2 /XSERVE")
    if "+png" in spec:
        enable_driver("! PNDRIV 1 /PNG")
        filter_file(
            "pndriv.o : ./png.h ./pngconf.h ./zlib.h ./zconf.h", "pndriv.o :", "makemake"
        )
    # Alwasy enable PS and LATEX since they are not depending on other libraries.
    enable_driver("! PSDRIV 1 /PS")
    enable_driver("! PSDRIV 2 /VPS")
    enable_driver("! PSDRIV 3 /CPS")
    enable_driver("! PSDRIV 4 /VCPS")
    enable_driver("! LXDRIV 0 /LATEX")
    # GIF is not working. Maybe it is a bug in the gidriv.f.
    # enable_driver('! GIDRIV 1 /GIF')
    # enable_driver('! GIDRIV 2 /VGIF')
    for key, value in sub.items():
        filter_file(key, value, conf)