hachem.wtf
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-09-08 01:08:54 +0200
committerhachem <im@hachem.wtf>2026-09-08 01:08:54 +0200
commitff0dbe69fc101d86cb4dafac7fa9d2fb6ac1a083 (patch)
treef0f39db9c8c8bd92e5fb9991669fbcc7001ac819
parent051fe9e5ac7369827639fc4b59fd20228b053efa (diff)
fix: split sanitization and debugging
-rw-r--r--Makefile15
-rw-r--r--mkproj.c12
2 files changed, 18 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index eca30ff..327856d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,7 @@
CC := clang
STD := c17
+DEBUG ?= 1
SANITIZE ?= 1
CFLAGS := -std=$(STD) \
@@ -13,13 +14,17 @@ CFLAGS := -std=$(STD) \
-Wsign-conversion \
-Wmissing-prototypes
-ifeq ($(SANITIZE),1)
-CFLAGS += -g -fno-omit-frame-pointer -fsanitize=address,undefined
-LDFLAGS += -fsanitize=address,undefined
+ifeq ($(DEBUG),1)
+CFLAGS += -g -fno-omit-frame-pointer
else
CFLAGS += -O2
endif
+ifeq ($(SANITIZE),1)
+CFLAGS += -fsanitize=address,undefined
+LDFLAGS += -fsanitize=address,undefined
+endif
+
TARGET := mkproj
SRC := mkproj.c
@@ -39,10 +44,10 @@ check:
--error-exitcode=1
clean:
- rm -f $(TARGET)
+ rm -rf $(TARGET) $(TARGET).dSYM
install: mkproj.1
- $(MAKE) SANITIZE=0 clean all
+ $(MAKE) DEBUG=0 SANITIZE=0 clean all
install -d $(bindir)
install -m 755 $(TARGET) $(bindir)/$(TARGET)
install -d $(mandir)
diff --git a/mkproj.c b/mkproj.c
index 5a5f45d..ef2b6f9 100644
--- a/mkproj.c
+++ b/mkproj.c
@@ -575,7 +575,7 @@ static void write_makefile(FILE* out, const struct Config* config)
if ((int) strlen(flags[i]) > width)
width = (int) strlen(flags[i]);
- (void) fprintf(out, "CC := %s\nSTD := %s\n\nSANITIZE ?= 1\n\nCFLAGS := ", lang->compiler, config->standard);
+ (void) fprintf(out, "CC := %s\nSTD := %s\n\nDEBUG ?= 1\nSANITIZE ?= 1\n\nCFLAGS := ", lang->compiler, config->standard);
for (size_t i = 0; i < count; i++)
{
@@ -591,13 +591,17 @@ static void write_makefile(FILE* out, const struct Config* config)
(void) fprintf(
out,
"\n"
- "ifeq ($(SANITIZE),1)\n"
- "CFLAGS += -g -fno-omit-frame-pointer -fsanitize=address,undefined\n"
- "LDFLAGS += -fsanitize=address,undefined\n"
+ "ifeq ($(DEBUG),1)\n"
+ "CFLAGS += -g -fno-omit-frame-pointer\n"
"else\n"
"CFLAGS += -O2\n"
"endif\n"
"\n"
+ "ifeq ($(SANITIZE),1)\n"
+ "CFLAGS += -fsanitize=address,undefined\n"
+ "LDFLAGS += -fsanitize=address,undefined\n"
+ "endif\n"
+ "\n"
"TARGET := %s/%s\n"
"SRC := $(shell find src -name '*.%s')\n"
"OBJ := $(SRC:src/%%=%s/%%.o)\n"