2024-10-09 10:54:19 -06:00
|
|
|
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
2024-10-28 13:47:54 -06:00
|
|
|
CFLAGS = -I $(ROOT_DIR)/include -I/usr/local/include -O0 -g -Wall -Wextra -fsanitize=address
|
2024-10-16 20:29:19 -06:00
|
|
|
LDFLAGS = -lfreetype -lz -lglfw -lvulkan -ldl -Xlinker -rpath -Xlinker /opt/homebrew/lib
|
2024-10-09 10:54:19 -06:00
|
|
|
|
2024-10-21 12:52:45 -06:00
|
|
|
SOURCES = src/main.c src/draw.c src/ui.c src/gpu.c lib/spng.c lib/vma.cpp
|
2024-10-09 10:54:19 -06:00
|
|
|
OBJECTS = $(addsuffix .o, $(basename $(SOURCES)))
|
|
|
|
VERT_SPV = $(addsuffix .vert.spv, $(basename $(wildcard shader_src/*.vert)))
|
|
|
|
FRAG_SPV = $(addsuffix .frag.spv, $(basename $(wildcard shader_src/*.frag)))
|
2024-10-15 00:06:46 -06:00
|
|
|
COMP_SPV = $(addsuffix .comp.spv, $(basename $(wildcard shader_src/*.comp)))
|
|
|
|
SPV_FILES = $(VERT_SPV) $(FRAG_SPV) $(COMP_SPV)
|
2024-10-09 10:54:19 -06:00
|
|
|
|
2024-10-15 10:37:56 -06:00
|
|
|
EXTRA_DEBUG_REQUIREMENTS :=
|
|
|
|
UNAME_S := $(shell uname -s)
|
|
|
|
ifeq ($(UNAME_S),Linux)
|
2024-10-16 15:28:42 -06:00
|
|
|
GDB = gdb
|
2024-10-21 15:52:16 -06:00
|
|
|
CFLAGS += -I /usr/include/freetype2
|
2024-10-15 10:37:56 -06:00
|
|
|
endif
|
|
|
|
ifeq ($(UNAME_S),Darwin)
|
2024-10-16 15:29:20 -06:00
|
|
|
export MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS=1
|
2024-10-16 15:28:42 -06:00
|
|
|
DSYM = dsymutil
|
|
|
|
GDB = lldb
|
2024-10-15 10:37:56 -06:00
|
|
|
EXTRA_DEBUG_REQUIREMENTS = roleplay.dSYM
|
|
|
|
endif
|
|
|
|
|
2024-10-16 15:28:42 -06:00
|
|
|
CC ?= clang
|
|
|
|
CXX ?= clang++
|
|
|
|
|
2024-10-09 10:54:19 -06:00
|
|
|
|
|
|
|
.PHONY: all
|
2024-10-15 00:06:46 -06:00
|
|
|
all: roleplay $(SPV_FILES)
|
2024-10-09 10:54:19 -06:00
|
|
|
|
|
|
|
roleplay: $(OBJECTS)
|
2024-10-16 15:28:42 -06:00
|
|
|
$(CXX) $(CFLAGS) $(LDFLAGS) -o $@ $^
|
2024-10-09 10:54:19 -06:00
|
|
|
|
|
|
|
%.o: %.cpp
|
2024-10-21 15:52:16 -06:00
|
|
|
$(CXX) $(CFLAGS) -std=c++17 -Wno-nullability-completeness -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unused-private-field -Wno-unused-variable -c -o $@ $<
|
2024-10-09 10:54:19 -06:00
|
|
|
|
|
|
|
%.o: %.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
|
|
|
|
.PHONY: clean clean_compdb
|
|
|
|
|
|
|
|
clean:
|
2024-10-15 00:06:46 -06:00
|
|
|
rm -f $(SPV_FILES)
|
2024-10-09 10:54:19 -06:00
|
|
|
rm -f $(OBJECTS)
|
|
|
|
rm -f roleplay
|
2024-10-15 10:37:56 -06:00
|
|
|
rm -rf $(EXTRA_DEBUG_REQUIREMENTS)
|
2024-10-09 10:54:19 -06:00
|
|
|
|
|
|
|
clean_compdb:
|
|
|
|
rm -rf .compdb
|
|
|
|
rm compile_commands.json
|
|
|
|
|
2024-10-15 00:06:46 -06:00
|
|
|
run: roleplay $(SPV_FILES)
|
2024-10-09 10:54:19 -06:00
|
|
|
./roleplay
|
|
|
|
|
|
|
|
roleplay.dSYM: roleplay
|
|
|
|
$(DSYM) roleplay
|
|
|
|
|
2024-10-15 10:37:56 -06:00
|
|
|
debug: roleplay $(EXTRA_DEBUG_REQUIREMENTS) $(SPV_FILES)
|
2024-10-09 10:54:19 -06:00
|
|
|
$(GDB) roleplay
|
|
|
|
|
|
|
|
%.vert.spv: %.vert
|
2024-10-20 21:59:28 -06:00
|
|
|
glslc -o $@ $<
|
2024-10-09 10:54:19 -06:00
|
|
|
|
|
|
|
%.frag.spv: %.frag
|
2024-10-20 21:59:28 -06:00
|
|
|
glslc -o $@ $<
|
2024-10-15 00:06:46 -06:00
|
|
|
|
|
|
|
%.comp.spv: %.comp
|
2024-10-20 21:59:28 -06:00
|
|
|
glslc -o $@ $<
|