-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
54 lines (40 loc) · 1.51 KB
/
Makefile
File metadata and controls
54 lines (40 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
include .env
# specify compiler options
# -std=c++17: Use the C++17 standard.
# -O2: Optimize for speed without excessive compile time.
CFLAGS = -std=c++17 -O2 -I${TINYOBJLOADER_PATH} -Iinclude
# LDFLAGS: Specifies linker options.
# -lglfw: Links the GLFW library (for windowing and OpenGL/Vulkan integration).
# -lvulkan: Links the Vulkan API library.
# -ldl, -lpthread, etc. link additional required system libraries for threading, dynamic loading, and X11 support.
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
# Find all source files
SRCS := $(shell find src -name '*.cpp')
# Convert source paths to object file paths under build/
OBJS := $(SRCS:src/%.cpp=build/%.o)
# Find shader files
VERT_SHADERS := $(shell find shaders -type f -name "*.vert")
FRAG_SHADERS := $(shell find shaders -type f -name "*.frag")
SHADER_BINS := $(patsubst shaders/%.vert,shaders/compiled/%.vert.spv,$(VERT_SHADERS)) \
$(patsubst shaders/%.frag,shaders/compiled/%.frag.spv,$(FRAG_SHADERS))
TARGET = build/first_app.out
# Create build directory
$(shell mkdir -p build)
$(shell mkdir -p shaders/compiled)
# Create subdirectories for object files
$(shell mkdir -p $(sort $(dir $(OBJS))))
# Main target
$(TARGET): $(SHADER_BINS) $(OBJS)
g++ $(OBJS) -o $(TARGET) $(LDFLAGS)
# Compile source files
build/%.o: src/%.cpp
g++ $(CFLAGS) -c $< -o $@
# Compile shaders
shaders/compiled/%.spv: shaders/%
${GLSLC_PATH} $< -o $@
.PHONY: clean test
test: $(TARGET)
./$(TARGET)
clean:
rm -rf shaders/compiled/
rm -rf build/