diff options
author | kartofen <mladenovnasko0@gmail.com> | 2023-10-16 23:46:15 +0300 |
---|---|---|
committer | kartofen <mladenovnasko0@gmail.com> | 2023-10-16 23:46:15 +0300 |
commit | 5e910c7e41d18dab95e34ceb6e620a8958197ae6 (patch) | |
tree | bf49c8ca6dd123d0765beef63d5858445dcf24aa /Makefile |
things done
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0009173 --- /dev/null +++ b/Makefile @@ -0,0 +1,83 @@ +CC := gcc +GLSLC := glslc + +ifeq ($(PROD),1) +CFLAGS := -O2 # production flags +else +CFLAGS := -Wall -Wextra -Wpedantic -g -DDEBUG # debug flags +endif + +CFLAGS += -std=c99 -lm -lvulkan `sdl2-config --cflags --libs` + +SRCD := src +OBJD := obj +BIND := bin +FILD := files +SHDR := shaders + +SFILE = $(shell find $(SRCD)/ -type f 2> /dev/null) +CSRCS = $(filter %.c, $(SFILE)) +COBJS = $(CSRCS:$(SRCD)/%.c=$(OBJD)/%.o) + +FILES = $(shell find $(FILD) -type f 2> /dev/null) +SHDRS = $(filter %.vert %.frag, $(FILES)) +SHOBJ = $(SHDRS:$(FILD)/$(SHDR)/%=$(BIND)/$(SHDR)/%.spv) + +CDEPS = $(COBJS:%.o=%.d) +-include $(CDEPS) + +NAME := test + +all: clean $(NAME) +$(NAME): $(BIND)/$(NAME) $(SHOBJ) + +clean: + rm -rf $(BIND) + rm -rf $(OBJD) + +$(OBJD)/%.o: $(SRCD)/%.c + @mkdir -p $(dir $@) + $(CC) $(CFLAGS) -MMD -MF $(@:%.o=%.d) -c $< -o $@ + +$(BIND)/$(SHDR)/%.spv: $(FILD)/$(SHDR)/% + @mkdir -p $(dir $@) + $(GLSLC) $< -o $@ + +$(BIND)/$(NAME): $(COBJS) + @mkdir -p $(dir $@) + $(CC) $(CFLAGS) $^ -o $@ + +# Extra Tools + +RUN_CMD := $(BIND)/$(NAME) +UNITY := unity + +$(BIND)/$(UNITY): $(CSRCS) + @mkdir -p $(dir $@) + + for src in $^; do \ + cat $${src} >> $(SRCD)/$(UNITY).c; \ + done + + $(CC) $(CFLAGS) $(SRCD)/$(UNITY).c -o $@ + @rm $(SRCD)/$(UNITY).c + +analyze: clean + scan-build \ + -enable-checker alpha \ + -enable-checker core \ + -enable-checker deadcode \ + -enable-checker security \ + -enable-checker unix \ + make $(BIND)/$(UNITY) + +sanitize: clean + $(MAKE) CC="clang -fsanitize=address" run + +run: $(NAME) + $(RUN_CMD) + +valgrind: all + valgrind -s --leak-check=full --show-leak-kinds=all $(RUN_CMD) + + |