'Install symlinks for lex compatibility.'

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

    if self.spec.satisfies('+lex'):
        dso = dso_suffix
        for (dir, flex, lex) in ((self.prefix.bin, 'flex', 'lex'), (self.prefix.lib, 'libfl.a', 'libl.a'), (self.prefix.lib, ('libfl.' + dso), ('libl.' + dso)), (self.prefix.lib64, 'libfl.a', 'libl.a'), (self.prefix.lib64, ('libfl.' + dso), ('libl.' + dso))):
            if os.path.isdir(dir):
                with working_dir(dir):
                    if (os.path.isfile(flex) and (not os.path.lexists(lex))):
                        symlink(flex, lex)
