#include <msp/datafile/parser.h>
#include <msp/path/utils.h>
#include <msp/strings/formatter.h>
+#include <msp/strings/regex.h>
#include <msp/strings/utils.h>
#include <msp/time/units.h>
#include <msp/time/utils.h>
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 &, const string &from, const list<string> &path)
+Target *Builder::get_header(const string &include, const string &arch, const string &from, const list<string> &path)
{
string hash(8, 0);
update_hash(hash, from);
if(i!=includes.end())
return i->second;
- string fn=include.substr(1);
- Target *tgt=0;
- if(include[0]=='"' && (tgt=get_header(Path(from)/fn)))
- ;
- else if((tgt=get_header(Path("/usr/include")/fn)))
- ;
- //XXX Determine the C++ header location dynamically
- else if((tgt=get_header(Path("/usr/include/c++/4.1.2")/fn)))
- ;
- else
+ static string cxx_ver;
+ if(cxx_ver.empty())
{
- for(list<string>::const_iterator j=path.begin(); (j!=path.end() && !tgt); ++j)
- tgt=get_header(cwd/ *j/fn);
+ StringList argv;
+ argv.push_back(get_architecture(arch).get_tool("CXX"));
+ argv.push_back("--version");
+ cxx_ver=Regex(" ([0-9.]+) ").match(run_command(argv))[1].str;
+ while(!cxx_ver.empty() && !exists(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(include[0]=='\"')
+ syspath.push_back(from);
+ if(arch=="native")
+ syspath.push_back("/usr/include");
+ else
+ syspath.push_back("/usr/"+get_architecture(arch).get_prefix()+"/lib");
+ syspath.push_back((Path("/usr/include/c++/")/cxx_ver/fn).str());
+
+ Target *tgt=0;
+ for(list<string>::const_iterator j=syspath.begin(); (!tgt && j!=syspath.end()); ++j)
+ tgt=get_header(Path(*j)/fn);
+ for(list<string>::const_iterator j=path.begin(); (!tgt && j!=path.end()); ++j)
+ tgt=get_header(cwd/ *j/fn);
+
includes.insert(TargetMap::value_type(id, tgt));
return tgt;
else
syspath.push_back("/usr/"+get_architecture(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::iterator j=syspath.begin(); (!tgt && j!=syspath.end()); ++j)
tgt=get_library(lib, arch, *j, mode);
problem(spkg->get_name(), format("wrong architecture (%s)", spkg->get_arch()));
}
- if(!problems.empty())
- {
- cerr<<"The following problems were detected:\n";
- for(ProblemList::iterator i=problems.begin(); i!=problems.end(); ++i)
- cerr<<" "<<i->package<<": "<<i->descr<<'\n';
- cerr<<"Please fix them and try again.\n";
- return 1;
- }
-
if(conf_only)
return 0;
if(analyzer)
analyzer->analyze();
+ if(!problems.empty())
+ {
+ cerr<<"The following problems were detected:\n";
+ for(ProblemList::iterator i=problems.begin(); i!=problems.end(); ++i)
+ cerr<<" "<<i->package<<": "<<i->descr<<'\n';
+ cerr<<"Please fix them and try again.\n";
+ return 1;
+ }
+
//if(create_makefile
if(clean)