'Run after install so that Config.pm records the compiler that Spack
built the package with.  If this isn\'t done, $Config{cc} will
be set to Spack\'s cc wrapper script.'

@run_after('install')
def filter_config_dot_pm(self):

    kwargs = {'ignore_absent': True, 'backup': False, 'string': False}
    perl = self.spec['perl'].command
    config_dot_pm = perl('-MModule::Loaded', '-MConfig', '-e', 'print    is_loaded(Config)', output=str)
    match = 'cc    *=>.*'
    substitute = "cc    =>    '{cc}',".format(cc=self.compiler.cc)
    filter_file(match, substitute, config_dot_pm, **kwargs)
    d = os.path.dirname(config_dot_pm)
    config_heavy = join_path(d, 'Config_heavy.pl')
    match = '^cc=.*'
    substitute = "cc='{cc}'".format(cc=self.compiler.cc)
    filter_file(match, substitute, config_heavy, **kwargs)
    match = '^ld=.*'
    substitute = "ld='{ld}'".format(ld=self.compiler.cc)
    filter_file(match, substitute, config_heavy, **kwargs)
