-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
56 lines (43 loc) · 1.48 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
52
53
54
55
56
# Header files
GLMDIR = libs/glm
HDIR := include $(GLMDIR)
# Source files
SRCDIR = src
SRCS = $(wildcard src/*.cpp)
# Dependencies
DEPDIR = dependencies
DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.d
# Object files
BUILDDIR = build
OBJS = $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%.o,$(basename $(SRCS)))
# Binary files
BINDIR = bin
BINARY_RAYTRACER = $(BINDIR)/raytracer
BINARY_RASTERISER = $(BINDIR)/rasteriser
# Compilation options
CXX = g++
CXXFLAGS = -std=c++11 -Wall -Ofast -march=native -fopenmp -ggdb -g3 -D unix -D GLM_FORCE_SSE2 -D GLM_FORCE_ALIGNED -D textureLess $(addprefix -I, $(HDIR)) $(shell sdl2-config --cflags) $(DEPFLAGS)
COMPILE = $(CXX) -o $@ -c $< $(CXXFLAGS)
# Link Options
LDFLAGS += $(shell sdl2-config --libs) -fopenmp
LDLIBS = `pkg-config --libs opencv`
LINK_RAYTRACER = $(CXX) -o $@ $(filter-out $(BUILDDIR)/rasteriser.o $(BUILDDIR)/rasteriser_screen.o, $^) $(LDFLAGS) $(LDLIBS)
LINK_RASTERISER = $(CXX) -o $@ $(filter-out $(BUILDDIR)/raytracer.o $(BUILDDIR)/raytracer_screen.o, $^) $(LDFLAGS) $(LDLIBS)
.PHONY: all clean
all: $(BUILDDIR) $(DEPDIR) $(BINDIR) $(BINARY_RAYTRACER) $(BINARY_RASTERISER)
clean:
@$(RM) $(BUILDDIR)/*.o $(DEPDIR)/*.d $(BINARY) screenshot.bmp
$(BUILDDIR) $(DEPDIR) $(BINDIR):
mkdir -p $@
# Compiling Objects
$(BUILDDIR)/%.o: $(SRCDIR)/%.cpp
$(info $@)
@$(COMPILE)
# Compiling Release Binary
$(BINARY_RAYTRACER): $(OBJS)
$(info $@)
@$(LINK_RAYTRACER)
$(BINARY_RASTERISER): $(OBJS)
$(info $@)
@$(LINK_RASTERISER)
include $(wildcard $(DEPDIR)/*.d)