diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2025-02-04 19:04:18 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2025-02-04 19:04:18 +0100 |
commit | 794335cf16b3c522b09b10dc5fb02c9554084f8a (patch) | |
tree | e1947e5dcd4f3b4dbdab1beacf7a66a577b06690 /src/configure.cc | |
parent | f4b6372c1fe8d48aceb853272e0b822b967a56d7 (diff) |
Add support for custom flags through env: CFLAGS, CXXFLAGS and LDFLAGS
Diffstat (limited to 'src/configure.cc')
-rw-r--r-- | src/configure.cc | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/configure.cc b/src/configure.cc index 7a68f03..ff4f24d 100644 --- a/src/configure.cc +++ b/src/configure.cc @@ -99,6 +99,23 @@ std::string ctor::configuration::get(const std::string& key, const std::string& return default_value; } +std::string ctor::configuration::getenv(const std::string& key) const +{ + auto envit = env.find(key); + if(envit != env.end()) + { + return envit->second; + } + + auto sysenv = std::getenv(key.data()); + if(sysenv) + { + return sysenv; + } + + return {}; +} + class Args : public std::vector<char*> { @@ -838,12 +855,24 @@ int configure(const ctor::settings& global_settings, int argc, char* argv[]) env["CC"] = cc_env; } + auto cflags_env = getenv("CFLAGS"); + if(cflags_env) + { + env["CFLAGS"] = cflags_env; + } + auto cxx_env = getenv("CXX"); if(cxx_env) { env["CXX"] = cxx_env; } + auto cxxflags_env = getenv("CXXFLAGS"); + if(cxxflags_env) + { + env["CXXFLAGS"] = cxxflags_env; + } + auto ar_env = getenv("AR"); if(ar_env) { @@ -856,6 +885,12 @@ int configure(const ctor::settings& global_settings, int argc, char* argv[]) env["LD"] = ld_env; } + auto ldflags_env = getenv("LDFLAGS"); + if(ldflags_env) + { + env["LDFLAGS"] = ldflags_env; + } + auto path_env = getenv("PATH"); if(path_env) { |