spacegame/Makefile

63 lines
1.4 KiB
Makefile

CFLAGS = -fsanitize=address -I/usr/local/include -O0 -g -Wall -Wextra
2024-01-07 03:04:12 -07:00
LDFLAGS = -L/usr/local/lib -lglfw -lvulkan -ldl -Xlinker -rpath -Xlinker /usr/local/lib
CC = clang
GDB = lldb
2024-01-07 01:01:57 -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)
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)
.PHONY: clean clean_compdb
clean:
2024-01-07 22:27:53 -07:00
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
2024-01-07 22:27:53 -07:00
%.vert.spv: %.vert
glslc $< -o $@
%.frag.spv: %.frag
glslc $< -o $@