#include <iostream>
#include <set>
+#include <sys/utsname.h>
#include <msp/core/except.h>
#include <msp/core/getopt.h>
#include <msp/datafile/parser.h>
conf_all(false),
conf_only(false),
build_all(false),
- create_makefile(false),
- current_arch("native")
+ create_makefile(false)
{
string analyze_mode;
string work_dir;
unsigned max_depth=5;
StringList cmdline_warn;
string prfx;
+ string arch;
GetOpt getopt;
getopt.add_option('a', "analyze", analyze_mode, GetOpt::REQUIRED_ARG);
getopt.add_option('C', "chdir", work_dir, GetOpt::REQUIRED_ARG);
getopt.add_option('P', "progress", show_progress, GetOpt::NO_ARG);
getopt.add_option('W', "what-if", what_if, GetOpt::REQUIRED_ARG);
- getopt.add_option( "arch", current_arch, GetOpt::REQUIRED_ARG);
+ getopt.add_option( "arch", arch, GetOpt::REQUIRED_ARG);
getopt.add_option( "conf-only", conf_only, GetOpt::NO_ARG);
getopt.add_option( "full-paths", full_paths, GetOpt::NO_ARG);
//getopt.add_option( "makefile", create_makefile, GetOpt::NO_ARG);
cwd=FS::getcwd();
- Architecture &native_arch=archs.insert(ArchMap::value_type("native", Architecture(*this, "native"))).first->second;
- native_arch.set_tool("CC", "gcc");
- native_arch.set_tool("CXX", "g++");
- native_arch.set_tool("LD", "gcc");
- native_arch.set_tool("LXX", "g++");
- native_arch.set_tool("AR", "ar");
+ utsname un;
+ string sysname="native";
+ if(uname(&un)==0)
+ sysname=tolower(un.sysname);
+
+ native_arch=&archs.insert(ArchMap::value_type(sysname, Architecture(*this, sysname, true))).first->second;
+ native_arch->set_tool("CC", "gcc");
+ native_arch->set_tool("CXX", "g++");
+ native_arch->set_tool("LD", "gcc");
+ native_arch->set_tool("LXX", "g++");
+ native_arch->set_tool("AR", "ar");
load_build_file((FS::get_home_dir()/".builderrc").str());
+ if(arch.empty())
+ current_arch=native_arch;
+ else
+ current_arch=&get_architecture(arch);
+
if(prfx.empty())
{
- if(current_arch=="native")
+ if(current_arch->is_native())
prefix=(FS::get_home_dir()/"local").str();
else
- prefix=(FS::get_home_dir()/"local"/current_arch).str();
+ prefix=(FS::get_home_dir()/"local"/current_arch->get_name()).str();
}
else
prefix=FS::getcwd()/prfx;
cout<<"Looking for include "<<fn<<" with path "<<join(path.begin(), path.end())<<'\n';
StringList syspath;
- if(current_arch=="native")
+ if(current_arch->is_native())
syspath.push_back("/usr/include");
else
- syspath.push_back("/usr/"+get_architecture(current_arch).get_prefix()+"/include");
+ syspath.push_back("/usr/"+current_arch->get_prefix()+"/include");
syspath.push_back((FS::Path("/usr/include/c++/")/cxx_ver/fn).str());
Target *tgt=0;
return i->second;
StringList syspath;
- if(current_arch=="native")
+ if(current_arch->is_native())
{
syspath.push_back("/lib");
syspath.push_back("/usr/lib");
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, '-');
if(conf_only)
return 0;
+ if(verbose>=2)
+ cout<<"Building on "<<native_arch->get_name()<<", for "<<current_arch->get_name()<<'\n';
if(verbose>=1)
cout<<all_reqs.size()<<" active packages, "<<targets.size()<<" targets\n";
if(verbose>=2)
if(mode!=ALL_STATIC)
{
- if(current_arch=="win32")
+ if(current_arch->get_name()=="win32")
{
candidates.push_back("lib"+lib+".dll");
candidates.push_back(lib+".dll");
/* Static libraries are always considered, since sometimes shared versions
may not be available */
candidates.push_back("lib"+lib+".a");
- if(current_arch=="win32")
+ if(current_arch->get_name()=="win32")
candidates.push_back("lib"+lib+".dll.a");
for(StringList::iterator i=candidates.begin(); i!=candidates.end(); ++i)