+ throw invalid_argument("Unknown tool");
+}
+
+bool Architecture::match_name(const string &pattern) const
+{
+ vector<string> parts = split(pattern, "-");
+ for(vector<string>::const_iterator i=parts.begin(); i!=parts.end(); ++i)
+ {
+ string part = resolve_alias(*i);
+ if((part=="32" && bits==32) || (part=="64" && bits==64))
+ ;
+ else if(part!=type && part!=cpu && part!=system)
+ return false;
+ }
+ return true;
+}
+
+string Architecture::resolve_alias(const string &part) const
+{
+ for(unsigned j=0; aliases[j]; j+=2)
+ if(part==aliases[j])
+ return aliases[j+1];
+
+ return part;
+}
+
+void Architecture::parse_specification(const string &spec)
+{
+ vector<string> parts = split(spec, "-");
+ for(vector<string>::const_iterator i=parts.begin(); i!=parts.end(); ++i)
+ {
+ string part = resolve_alias(*i);
+
+ bool ok = false;
+
+ for(unsigned j=0; (!ok && types[j]); ++j)
+ if(part==types[j])
+ {
+ if(!type.empty() && part!=type)
+ throw invalid_argument("Conflicting type specification");
+ type = part;
+ ok = true;
+ }
+
+ for(unsigned j=0; (!ok && cpus[j]); j+=2)
+ if(part==cpus[j])
+ {
+ if(type.empty())
+ type = cpus[j+1];
+ else if(cpus[j+1]!=type)
+ throw invalid_argument("Conflicting CPU specification");
+ cpu = part;
+ ok = true;
+ }
+
+ for(unsigned j=0; (!ok && systems[j]); ++j)
+ if(part==systems[j])
+ {
+ system = part;
+ ok = true;
+ }
+
+ if(!ok && (part=="32" || part=="64"))
+ {
+ bits = lexical_cast<unsigned>(part);
+ ok = true;
+ }
+
+ if(!ok)
+ throw invalid_argument("Unrecognized part in arch specification: "+*i);
+ }