X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbuilder.cpp;h=286f53b049cf8284b770821b0098fe58a4f2c77c;hb=3585dea6eabf5f1565886bf09c2bdb2eee978912;hp=b77b8fc3d453f17d755115cdc23f480f3be99b63;hpb=3772879ebdf452eeb9e8e2c04c07338c4933a3ed;p=builder.git diff --git a/source/builder.cpp b/source/builder.cpp index b77b8fc..286f53b 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -7,6 +7,7 @@ Distributed under the LGPL #include #include +#include #include #include #include @@ -54,8 +55,7 @@ Builder::Builder(int argc, char **argv): conf_all(false), conf_only(false), build_all(false), - create_makefile(false), - current_arch("native") + create_makefile(false) { string analyze_mode; string work_dir; @@ -63,6 +63,7 @@ Builder::Builder(int argc, char **argv): unsigned max_depth=5; StringList cmdline_warn; string prfx; + string arch; GetOpt getopt; getopt.add_option('a', "analyze", analyze_mode, GetOpt::REQUIRED_ARG); @@ -78,7 +79,7 @@ Builder::Builder(int argc, char **argv): 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); @@ -126,21 +127,31 @@ Builder::Builder(int argc, char **argv): 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; @@ -246,10 +257,10 @@ Target *Builder::get_header(const string &include, const string &from, const lis cout<<"Looking for include "<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; @@ -288,7 +299,7 @@ Target *Builder::get_library(const string &lib, const list &path, LibMod return i->second; StringList syspath; - if(current_arch=="native") + if(current_arch->is_native()) { syspath.push_back("/lib"); syspath.push_back("/usr/lib"); @@ -319,11 +330,6 @@ const Architecture &Builder::get_architecture(const string &arch) const 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 parts=split(pt, '-'); @@ -379,6 +385,8 @@ int Builder::main() if(conf_only) return 0; + if(verbose>=2) + cout<<"Building on "<get_name()<<", for "<get_name()<<'\n'; if(verbose>=1) cout<=2) @@ -676,7 +684,7 @@ Target *Builder::get_library(const string &lib, const FS::Path &path, LibMode mo 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"); @@ -688,7 +696,7 @@ Target *Builder::get_library(const string &lib, const FS::Path &path, LibMode mo /* 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)