-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
104 lines (85 loc) · 2.65 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
.SUFFIXES: .cpp .hpp .h
# Programs
SHELL = bash
CC = g++
LD = ld
RM = rm
ECHO = /bin/echo
CAT = cat
PRINTF = printf
SED = sed
DOXYGEN = doxygen
######################################
# Project Name (generate executable with this name)
TARGET = drishti
# Project Paths
PROJECT_ROOT:=.
SRCDIR := $(PROJECT_ROOT)/src
INCDIR := $(PROJECT_ROOT)/include/
DOCDIR := $(PROJECT_ROOT)/doc
# EXTDIR := $(PROJECT_ROOT)/ext
# OPENGLLIB= -lGL
# GLEWLIB= -lGLEW
# GLFWLIB = -lglfw
EIGEN_INCLUDE=/usr/include/eigen3
# TINYXML2_INCLUDE=$(EXTDIR)/tinyxml2
# FILESYSTEM_INCLUDE=$(EXTDIR)/filesystem
# EXTMODULES=$(EXTDIR)/tinyxml2
MPLIB_INCLUDE=/usr/include/python2.7
# Compiler and Linker flags
LDFLAGS=-L/usr/local/lib -fopenmp
# CPPFLAGS=-I$(MPLIB_INCLUDE) -I$(EIGEN_INCLUDE) -I$(INCDIR)
CPPFLAGS=-I$(INCDIR)
CPPFLAGS+=-g -fopenmp -O3 -Wall -std=c++11
######################################
NO_COLOR=\e[0m
OK_COLOR=\e[1;32m
ERR_COLOR=\e[1;31m
WARN_COLOR=\e[1;33m
MESG_COLOR=\e[1;34m
FILE_COLOR=\e[1;37m
OK_STRING="[OK]"
ERR_STRING="[ERRORS]"
WARN_STRING="[WARNINGS]"
OK_FMT="${OK_COLOR}%30s\n${NO_COLOR}"
ERR_FMT="${ERR_COLOR}%30s\n${NO_COLOR}"
WARN_FMT="${WARN_COLOR}%30s\n${NO_COLOR}"
######################################
SRCS:=$(wildcard $(SRCDIR)/*.cpp)
# include $(patsubst %,%/makefile.mk,$(EXTMODULES))
OBJS:=$(patsubst %.cpp,%.o,$(filter %.cpp,$(SRCS)))
DEPS:=$(patsubst %.cpp,%.d,$(filter %.cpp,$(SRCS)))
.PHONY: all doc clean distclean
all: $(TARGET)
$(TARGET): $(OBJS)
@$(PRINTF) "$(MESG_COLOR)Building executable:$(NO_COLOR) $(FILE_COLOR) %16s$(NO_COLOR)" "$(notdir $@)"
@$(CC) -o $@ $(LDFLAGS) $(OBJS) $(LIBS) 2> temp.log || touch temp.err
@if test -e temp.err; \
then $(PRINTF) $(ERR_FMT) $(ERR_STRING) && $(CAT) temp.log; \
elif test -s temp.log; \
then $(PRINTF) $(WARN_FMT) $(WARN_STRING) && $(CAT) temp.log; \
else $(PRINTF) $(OK_FMT) $(OK_STRING); \
fi;
@$(RM) -f temp.log temp.err
-include -include $(OBJS:.o=.d)
$(OBJS): %.o : %.cpp
@$(PRINTF) "$(MESG_COLOR)Compiling: $(NO_COLOR) $(FILE_COLOR) %25s$(NO_COLOR)" "$(notdir $<)"
@$(CC) $(CPPFLAGS) $(CPPFLAGS+) -c $< -o $@ -MD 2> temp.log || touch temp.err
@if test -e temp.err; \
then $(PRINTF) $(ERR_FMT) $(ERR_STRING) && $(CAT) temp.log; \
elif test -s temp.log; \
then $(PRINTF) $(WARN_FMT) $(WARN_STRING) && $(CAT) temp.log; \
else printf "${OK_COLOR}%30s\n${NO_COLOR}" "[OK]"; \
fi;
@$(RM) -f temp.log temp.err
doc:
@$(ECHO) -n "Generating Doxygen Documentation ... "
@$(RM) -rf doc/html
@$(DOXYGEN) $(DOCDIR)/Doxyfile 2 > /dev/null
@$(ECHO) "Done"
clean:
@$(ECHO) -n "Cleaning up..."
@$(RM) -rf *~ $(OBJS) $(DEPS) $(SRCDIR)/*~
@$(ECHO) "Done"
distclean: clean
@$(RM) -rf $(TARGET) $(DOCDIR)/html