+ //const Tool &tar = toolchain.get_tool("TAR");
+
+ string tarname = name;
+ if(name=="@src")
+ {
+ tarname = pkg.get_name()+"-"+pkg.get_version();
+ source_filenames.push_back(pkg.get_source()/"Build");
+ }
+
+ list<Target *> files;
+ for(PathList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i)
+ {
+ FileTarget *file = builder.get_vfs().get_target(*i);
+ if(!file)
+ file = new File(builder, *i);
+ files.push_back(file);
+ }
+
+ if(name=="@src")
+ {
+ const Builder::TargetMap &targets = builder.get_targets();
+ for(Builder::TargetMap::const_iterator i=targets.begin(); i!=targets.end(); ++i)
+ if(i->second->get_package()==&pkg && !i->second->is_buildable())
+ files.push_back(i->second);
+ }
+
+ /* XXX The source files don't have a package at the moment, so we can't
+ create the tarball target until things get fixed up a bit */
+ /*Target *result = tar.create_target(files, tarname);
+
+ Target *tarballs_tgt = builder.get_target("tarballs");
+ tarballs_tgt->add_depend(result);*/
+
+ return;
+ }
+ else if(type==INSTALL)
+ {
+ inst_loc = name;
+ for(PathList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i)
+ {
+ FileTarget *ft;
+ if(Target *tgt = builder.get_vfs().get_target(*i))
+ ft = dynamic_cast<FileTarget *>(tgt);
+ else
+ ft = new File(builder, pkg, *i);
+ inst_list.push_back(ft);
+ }
+ }
+ else if(type==DATAFILE)
+ {
+ const Tool &dcomp = toolchain.get_tool("DATA");
+
+ File *source;
+ if(Target *tgt = builder.get_vfs().get_target(source_filenames.front()))
+ source = dynamic_cast<File *>(tgt);
+ else
+ source = new File(builder, pkg, source_filenames.front());
+ Target *result = dcomp.create_target(*source);
+
+ 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);
+ }
+ }