-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
38 lines (26 loc) · 1.01 KB
/
Makefile
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
TARGET := app
GLSLC := glslc
SOURCES := $(wildcard src/*.c) $(wildcard src/vk/*.c) $(wildcard src/link/*.c) $(wildcard src/link/*.cpp)
SHADER_SOURCES := $(wildcard shader/*.vert) $(wildcard shader/*.frag)
LIBS := -lvulkan -lglfw -lm
OBJECTS := $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCES)))
DEPENDS := $(patsubst %.c,%.d,$(patsubst %.cpp,%.d,$(SOURCES)))
SHADER_OBJECTS := $(patsubst %.vert,%.spv,$(patsubst %.frag,%.spv,$(SHADER_SOURCES)))
CFLAGS = -O2 -std=c2x -Wall -Wextra -Wpedantic -Wconversion -Wno-override-init -Wno-pointer-arith -Werror -Wfatal-errors -Isrc -Ilib
CXXFLAGS = -O2 -Isrc -Ilib
.PHONY: build run clean
build: $(OBJECTS) $(SHADER_OBJECTS)
$(CXX) $(CFLAGS) -o $(TARGET).elf $(OBJECTS) $(LIBS)
run: build
@./$(TARGET).elf
clean:
$(RM) $(OBJECTS) $(DEPENDS) $(SHADER_OBJECTS)
-include $(DEPENDS)
%.o: %.c Makefile
$(CC) $(CFLAGS) -MMD -MP -c $< -o $@
%.o: %.cpp Makefile
$(CXX) $(CXXFLAGS) -MMD -MP -c $< -o $@
%.spv: %.vert Makefile
$(GLSLC) $< -o $@
%.spv: %.frag Makefile
$(GLSLC) $< -o $@