|
|
|
@ -2,10 +2,40 @@ CFLAGS = -I/opt/homebrew/include -O2 -Wall -Wextra
|
|
|
|
|
LDFLAGS = -L/opt/homebrew/lib -lglfw -lvulkan -ldl
|
|
|
|
|
CC = gcc
|
|
|
|
|
|
|
|
|
|
SOURCES = $(wildcard $(SRC)/*.c)
|
|
|
|
|
SOURCES = $(wildcard src/*.c)
|
|
|
|
|
|
|
|
|
|
OBJECTS = $(addsuffix .o, $(basename $(SOURCES)))
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
spacegame: src/main.o
|
|
|
|
|
$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS)
|
|
|
|
|
.PHONY: clean clean_compdb
|
|
|
|
|
|
|
|
|
|
clean:
|
|
|
|
|
rm $(OBJECTS)
|
|
|
|
|
rm spacegame
|
|
|
|
|
|
|
|
|
|
clean_compdb:
|
|
|
|
|
rm -rf .compdb
|
|
|
|
|
rm compile_commands.json
|
|
|
|
|