- prefix=FS::getcwd()/prfx;
-
- warnings.push_back("all");
- warnings.push_back("extra");
- warnings.push_back("shadow");
- warnings.push_back("pointer-arith");
- warnings.push_back("error");
- for(StringList::iterator i=cmdline_warn.begin(); i!=cmdline_warn.end(); ++i)
- {
- vector<string> warns=split(*i, ',');
- warnings.insert(warnings.end(), warns.begin(), warns.end());
- }
-
- pkg_path.push_back(cwd/".");
- pkg_path.push_back(cwd/"..");
-}
-
-/**
-Gets a package by name, possibly creating it.
-
-@param name Package name
-
-@return Pointer to the package, or 0 if the package could not be located
-*/
-Package *Builder::get_package(const string &name)
-{
- PackageMap::iterator i=packages.find(format("%s/%s", name, current_arch));
- if(i==packages.end())
- i=packages.find(name);
- if(i!=packages.end())
- return i->second;
-
- FS::Path path=get_package_location(name);
- if(!path.empty() && !load_build_file(path/"Build"))
- {
- i=packages.find(name);
- if(i!=packages.end())
- return i->second;
- }
-
- // Package source not found - create a binary package
- Package *pkg=BinaryPackage::from_pkgconfig(*this, name);
-
- packages.insert(PackageMap::value_type(name, pkg));
-
- if(!pkg)
- problem(name, "not found");
-
- return pkg;
-}
-
-/**
-Returns the target with the given name, or 0 if no such target exists.
-*/
-Target *Builder::get_target(const string &n) const
-{
- TargetMap::const_iterator i=targets.find(n);
- if(i!=targets.end())
- return i->second;
- return 0;
-}
-
-/**
-Tries to locate a header included from a given location and with a given include
-path. Considers known targets as well as existing files. If a matching target
-is not found but a file exists, a new SystemHeader target will be created and
-returned.
-*/
-Target *Builder::get_header(const string &include, const string &from, const list<string> &path)
-{
- string hash(8, 0);
- update_hash(hash, from);
- for(list<string>::const_iterator i=path.begin(); i!=path.end(); ++i)
- update_hash(hash, *i);
-
- string id=hash+include;
- TargetMap::iterator i=includes.find(id);
- if(i!=includes.end())
- return i->second;
-
- static string cxx_ver;
- if(cxx_ver.empty())
- {
- StringList argv;
- argv.push_back(get_current_arch().get_tool("CXX"));
- argv.push_back("--version");
- cxx_ver=Regex("[0-9]\\.[0-9.]+").match(run_command(argv))[0].str;
- while(!cxx_ver.empty() && !FS::is_dir(FS::Path("/usr/include/c++")/cxx_ver))
- {
- unsigned dot=cxx_ver.rfind('.');
- if(dot==string::npos)
- break;
- cxx_ver.erase(dot);
- }
- if(verbose>=5)
- cout<<"C++ version is "<<cxx_ver<<'\n';
- }
-
- string fn=include.substr(1);
- if(verbose>=5)
- cout<<"Looking for include "<<fn<<" with path "<<join(path.begin(), path.end())<<'\n';
-
- StringList syspath;
- if(current_arch=="native")
- syspath.push_back("/usr/include");
- else
- syspath.push_back("/usr/"+get_architecture(current_arch).get_prefix()+"/include");
- syspath.push_back((FS::Path("/usr/include/c++/")/cxx_ver/fn).str());
-
- Target *tgt=0;
- if(include[0]=='\"')
- tgt=get_header(FS::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(FS::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.