ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) CFLAGS = -I $(ROOT_DIR)/include -I/usr/local/include -O0 -g -Wall -Wextra LDFLAGS = -lfreetype -lz -lglfw -lvulkan -ldl -Xlinker -rpath -Xlinker /opt/homebrew/lib ENGINE_SOURCES = src/engine.c src/draw.c src/ui.c src/gpu.c src/hex.c src/hsv.c lib/spng.c lib/vma.cpp APP_SOURCES = src/main.c $(ENGINE_SOURCES) EDITOR_SOURCES = src/editor.c $(ENGINE_SOURCES) TEST_SOURCES = test/hsv.c $(ENGINE_SOURCES) APP_OBJECTS = $(addsuffix .o, $(basename $(APP_SOURCES))) EDITOR_OBJECTS = $(addsuffix .o, $(basename $(EDITOR_SOURCES))) TEST_OBJECTS = $(addsuffix .o, $(basename $(TEST_SOURCES))) VERT_SPV = $(addsuffix .vert.spv, $(basename $(wildcard shader/*.vert))) FRAG_SPV = $(addsuffix .frag.spv, $(basename $(wildcard shader/*.frag))) COMP_SPV = $(addsuffix .comp.spv, $(basename $(wildcard shader/*.comp))) SPV_FILES = $(VERT_SPV) $(FRAG_SPV) $(COMP_SPV) EXTRA_DEBUG_REQUIREMENTS := UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Linux) GDB = gdb CFLAGS += -I /usr/include/freetype2 endif ifeq ($(UNAME_S),Darwin) export MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS=1 DSYM = dsymutil GDB = lldb EXTRA_DEBUG_REQUIREMENTS = roleplay.dSYM endif CC ?= clang CXX ?= clang++ .PHONY: all all: roleplay $(SPV_FILES) roleplay: $(APP_OBJECTS) $(CXX) $(CFLAGS) $(LDFLAGS) -o $@ $^ editor: $(EDITOR_OBJECTS) $(CXX) $(CFLAGS) $(LDFLAGS) -o $@ $^ test/test_hsv: $(TEST_OBJECTS) $(CXX) $(CFLAGS) $(LDFLAGS) -o $@ $^ .PHONY: test test: test/test_hsv ./test/test_hsv %.o: %.cpp $(CXX) $(CFLAGS) -std=c++17 -Wno-nullability-completeness -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unused-private-field -Wno-unused-variable -c -o $@ $< %.o: %.c $(CC) $(CFLAGS) -c -o $@ $< .PHONY: clean clean_compdb run run_editor clean: rm -f $(SPV_FILES) rm -f $(APP_OBJECTS) rm -f $(TEST_OBJECTS) rm -f roleplay rm -rf $(EXTRA_DEBUG_REQUIREMENTS) clean_compdb: rm -rf .compdb rm compile_commands.json run: roleplay $(SPV_FILES) ./roleplay run_editor: editor $(SPV_FILES) ./editor .PHONY: debug-sign debug-sign: codesign --entitlements ./ent.plist -f -s "fake-apple-signing" ./roleplay roleplay.dSYM: roleplay $(DSYM) roleplay debug: roleplay $(EXTRA_DEBUG_REQUIREMENTS) $(SPV_FILES) $(GDB) roleplay %.vert.spv: %.vert glslc -o $@ $< %.frag.spv: %.frag glslc -o $@ $< %.comp.spv: %.comp glslc -o $@ $<