70 lines
1.8 KiB
Makefile
70 lines
1.8 KiB
Makefile
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
|
CFLAGS = -I $(ROOT_DIR)/include -I/usr/local/include -O0 -g -Wall -Wextra -fsanitize=address
|
|
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 lib/spng.c lib/vma.cpp
|
|
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)))
|
|
COMP_SPV = $(addsuffix .comp.spv, $(basename $(wildcard shader_src/*.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
|
|
|
|
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
|
|
|
|
roleplay.dSYM: roleplay
|
|
$(DSYM) roleplay
|
|
|
|
debug: roleplay $(EXTRA_DEBUG_REQUIREMENTS) $(SPV_FILES)
|
|
$(GDB) roleplay
|
|
|
|
%.vert.spv: %.vert
|
|
glslc --target-env=vulkan1.2 -o $@ $<
|
|
|
|
%.frag.spv: %.frag
|
|
glslc --target-env=vulkan1.2 -o $@ $<
|
|
|
|
%.comp.spv: %.comp
|
|
glslc --target-env=vulkan1.2 -o $@ $<
|