- list<Target *> objs;
- const Toolchain &pkg_tools = package.get_toolchain();
- for(SourceList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i)
- {
- string ext = FS::extpart(FS::basename(*i));
- Target *src = 0;
-
- Tool *gen = pkg_tools.get_tool_for_suffix(ext);
- if(gen)
- {
- Target *tmpl = gen->create_source(*this, *i);
- if(tmpl)
- {
- src = gen->create_target(*tmpl);
- ext = FS::extpart(FS::basename(dynamic_cast<FileTarget &>(*src).get_path()));
- }
- }
-
- Tool *tool = toolchain.get_tool_for_suffix(ext, true);
- if(tool)
- {
- if(!src)
- src = tool->create_source(*this, *i);
- if(!src)
- continue;
-
- if(tool->accepts_suffix(ext))
- {
- Target *obj = tool->create_target(*src);
- objs.push_back(obj);
- }
-
- if(type==LIBRARY && install)
- {
- if(dynamic_cast<FileTarget *>(src)->is_installable())
- build_graph.add_installed_target(*src);
-
- const Target::Dependencies &side_effects = src->get_side_effects();
- for(Target::Dependencies::const_iterator j=side_effects.begin(); j!=side_effects.end(); ++j)
- if(dynamic_cast<FileTarget *>(*j)->is_installable())
- build_graph.add_installed_target(**j);
- }
- }
- }
-
- Tool &linker = toolchain.get_tool("LINK");
-
- list<Target *> results;
- if(type==LIBRARY)
- {
- 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));
+ FS::Path dir = FS::dirname(path);
+ string last = FS::basename(dir);
+ if(any_equals(overlays, last))
+ dir = FS::dirname(dir);