From b8f4479a17e1add06e1532a00ae913cc0f4e9567 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Mon, 29 Jan 2024 00:42:05 +0100 Subject: Bump librune --- vendor/librune/make.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'vendor/librune/make.c') diff --git a/vendor/librune/make.c b/vendor/librune/make.c index d818f09..32513e1 100644 --- a/vendor/librune/make.c +++ b/vendor/librune/make.c @@ -1,6 +1,8 @@ +#define _GNU_SOURCE #include #include #include +#include #include #include #include @@ -30,10 +32,12 @@ #define streq(a, b) (!strcmp(a, b)) +#define flagset(o) (flags & (1 << ((o) - 'a'))) + static void work(void *); static int globerr(const char *, int); -static bool lflag, rflag; +static uint32_t flags; int main(int argc, char **argv) @@ -43,17 +47,13 @@ main(int argc, char **argv) cbsinit(argc, argv); rebuild(); - while ((opt = getopt(argc, argv, "lr")) != -1) { + while ((opt = getopt(argc, argv, "flr")) != -1) { switch (opt) { - case 'l': - lflag = true; - break; - case 'r': - rflag = true; - break; - default: - fprintf(stderr, "Usage: %s [-lr]\n", *argv); + case '?': + fprintf(stderr, "Usage: %s [-flr]\n", *argv); exit(EXIT_FAILURE); + default: + flags |= 1 << (opt - 'a'); } } @@ -93,7 +93,9 @@ main(int argc, char **argv) for (size_t i = 0; i < g.gl_pathc; i++) g.gl_pathv[i][strlen(g.gl_pathv[i]) - 1] = 'o'; - if (foutdatedv("librune.a", (const char **)g.gl_pathv, g.gl_pathc)) { + if (flagset('f') + || foutdatedv("librune.a", (const char **)g.gl_pathv, g.gl_pathc)) + { cmdadd(&c, "ar", "rcs", "librune.a"); cmdaddv(&c, g.gl_pathv, g.gl_pathc); cmdprc(c); @@ -116,14 +118,14 @@ work(void *p) die("strdup"); dst[strlen(dst) - 1] = 'o'; - if (foutdated(dst, src)) { + if (flagset('f') || foutdated(dst, src)) { env_or_default(&sv, "CC", CC); - if (rflag) + if (flagset('r')) env_or_default(&sv, "CFLAGS", CFLAGS_RLS); else env_or_default(&sv, "CFLAGS", CFLAGS_DBG); cmdaddv(&c, sv.buf, sv.len); - if (lflag) + if (flagset('l')) cmdadd(&c, "-flto"); cmdadd(&c, "-Iinclude", "-fPIC", "-o", dst, "-c", src); cmdprc(c); -- cgit v1.2.3