42 lines
985 B
Makefile
42 lines
985 B
Makefile
CFLAGS = -I/opt/homebrew/include -O2 -Wall -Wextra
|
|
LDFLAGS = -L/opt/homebrew/lib -lglfw -lvulkan -ldl
|
|
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
|
|
|
|
%.o: %.c
|
|
$(CC) -c -o $@ $< $(CFLAGS)
|
|
|
|
.PHONY: clean clean_compdb
|
|
|
|
clean:
|
|
rm $(OBJECTS)
|
|
rm spacegame
|
|
|
|
clean_compdb:
|
|
rm -rf .compdb
|
|
rm compile_commands.json
|