- string basename=(*i)[-1];
- string ext=Path::splitext(basename).ext;
- if((ext==".cpp" || ext==".c") && build_exe)
- {
- SourceFile *src=new SourceFile(builder, this, i->str());
-
- // Compile sources
- ObjectFile *obj=new ObjectFile(builder, *this, *src);
- objs.push_back(obj);
- }
- else if(ext==".h")
- {
- Target *hdr=builder.get_target(i->str());
- if(!hdr)
- hdr=new Header(builder, this, i->str());
-
- // Install headers if requested
- if(!install_headers.empty())
- inst_tgts.push_back(hdr);
- }
- }
-
- if(build_exe)
- {
- Executable *exe=0;
- StaticLibrary *slib=0;
- if(type==LIBRARY)
- {
- exe=new SharedLibrary(builder, *this, objs);
- slib=new StaticLibrary(builder, *this, objs);
- }
- else
- exe=new Executable(builder, *this, objs);
-
- if(&pkg==builder.get_default_package() && deflt)
- {
- def_tgt->add_depend(exe);
- if(slib) def_tgt->add_depend(slib);
- }
- else
- {
- world->add_depend(exe);
- if(slib) world->add_depend(slib);
- }
-
- if(install)
- {
- inst_tgts.push_back(exe);
- if(slib)
- inst_tgts.push_back(slib);
- }
+ FS::Path dir = FS::dirname(path);
+ string last = FS::basename(dir);
+ for(OverlayList::const_iterator i=overlays.begin(); i!=overlays.end(); ++i)
+ if(last==*i)
+ {
+ dir = FS::dirname(dir);
+ break;
+ }
+
+ for(SourceList::const_iterator i=sources.begin(); i!=sources.end(); ++i)
+ if(dir==*i)
+ {
+ binfo.local_incpath.push_back(dir);
+ for(OverlayList::const_iterator j=overlays.begin(); j!=overlays.end(); ++j)
+ binfo.local_incpath.push_back(*i/ *j);
+ }