-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
51 lines (42 loc) · 1.03 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
39
40
41
42
43
44
45
46
47
48
49
50
51
# https://en.wikipedia.org/wiki/Makefile
SRCDIR := .
OBJDIR := ./out
EXECUTABLE := renderer
SRCFILES := $(shell find $(SRCDIR) -name "*.cpp")
SRCNAMES := $(notdir $(SRCFILES))
OBJFILES := $(SRCNAMES:%.cpp=$(OBJDIR)/%.o)
LDFLAGS := -lX11 -lXi -lSDL2
space :=
VPATH := $(subst $(space),:,$(shell find . -type d))
GCCFLAGS := -std=c++17
# select shader
ifeq ($(shader), gouraud)
GCCFLAGS += -DGOURAUD_SHADER
else ifeq ($(shader), phong)
GCCFLAGS += -DPHONG_SHADER
else
GCCFLAGS += -DPHONG_SHADER
endif
# select reflection model
ifeq ($(reflection), phong)
GCCFLAGS += -DPHONG_REFLECTION
else ifeq ($(reflection), blinn)
GCCFLAGS += -DBLINN_REFLECTION
else
GCCFLAGS += -DPHONG_REFLECTION
endif
# select release or debug
ifeq ($(config), debug)
GCCFLAGS += -g -pg
else
GCCFLAGS += -O2
endif
.PHONY: all
all: out/$(EXECUTABLE)
out/$(EXECUTABLE): $(OBJFILES)
g++ $(GCCFLAGS) $(OBJFILES) -o $@ $(LDFLAGS)
$(OBJDIR)/%.o: %.cpp
g++ $(GCCFLAGS) -c $< -o $@
.PHONY: clean
clean:
@rm -f out/* && echo "[CL] out/"