aboutsummaryrefslogtreecommitdiff
path: root/vendor/librune/make.c
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-01-27 23:26:42 +0100
committerThomas Voss <mail@thomasvoss.com> 2024-01-27 23:26:42 +0100
commit679f7928e27a95e559eb3a69febf0c6336e40234 (patch)
treeaf9c5bb35253086eb8e3ad3d7774e7349b3beefe /vendor/librune/make.c
parentfd502fd87b40ae7f60314d8d9009f739f1c5fcf3 (diff)
Bump librune
Diffstat (limited to 'vendor/librune/make.c')
-rw-r--r--vendor/librune/make.c45
1 files changed, 36 insertions, 9 deletions
diff --git a/vendor/librune/make.c b/vendor/librune/make.c
index a7227c9..d818f09 100644
--- a/vendor/librune/make.c
+++ b/vendor/librune/make.c
@@ -9,13 +9,14 @@
#define CBS_PTHREAD
#include "cbs.h"
-#define CC "cc"
+#define CC "cc"
+#define WARNINGS "-Wall", "-Wextra", "-Wpedantic", "-Werror", "-Wno-attributes"
+#define CFLAGS_ALL WARNINGS, "-pipe", "-std=c2x"
+#define CFLAGS_DBG CFLAGS_ALL, "-g", "-ggdb3", "-Og"
#ifdef __APPLE__
-# define CFLAGS "-Wall", "-Wextra", "-Wpedantic", "-Werror", "-pipe", "-O3"
+# define CFLAGS_RLS CFLAGS_ALL, "-O3"
#else
-# define CFLAGS \
- "-Wall", "-Wextra", "-Wpedantic", "-Werror", "-pipe", "-O3", \
- "-march=native", "-mtune=native"
+# define CFLAGS_RLS CFLAGS_ALL, "-O3", "-march=native", "-mtune=native"
#endif
#define cmdprc(c) \
@@ -32,19 +33,40 @@
static void work(void *);
static int globerr(const char *, int);
+static bool lflag, rflag;
+
int
main(int argc, char **argv)
{
+ int opt;
+
cbsinit(argc, argv);
rebuild();
- if (argc > 1) {
- if (streq(argv[1], "clean")) {
+ while ((opt = getopt(argc, argv, "lr")) != -1) {
+ switch (opt) {
+ case 'l':
+ lflag = true;
+ break;
+ case 'r':
+ rflag = true;
+ break;
+ default:
+ fprintf(stderr, "Usage: %s [-lr]\n", *argv);
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ argc -= optind;
+ argv += optind;
+
+ if (argc >= 1) {
+ if (streq(*argv, "clean")) {
cmd_t c = {0};
cmdadd(&c, "find", ".", "-name", "*.[ao]", "-delete");
cmdprc(c);
} else {
- diex("invalid subcommand -- '%s'", argv[1]);
+ diex("invalid subcommand -- '%s'", *argv);
exit(EXIT_FAILURE);
}
} else {
@@ -96,8 +118,13 @@ work(void *p)
if (foutdated(dst, src)) {
env_or_default(&sv, "CC", CC);
- env_or_default(&sv, "CFLAGS", CFLAGS);
+ if (rflag)
+ env_or_default(&sv, "CFLAGS", CFLAGS_RLS);
+ else
+ env_or_default(&sv, "CFLAGS", CFLAGS_DBG);
cmdaddv(&c, sv.buf, sv.len);
+ if (lflag)
+ cmdadd(&c, "-flto");
cmdadd(&c, "-Iinclude", "-fPIC", "-o", dst, "-c", src);
cmdprc(c);
}