From 28f36a2e69e13ee326d8bda50ad7a8df4e74d63a Mon Sep 17 00:00:00 2001 From: Jesper Jensen Date: Sun, 4 Oct 2026 23:51:01 +0200 Subject: Saving done --- Makefile | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index f93fe77..dfb868c 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,7 @@ SRCDIR ?= src INCDIR ?= inc OBJDIR ?= obj TSTDIR ?= test +TSTLIBDIR ?= test_lib INCS = -Ithirdparty/cglm/include -Ithirdparty/ -I/usr/include/json-c -I$(SRCDIR)/ LIBS = -lcurl -luuid -ljson-c @@ -20,17 +21,22 @@ APP_SOURCES = $(filter-out $(APP_MAIN_SOURCES),$(shell find $(SRCDIR) -name "*.c APP_OBJS = $(APP_SOURCES:%.c=$(OBJDIR)/%.o) APP_DEPS = $(APP_OBJS:%.o=%.d) +TST_LIB_SOURCES = $(shell find $(TSTLIBDIR) -name "*.c") +TST_LIB_OBJS = $(TST_LIB_SOURCES:%.c=$(OBJDIR)/%.o) +TST_LIB_DEPS = $(TST_LIB_OBJS:%.o=%.d) +TST_LIB_INCS = -I$(TSTLIBDIR)/ + TST_SOURCES = $(shell find $(TSTDIR) -name "*.c") TST_OBJS = $(TST_SOURCES:%.c=$(OBJDIR)/%.o) TST_DEPS = $(TST_OBJS:%.o=%.d) TST_APPS = $(TST_SOURCES:%.c=$(OBJDIR)/%) --include $(APP_DEPS) $(APP_MAIN_DEPS) $(TST_DEPS) +-include $(APP_DEPS) $(APP_MAIN_DEPS) $(TST_DEPS) $(TST_LIB_DEPS) # We don't really need to run the tests for bear to record them compile_commands.json: clean Makefile $(APP_SOURCES) @rm -f "$@" - bear -- make main + bear -- make main test main: $(APP_MAIN_OBJS) $(APP_OBJS) $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(APP_MAIN_OBJS) $(APP_OBJS) $(LIBS) @@ -39,9 +45,13 @@ $(OBJDIR)/%.o: %.c @mkdir -p $(dir $@) $(CC) $(CFLAGS) $(INCS) -MMD -o $@ -c $< -$(OBJDIR)/test/%: $(OBJDIR)/test/%.o $(APP_OBJS) +$(OBJDIR)/test/%.o: test/%.c + @mkdir -p $(dir $@) + $(CC) $(CFLAGS) $(INCS) $(TST_LIB_INCS) -MMD -o $@ -c $< + +$(OBJDIR)/test/%: $(OBJDIR)/test/%.o $(TST_LIB_OBJS) $(APP_OBJS) @mkdir -p $(dir $@) - $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $< $(APP_OBJS) $(LIBS) + $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $< $(TST_LIB_OBJS) $(APP_OBJS) $(LIBS) clean: @rm -rf $(OBJDIR) -- cgit v1.2.3