2024-01-10 23:55:11 -07:00
|
|
|
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
|
|
|
CFLAGS = -fsanitize=address -I $(ROOT_DIR)/include -I/usr/local/include -O0 -g -Wall -Wextra
|
2024-01-12 19:00:20 -07:00
|
|
|
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
|
2024-01-07 16:34:09 -07:00
|
|
|
GDB = lldb
|
2024-01-07 01:01:57 -07:00
|
|
|
|
2024-01-07 01:24:20 -07:00
|
|
|
SOURCES = $(wildcard src/*.c)
|
|
|
|
|
|
|
|
OBJECTS = $(addsuffix .o, $(basename $(SOURCES)))
|
2024-01-07 22:27:53 -07:00
|
|
|
VERT_SPV = $(addsuffix .vert.spv, $(basename $(wildcard shader_src/*.vert)))
|
|
|
|
FRAG_SPV = $(addsuffix .frag.spv, $(basename $(wildcard shader_src/*.frag)))
|
|
|
|
|
|
|
|
.PHONY: all
|
|
|
|
all: spacegame $(VERT_SPV) $(FRAG_SPV)
|
2024-01-07 01:24:20 -07:00
|
|
|
|
|
|
|
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
|
2024-01-07 01:01:57 -07:00
|
|
|
|
|
|
|
%.o: %.c
|
|
|
|
$(CC) -c -o $@ $< $(CFLAGS)
|
|
|
|
|
2024-01-07 01:24:20 -07:00
|
|
|
.PHONY: clean clean_compdb
|
|
|
|
|
|
|
|
clean:
|
2024-01-07 22:27:53 -07:00
|
|
|
rm $(FRAG_SPV)
|
|
|
|
rm $(VERT_SPV)
|
2024-01-07 01:24:20 -07:00
|
|
|
rm $(OBJECTS)
|
|
|
|
rm spacegame
|
|
|
|
|
|
|
|
clean_compdb:
|
|
|
|
rm -rf .compdb
|
|
|
|
rm compile_commands.json
|
2024-01-07 16:34:09 -07:00
|
|
|
|
|
|
|
run: spacegame
|
|
|
|
./spacegame
|
|
|
|
|
|
|
|
debug: spacegame
|
|
|
|
$(GDB) spacegame
|
2024-01-07 22:27:53 -07:00
|
|
|
|
|
|
|
|
|
|
|
%.vert.spv: %.vert
|
|
|
|
glslc $< -o $@
|
|
|
|
|
|
|
|
%.frag.spv: %.frag
|
|
|
|
glslc $< -o $@
|