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 SOURCES = src/main.c src/draw.c src/ui.c src/gpu.c src/hex.c lib/spng.c lib/vma.cpp OBJECTS = $(addsuffix .o, $(basename $(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: $(OBJECTS) $(CXX) $(CFLAGS) $(LDFLAGS) -o $@ $^ %.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 clean: rm -f $(SPV_FILES) rm -f $(OBJECTS) rm -f roleplay rm -rf $(EXTRA_DEBUG_REQUIREMENTS) clean_compdb: rm -rf .compdb rm compile_commands.json run: roleplay $(SPV_FILES) ./roleplay .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 $@ $<