summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile59
1 files changed, 59 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..96e7b3a
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,59 @@
+include .env
+
+CC = clang++
+
+INCFLAGS = -Isrc
+INCFLAGS += -Iengine
+INCFLAGS += -Ilib/glfw/include
+INCFLAGS += -Ilib/glm
+INCFLAGS += -L${VULKAN_SDK}/lib -lvulkan
+
+CCFLAGS = -std=c++17 -O2 -g
+CCFLAGS += $(INCFLAGS)
+
+LDFLAGS = -lm
+LDFLAGS += $(INCFLAGS)
+LDFLAGS += lib/glfw/src/libglfw3.a
+LDFLAGS += lib/glm/glm/libglm_static.a
+
+SRC = $(shell find src -name "*.cpp")
+SRC += $(shell find engine -name "*.cpp")
+OBJ = $(SRC:.cpp=.o)
+BIN = bin
+
+VERTSRC = $(shell find ./res/shaders -type f -name "*.vert")
+VERTOBJ = $(patsubst %.vert, %.vert.spv, $(VERTSRC))
+FRAGSRC = $(shell find ./res/shaders -type f -name "*.frag")
+FRAGOBJ = $(patsubst %.frag, %.frag.spv, $(FRAGSRC))
+
+.PHONY: all clean
+
+all: dirs libs shader build
+
+libs:
+ cd lib/glfw && cmake . && make
+ cd lib/glm && cmake . && make
+
+dirs:
+ mkdir -p ./$(BIN)
+
+
+shader: $(VERTOBJ) $(FRAGOBJ)
+
+run: build
+ $(RUN) $(BIN)/game
+
+build: dirs shader ${OBJ}
+ ${CC} -o $(BIN)/game $(filter %.o,$^) $(LDFLAGS)
+
+%.spv: %
+ glslc -o $@ $<
+
+%.o: %.cpp
+ $(CC) -o $@ -c $< $(CCFLAGS)
+
+clean:
+ rm -rf app
+ rm -rf $(BIN) $(OBJ)
+ rm -rf res/shaders/*.spv
+ rm -rf lib/glfw/CMakeCache.txt \ No newline at end of file