diff options
author | kartofen <mladenovnasko0@gmail.com> | 2023-11-25 17:36:19 +0200 |
---|---|---|
committer | kartofen <mladenovnasko0@gmail.com> | 2023-11-25 17:36:19 +0200 |
commit | 20802dfefd399a034900424b3813cf3a0d7718f6 (patch) | |
tree | 786bbcad70613e8d1b469b418353c2fdfdd2863a | |
parent | 4323e172facadb0af33c3295e019fcd5d8547ca5 (diff) |
-rw-r--r-- | Makefile | 43 | ||||
-rw-r--r-- | src/objload.c | 2 |
2 files changed, 35 insertions, 10 deletions
@@ -2,12 +2,13 @@ CC := gcc GLSLC := glslc ifeq ($(PROD),1) -CFLAGS := -O2 # production flags +CFLAGS := -std=c99 -O2 # production flags else -CFLAGS := -Wall -Wextra -Wpedantic -g -DDEBUG # debug flags +CFLAGS := -std=c99 -Wall -Wextra -Wpedantic -g -DDEBUG # debug flags endif -CFLAGS += -std=c99 -lm -lvulkan `sdl2-config --cflags --libs` /usr/local/lib/libcglm.a +DEP_CGLM ?= /usr/local/lib/libcglm.a +LDFLAGS += -lm -lvulkan `sdl2-config --cflags --libs` $(DEP_CGLM) SRCD := src OBJD := obj @@ -28,8 +29,8 @@ CDEPS = $(COBJS:%.o=%.d) NAME := test -all: clean $(NAME) -$(NAME): $(BIND)/$(NAME) $(SHOBJ) +all: $(NAME) $(SHOBJ) +$(NAME): $(DEP_CGLM) $(BIND)/$(NAME) clean: rm -rf $(BIND) @@ -45,9 +46,31 @@ $(BIND)/$(SHDR)/%.spv: $(FILD)/$(SHDR)/% $(BIND)/$(NAME): $(COBJS) @mkdir -p $(dir $@) - $(CC) $(CFLAGS) $^ -o $@ + $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ -# Extra Tools +# Dependency Tools + +DEP_CGLM_DIR ?= /usr/local/src + +$(DEP_CGLM): + @echo "-- DEPENDENCY NOT INSTALLED --" + @echo "DEP_CGLM=$(DEP_CGLM) does not exist" + @echo "use '[sudo] make cglm_install' to install it quickly" + @echo "DEP_CGLM_DIR is the dir where the source code will be cloned" + @echo " (default is $(DEP_CGLM_DIR))" + @exit 1 + +cglm_install: + @echo "cloning cglm at $(DEP_CGLM_DIR)" + cd $(DEP_CGLM_DIR); \ + git clone "https://github.com/recp/cglm"; \ + cd cglm && mkdir build && cd build; \ + cmake .. -DCGLM_STATIC=ON; \ + make; \ + mkdir -p $(dir $(DEP_CGLM)); \ + mv libcglm.a $(DEP_CGLM); \ + +# Debug Tools RUN_CMD := cd $(BIND) && ./$(NAME) UNITY := unity @@ -74,9 +97,11 @@ analyze: clean sanitize: clean $(MAKE) CC="clang -fsanitize=address" run -run: $(NAME) +run: all $(RUN_CMD) -valgrind: $(BIND)/$(NAME) +valgrind: all cd $(BIND) && \ valgrind -s --leak-check=full --show-leak-kinds=all ./$(NAME) + +.PHONY: all $(NAME) clean cglm_install analyze sanitize run valgrind diff --git a/src/objload.c b/src/objload.c index 7cc12ab..064cfd7 100644 --- a/src/objload.c +++ b/src/objload.c @@ -1,6 +1,6 @@ +#define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> -#define _BSD_SOURCE #include <string.h> #include "objload.h" |