'Return (buildable, error, "reason why not")'

def can_build(self, pkg, use_blacklist=False, failed_packages=[], use_makefile=True):

    output_str = ''
    output_state = True
    buildable = True
    previously_failed_pkgs = [pk for pk in failed_packages if (pk in self.dependency_tracker.get_deps(pkg))]
    if (len(previously_failed_pkgs) > 0):
        buildable = False
        output_state = False
        output_str += ('    Package    %s    cannot    be    built    for    dependent    package(s)    %s    failed.    \n' % (pkg, previously_failed_pkgs))
    if use_blacklist:
        black_listed_dependents = self.is_blacklisted(pkg)
        if (len(black_listed_dependents) > 0):
            buildable = False
            output_str += ('Cannot    build    %s    ROS_BUILD_BLACKLIST    found    in    packages    %s' % (pkg, black_listed_dependents))
    if self.has_nobuild(pkg):
        buildable = False
        output_state = True
        output_str += ('ROS_NOBUILD    in    package    %s\n' % pkg)
    if (use_makefile and (not self.has_makefile(pkg))):
        output_state = True
        buildable = False
        output_str += ('    No    Makefile    in    package    %s\n' % pkg)
    if (output_str and (output_str[(-1)] == '\n')):
        output_str = output_str[:(-1)]
    return (buildable, output_state, output_str)
