ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) CFLAGS = -fsanitize=address -I $(ROOT_DIR)/include -I/usr/local/include -O0 -g -Wall -Wextra LDFLAGS = -L/opt/homebrew/opt/llvm/lib -L/usr/local/lib -lglfw -lvulkan -ldl -Xlinker -rpath -Xlinker /usr/local/lib -Xlinker -rpath -Xlinker /opt/homebrew/opt/llvm/lib -Xpreprocessor -fooenmp CC = /opt/homebrew/opt/llvm/bin/clang GDB = lldb SOURCES = $(wildcard src/*.c) OBJECTS = $(addsuffix .o, $(basename $(SOURCES))) VERT_SPV = $(addsuffix .vert.spv, $(basename $(wildcard shader_src/*.vert))) FRAG_SPV = $(addsuffix .frag.spv, $(basename $(wildcard shader_src/*.frag))) export MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS=1 .PHONY: all all: spacegame $(VERT_SPV) $(FRAG_SPV) spacegame: $(OBJECTS) $(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS) .compdb/%.compdb_entry: %.c @mkdir -p $(shell dirname $@) @echo " {" > $@ @echo " \"command\": \"$(CC) $(CFLAGS) -c $<\"," >> $@ @echo " \"directory\": \"$(CURDIR)\"," >> $@ @echo " \"file\": \"$<\"" >> $@ @echo " }," >> $@ COMPDB_ENTRIES = $(addprefix .compdb/, $(addsuffix .compdb_entry, $(basename $(SOURCES)))) compile_commands.json: $(COMPDB_ENTRIES) @echo "[" > $@.tmp @cat $^ >> $@.tmp @sed '$$d' < $@.tmp > $@ @echo " }" >> $@ @echo "]" >> $@ @rm $@.tmp %.o: %.c $(CC) -c -o $@ $< $(CFLAGS) .PHONY: clean clean_compdb clean: rm $(FRAG_SPV) rm $(VERT_SPV) rm $(OBJECTS) rm spacegame clean_compdb: rm -rf .compdb rm compile_commands.json run: spacegame ./spacegame debug: spacegame $(GDB) spacegame %.vert.spv: %.vert glslangValidator -V -o $@ $< %.frag.spv: %.frag glslangValidator -V -o $@ $<