spacegame/Makefile

42 lines
1019 B
Makefile

2024-01-07 03:04:12 -07:00
CFLAGS = -I/usr/local/include -O2 -Wall -Wextra
LDFLAGS = -L/usr/local/lib -lglfw -lvulkan -ldl -Xlinker -rpath -Xlinker /usr/local/lib
2024-01-07 01:01:57 -07:00
CC = gcc
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
2024-01-07 01:01:57 -07:00
%.o: %.c
$(CC) -c -o $@ $< $(CFLAGS)
.PHONY: clean clean_compdb
clean:
rm $(OBJECTS)
rm spacegame
clean_compdb:
rm -rf .compdb
rm compile_commands.json