summaryrefslogtreecommitdiff
path: root/src/configure.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/configure.cc')
-rw-r--r--src/configure.cc69
1 files changed, 53 insertions, 16 deletions
diff --git a/src/configure.cc b/src/configure.cc
index a2bb8bc..10f3056 100644
--- a/src/configure.cc
+++ b/src/configure.cc
@@ -193,6 +193,26 @@ std::ostream& operator<<(std::ostream& stream, const ctor::toolchain& toolchain)
return stream;
}
+std::ostream& operator<<(std::ostream& stream, const ctor::arch& arch)
+{
+ switch(arch)
+ {
+ case ctor::arch::unix:
+ stream << "ctor::arch::unix";
+ break;
+ case ctor::arch::apple:
+ stream << "ctor::arch::apple";
+ break;
+ case ctor::arch::windows:
+ stream << "ctor::arch::windows";
+ break;
+ case ctor::arch::unknown:
+ stream << "ctor::arch::unknown";
+ break;
+ }
+ return stream;
+}
+
std::ostream& operator<<(std::ostream& ostr, const ctor::c_flag& flag)
{
for(const auto& s : to_strings(ctor::toolchain::any, flag))
@@ -243,9 +263,9 @@ int regenerateCache(ctor::settings& settings,
dg::Options opt;
int key{128};
- std::string build_arch;
+ std::string build_arch_prefix;
std::string build_path;
- std::string host_arch;
+ std::string host_arch_prefix;
std::string host_path;
std::string cc_prog = "gcc";
std::string cxx_prog = "g++";
@@ -302,7 +322,7 @@ int regenerateCache(ctor::settings& settings,
opt.add("build", required_argument, key++,
"Configure for building on specified architecture.",
[&]() {
- build_arch = optarg;
+ build_arch_prefix = optarg;
return 0;
});
@@ -316,7 +336,7 @@ int regenerateCache(ctor::settings& settings,
opt.add("host", required_argument, key++,
"Cross-compile to build programs to run on specified architecture.",
[&]() {
- host_arch = optarg;
+ host_arch_prefix = optarg;
return 0;
});
@@ -399,9 +419,9 @@ int regenerateCache(ctor::settings& settings,
opt.process(vargs.size(), vargs.data());
- if(host_arch.empty())
+ if(host_arch_prefix.empty())
{
- host_arch = build_arch;
+ host_arch_prefix = build_arch_prefix;
}
auto tasks = getTasks(settings, {}, false);
@@ -455,14 +475,29 @@ int regenerateCache(ctor::settings& settings,
ld_prog = ld_env->second;
}
- std::string host_cc = locate(host_arch, cc_prog);
- std::string host_cxx = locate(host_arch, cxx_prog);
- std::string host_ar = locate(host_arch, ar_prog);
- std::string host_ld = locate(host_arch, ld_prog);
- std::string build_cc = locate(build_arch, cc_prog);
- std::string build_cxx = locate(build_arch, cxx_prog);
- std::string build_ar = locate(build_arch, ar_prog);
- std::string build_ld = locate(build_arch, ld_prog);
+ // Host detection
+ auto host_cc = locate(host_arch_prefix, cc_prog);
+ auto host_cxx = locate(host_arch_prefix, cxx_prog);
+ auto host_ar = locate(host_arch_prefix, ar_prog);
+ auto host_ld = locate(host_arch_prefix, ld_prog);
+
+ auto host_toolchain = getToolChain(host_cxx);
+ auto host_arch_str = get_arch(ctor::output_system::host);
+ auto host_arch = get_arch(ctor::output_system::host, host_arch_str);
+
+ std::cout << "** Host architecture '" << host_arch_str << "': " << host_arch << std::endl;
+
+ // Build detection
+ auto build_cc = locate(build_arch_prefix, cc_prog);
+ auto build_cxx = locate(build_arch_prefix, cxx_prog);
+ auto build_ar = locate(build_arch_prefix, ar_prog);
+ auto build_ld = locate(build_arch_prefix, ld_prog);
+
+ auto build_toolchain = getToolChain(build_cxx);
+ auto build_arch_str = get_arch(ctor::output_system::build);
+ auto build_arch = get_arch(ctor::output_system::build, build_arch_str);
+
+ std::cout << "** Build architecture '" << build_arch_str << "': " << build_arch << std::endl;
if(!host_cxx.empty())
{
@@ -494,8 +529,10 @@ int regenerateCache(ctor::settings& settings,
istr << "{\n";
istr << " static ctor::configuration cfg =\n";
istr << " {\n";
- istr << " .host_toolchain = " << getToolChain(host_cxx) << ",\n";
- istr << " .build_toolchain = " << getToolChain(build_cxx) << ",\n";
+ istr << " .host_toolchain = " << host_toolchain << ",\n";
+ istr << " .host_arch = " << host_arch << ",\n";
+ istr << " .build_toolchain = " << build_toolchain << ",\n";
+ istr << " .build_arch = " << build_arch << ",\n";
istr << " .args = {";
for(const auto& arg : args)
{