summaryrefslogtreecommitdiff
path: root/src/configure.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/configure.cc')
-rw-r--r--src/configure.cc86
1 files changed, 85 insertions, 1 deletions
diff --git a/src/configure.cc b/src/configure.cc
index bc7d3e8..a7e47eb 100644
--- a/src/configure.cc
+++ b/src/configure.cc
@@ -14,6 +14,7 @@
#include "libctor.h"
#include "tasks.h"
#include "rebuild.h"
+#include "search.h"
#include "externals.h"
std::filesystem::path configurationFile("configuration.cc");
@@ -146,6 +147,58 @@ public:
}
};
+int resolv(const Settings& settings, const std::string& name,
+ const ExternalAutomatic& ext, Flags& flags)
+{
+ using namespace std::string_literals;
+
+ flags = ext.flags;
+
+ for(const auto& header : ext.headers)
+ {
+ std::vector<std::string> paths;
+ auto it = external_includedir.find(name);
+ if(it != external_includedir.end())
+ {
+ paths.push_back(it->second);
+ }
+
+ auto res = findHeader(settings, header, paths);
+ if(res.empty())
+ {
+ std::cout << "Header " << header << " required by " << name <<
+ " not found.\n";
+ return 1;
+ }
+ auto flag = "-I"s + res.string();
+ flags.cxxflags.push_back(flag);
+ }
+
+ for(const auto& lib : ext.libs)
+ {
+ std::vector<std::string> paths;
+ auto it = external_libdir.find(name);
+ if(it != external_libdir.end())
+ {
+ paths.push_back(it->second);
+ }
+
+ auto res = findLibrary(settings, lib, paths);
+ if(res.empty())
+ {
+ std::cout << "Library " << lib << " required by " << name <<
+ " not found.\n";
+ return 1;
+ }
+ auto flag = "-L"s + res[0].parent_path().string();
+ flags.ldflags.push_back(flag);
+ flag = "-l"s + lib;
+ flags.ldflags.push_back(flag);
+ }
+
+ return 0;
+}
+
// helper constant for the visitor
template<class> inline constexpr bool always_false_v = false;
@@ -288,7 +341,11 @@ int regenerateCache(const Settings& default_settings,
std::visit([&](auto&& arg)
{
using T = std::decay_t<decltype(arg)>;
- if constexpr (std::is_same_v<T, ExternalManual>)
+ if constexpr (std::is_same_v<T, ExternalAutomatic>)
+ {
+ add_path_args(ext.name);
+ }
+ else if constexpr (std::is_same_v<T, ExternalManual>)
{
add_path_args(ext.name);
}
@@ -298,6 +355,24 @@ int regenerateCache(const Settings& default_settings,
}
}, ext.external);
+ /*
+ if(std::holds_alternative<ExternalAutomatic>(ext.external))
+ {
+ opt.add(ext.name + "-includedir", required_argument, key++,
+ "Set path to " + ext.name + " header file.",
+ [&]() {
+ //X_includedir = optarg;
+ return 0;
+ });
+
+ opt.add(ext.name + "-libdir", required_argument, key++,
+ "Set path to " + ext.name + " libraries.",
+ [&]() {
+ //X_libdir = optarg;
+ return 0;
+ });
+ }
+ */
}
opt.add("help", no_argument, 'h',
@@ -434,6 +509,15 @@ int regenerateCache(const Settings& default_settings,
return ret;
}
}
+ else if(std::holds_alternative<ExternalAutomatic>(ext.external))
+ {
+ if(auto ret = resolv(settings, ext.name,
+ std::get<ExternalAutomatic>(ext.external),
+ resolved_flags))
+ {
+ return ret;
+ }
+ }
else
{
std::cout << "Unknown external type\n";