-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMakefile
78 lines (60 loc) · 1.91 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
CXX := g++
BUILD_TYPE := Release
TARGET := main
SRCDIR := src
BUILDDIR := obj
TARGETDIR := bin
OUTPUTDIR := output
# extensions
SRCEXT := cpp
DEPEXT := d
OBJEXT := o
# flags
CXXFLAGS := -MMD -MP -std=c++14 -fopenmp
CXX_DEBUG_FLAGS := -Wall -g -O0
CXX_RELEASE_FLAGS := -s -O2
LDFLAGS :=
INCLUDE := -I./include -I/usr/local/include/eigen3
LIBS := -lGL -lGLEW -lglfw3 -lX11 -lXxf86vm -lXrandr -lpthread -lXi -ldl -lXinerama -lXcursor
LIBS += -lopencv_core -lopencv_videoio -lopencv_highgui
#---------------------------------------------------------------------------------
# DO NOT EDIT BELOW THIS LINE
#---------------------------------------------------------------------------------
ifeq ($(BUILD_TYPE),Release)
CXXFLAGS += $(CXX_RELEASE_FLAGS)
else ifeq ($(BUILD_TYPE),Debug)
CXXFLAGS += $(CXX_DEBUG_FLAGS)
else
$(error buildtype must be release, debug, profile or coverage)
endif
sources := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT))
objects := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(subst $(SRCEXT),$(OBJEXT),$(sources)))
dependencies := $(subst .$(OBJEXT),.$(DEPEXT),$(objects))
# Defauilt Make
all: directories $(TARGETDIR)/$(TARGET)
run: all
$(TARGETDIR)/$(TARGET)
# Remake
remake: cleaner all
# make directory
directories:
@mkdir -p $(TARGETDIR)
@mkdir -p $(BUILDDIR)
@mkdir -p $(OUTPUTDIR)
# remove directory for intermediate products
clean:
@$(RM) -rf $(BUILDDIR)
# remove directories for both intermediate and final products
cleaner: clean
@$(RM) -rf $(TARGETDIR)
-include $(dependencies)
# generate binary by linking objects
$(TARGETDIR)/$(TARGET): $(objects)
$(CXX) $(CXXFLAGS) -o $(TARGETDIR)/$(TARGET) $^ $(LIBS)
# generate objects by compiling sources
# save dependencies of source as .d
$(BUILDDIR)/%.$(OBJEXT): $(SRCDIR)/%.$(SRCEXT)
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) $(INCLUDE) -o $@ -c $<
# Non-File Targets
.PHONY: all run remake clean cleaner