Adds any relevant libraries that need to be explicitly included according
    to the fortpy configuration file. Libraries are appended to the specified
    collection of lines. Returns true if relevant libraries were added.

def _add_explicit_includes(lines, dependencies=None, extralinks=None):
    """Adds any relevant libraries that need to be explicitly included according
    to the fortpy configuration file. Libraries are appended to the specified
    collection of lines. Returns true if relevant libraries were added.
    """
    from fortpy import config
    import sys
    from os import path
    includes = sys.modules["config"].includes
    linklibs = False

    if extralinks is not None and len(extralinks) > 0:
        for i, link in enumerate(extralinks):
            lines.append("LBD{0:d} 		= {1}".format(i, link))
        lines.append("")
    
    if len(includes) > 0:
        lines.append("LIBS\t\t= \\")
        for library in includes:
            addlib = False
            if "modules" in library:
                #We need to loop over the modules specified for the library and see
                #if any of them are in our list of modules.
                for libmod in library["modules"]:
                    if dependencies is None or libmod.lower() in dependencies:
                        addlib = True
                        break
            else:
                addlib = True

            if addlib:
                linklibs = True
                lines.append("\t\t{} \\".format(library["path"]))

        #These links specify explicit libraries to include in the final compilation.
        if extralinks is not None:
            for i in range(len(extralinks)):
                if path.isfile(extralinks[i]):
                    lines.append("\t\t$(LBD{0:d}) \\".format(i))
            
    return linklibs or (extralinks is not None and len(extralinks) > 0)