+ if(&pkg==builder.get_main_package() && deflt)
+ def_tgt->add_depend(result);
+ else
+ world->add_depend(result);
+ if(install)
+ inst_list.push_back(result);
+ }
+ else
+ {
+ for(PathList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i)
+ {
+ string ext = FS::extpart(FS::basename(*i));
+ if(ext==".h")
+ {
+ FileTarget *hdr = builder.get_vfs().get_target(*i);
+ if(!hdr)
+ hdr = new CSourceFile(builder, *this, *i);
+
+ // Install headers if requested
+ if(type==HEADERS && install)
+ inst_list.push_back(hdr);
+ }
+ }
+ }
+
+ if(type==PROGRAM || type==LIBRARY || type==MODULE)
+ {
+ list<Target *> objs;
+ for(PathList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i)
+ {
+ string ext = FS::extpart(FS::basename(*i));
+ const Tool *tool = toolchain.get_tool_for_suffix(ext);
+ if(tool)
+ {
+ Target *src = tool->create_source(*this, *i);
+ Target *obj = tool->create_target(*src);
+ objs.push_back(obj);
+ }
+ }
+
+ const Tool &linker = toolchain.get_tool("LINK");
+
+ list<Target *> results;
+ if(type==LIBRARY)
+ {
+ const Tool &archiver = toolchain.get_tool("AR");
+ results.push_back(linker.create_target(objs, "shared"));
+ results.push_back(archiver.create_target(objs));
+ }
+ else if(type==MODULE)
+ results.push_back(linker.create_target(objs, "shared"));
+ else
+ results.push_back(linker.create_target(objs));
+
+ for(list<Target *>::const_iterator i=results.begin(); i!=results.end(); ++i)
+ {
+ if(&pkg==builder.get_main_package() && deflt)
+ def_tgt->add_depend(*i);
+ else
+ world->add_depend(*i);
+ if(install)
+ inst_list.push_back(*i);
+ }
+ }
+
+ Target *inst_tgt = builder.get_target("install");
+ const Tool © = toolchain.get_tool("CP");
+ for(list<Target *>::const_iterator i=inst_list.begin(); i!=inst_list.end(); ++i)
+ {
+ Target *inst = copy.create_target(**i, inst_loc);
+ inst_tgt->add_depend(inst);
+ }
+}
+
+PathList Component::collect_source_files() const
+{
+ PathList files;
+ for(StringList::const_iterator i=sources.begin(); i!=sources.end(); ++i)
+ {
+ FS::Path path(*i);
+ if(FS::is_dir(path))
+ {
+ list<string> sfiles = list_files(path);
+ for(list<string>::iterator j=sfiles.begin(); j!=sfiles.end(); ++j)
+ files.push_back(path / *j);
+ }
+ else
+ files.push_back(path);
+ }
+
+ return files;