Commit 9dbb1476 authored by jan.koester's avatar jan.koester
Browse files

test

parent c0358bed
Loading
Loading
Loading
Loading
+13 −1
Changes for main.cpp: 13 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -32,6 +32,16 @@ static void print_version() {
    std::cout << "makeplus 0.1.0 - GNU Make compatible build system" << std::endl;
}

// Make-special variables are never propagated to sub-makes as ordinary
// command-line overrides (the "--" section of MAKEFLAGS): make controls them
// itself. In particular the kernel passes MAKEFLAGS="..." as a command-line
// assignment to its tools/ recursion, and re-emitting that as an override would
// corrupt the carrier MAKEFLAGS of every nested sub-make.
static bool is_make_special_var(const std::string& name) {
    return name == "MAKEFLAGS" || name == "MFLAGS" ||
           name == "MAKEOVERRIDES" || name == "MAKELEVEL" || name == "MAKE";
}

static void setup_defaults(makeplus::Makefile& mf, const char* argv0) {
    // Default variables (only if not already set)
    auto set_default = [&](const std::string& name, const std::string& value) {
@@ -257,7 +267,8 @@ int main(int argc, char* argv[]) {
            auto flush = [&]() {
                if (word.empty()) return;
                size_t e = word.find('=');
                if (e != std::string::npos && e > 0)
                if (e != std::string::npos && e > 0 &&
                    !is_make_special_var(word.substr(0, e)))
                    inherited.emplace_back(word.substr(0, e), word.substr(e + 1));
                word.clear();
            };
@@ -315,6 +326,7 @@ int main(int argc, char* argv[]) {
            std::map<std::string, std::string> ov;
            std::vector<std::string> order;
            for (const auto& kv : cmdline_vars) {
                if (is_make_special_var(kv.first)) continue;
                if (!ov.count(kv.first)) order.push_back(kv.first);
                ov[kv.first] = kv.second;   // later (command-line) value wins
            }