aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-01-18 10:37:21 +0100
committerThomas Voss <mail@thomasvoss.com> 2024-01-18 10:37:21 +0100
commit42fe824ea8255869a5b5df8be9703dfabefba11b (patch)
tree319e2baa2836260c9c621d1980993a4bf706560f
parentab8c6f957e1e2d9b24acc00413c28fb2020e1516 (diff)
Support custom CFLAGS and CC
-rw-r--r--make.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/make.c b/make.c
index 12764da..d56967c 100644
--- a/make.c
+++ b/make.c
@@ -75,23 +75,30 @@ main(int argc, char **argv)
cmdprc(c);
}
} else {
- if (foutdated("grab", "src/grab.c", "src/da.h")) {
- for (int i = 0; i < 2; i++) {
- char buf[] = "-DGIT_GRAB=X";
- buf[sizeof(buf) - 2] = i + '0';
-
- cmdadd(&c, CC, CFLAGS);
- cmdadd(&c, buf);
- if (!Pflag)
- cmdadd(&c, "-DGRAB_DO_PCRE=1", "-lpcre2-posix");
- if (debug)
- cmdadd(&c, CFLAGS_DEBUG);
- else
- cmdadd(&c, CFLAGS_RELEASE);
- cmdadd(&c, "-o", i == 0 ? "grab" : "git-grab", "src/grab.c");
- cmdprc(c);
- }
+ struct strv cc = {0};
+ struct strv cflags = {0};
+
+ env_or_default(&cc, "CC", CC);
+ if (debug)
+ env_or_default(&cflags, "CFLAGS", CFLAGS, CFLAGS_DEBUG);
+ else
+ env_or_default(&cflags, "CFLAGS", CFLAGS, CFLAGS_RELEASE);
+
+ for (int i = 0; i < 2; i++) {
+ char buf[] = "-DGIT_GRAB=X";
+ buf[sizeof(buf) - 2] = i + '0';
+
+ cmdaddv(&c, cc.buf, cc.len);
+ cmdaddv(&c, cflags.buf, cflags.len);
+ cmdadd(&c, buf);
+ if (!Pflag)
+ cmdadd(&c, "-DGRAB_DO_PCRE=1", "-lpcre2-posix");
+ cmdadd(&c, "-o", i == 0 ? "grab" : "git-grab", "src/grab.c");
+ cmdprc(c);
}
+
+ strvfree(&cc);
+ strvfree(&cflags);
}
return EXIT_SUCCESS;