+ if(include[0]=='\"')
+ tgt=get_header(Path(from)/fn);
+ for(list<string>::const_iterator j=path.begin(); (!tgt && j!=path.end()); ++j)
+ tgt=get_header(cwd/ *j/fn);
+ for(list<string>::const_iterator j=syspath.begin(); (!tgt && j!=syspath.end()); ++j)
+ tgt=get_header(Path(*j)/fn);
+
+ includes.insert(TargetMap::value_type(id, tgt));
+
+ return tgt;
+}
+
+/**
+Tries to locate a library with the given library path. Considers known targets
+as well as existing files. If a matching target is not found but a file exists,
+a new SystemLibrary target will be created and returned.
+
+@param lib Name of the library to get (without "lib" prefix or extension)
+@param path List of paths to search for the library
+@param mode Shared / static mode
+
+@return Some kind of library target, if a match was found
+*/
+Target *Builder::get_library(const string &lib, const list<string> &path, LibMode mode)
+{
+ string hash(8, 0);
+ for(list<string>::const_iterator i=path.begin(); i!=path.end(); ++i)
+ update_hash(hash, *i);
+
+ string id=hash+string(1, mode)+lib;
+ TargetMap::iterator i=libraries.find(id);
+ if(i!=libraries.end())
+ return i->second;
+
+ StringList syspath;
+ if(current_arch=="native")
+ {
+ syspath.push_back("/lib");
+ syspath.push_back("/usr/lib");
+ }
+ else
+ syspath.push_back("/usr/"+get_current_arch().get_prefix()+"/lib");
+
+ if(verbose>=5)
+ cout<<"Looking for library "<<lib<<" with path "<<join(path.begin(), path.end())<<'\n';
+
+ Target *tgt=0;
+ for(StringList::const_iterator j=path.begin(); (!tgt && j!=path.end()); ++j)
+ tgt=get_library(lib, cwd/ *j, mode);
+ for(StringList::iterator j=syspath.begin(); (!tgt && j!=syspath.end()); ++j)
+ tgt=get_library(lib, *j, mode);
+
+ libraries.insert(TargetMap::value_type(id, tgt));
+
+ return tgt;
+}
+
+const Architecture &Builder::get_architecture(const string &arch) const
+{
+ ArchMap::const_iterator i=archs.find(arch);
+ if(i==archs.end())
+ throw KeyError("Unknown architecture", arch);
+
+ return i->second;
+}
+
+const Architecture &Builder::get_current_arch() const
+{
+ return get_architecture(current_arch);
+}
+
+void Builder::apply_profile_template(Config &config, const string &pt) const
+{
+ vector<string> parts=split(pt, '-');
+
+ for(vector<string>::iterator i=parts.begin(); i!=parts.end(); ++i)
+ {
+ ProfileTemplateMap::const_iterator j=profile_tmpl.find(*i);
+ if(j==profile_tmpl.end())
+ continue;
+
+ config.update(j->second);
+ }
+}
+
+void Builder::problem(const string &p, const string &d)
+{
+ problems.push_back(Problem(p, d));
+}
+
+/**
+Adds a target to both the target map and the new target queue. Called from
+Target constructor.
+*/
+void Builder::add_target(Target *t)
+{
+ targets.insert(TargetMap::value_type(t->get_name(), t));
+ new_tgts.push_back(t);