-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
130 lines (112 loc) · 3.35 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
CC := gcc
LD := $(CC)
CXX := g++
LDXX := $(CXX)
OPTFLAGS := -g -pg -fopenmp
CFLAGS += -Wall -Wextra -Wpedantic -std=gnu11 $(OPTFLAGS)
CXXFLAGS += -Wall -Wextra -Wpedantic -std=c++11 $(OPTFLAGS)
LDFLAGS += -ltiff -lfftw3_omp -lfftw3 -lm
LINT:=cpplint --extensions=c,h,cpp
VALGRIND:=valgrind --leak-check=full --show-leak-kinds=all
BINDIR:=$(CURDIR)/bin
BUILDDIR:=$(CURDIR)/build
RELEASEDIR:=$(CURDIR)/release
TESTSDIR:=$(CURDIR)/tests
DOCDIR:=$(CURDIR)/doc
LOGDIR:=$(BUILDDIR)/logs
OUT:=$(BUILDDIR)/release
OUTTESTS:=$(BUILDDIR)/tests
SRC:=$(wildcard $(RELEASEDIR)/src/*.c)
INCLUDE:=$(wildcard $(RELEASEDIR)/include/*.h)
OBJS:=$(patsubst $(RELEASEDIR)/src/%.c,$(OUT)/%.o,$(SRC))
RELEASESRC:=$(filter-out $(RELEASEDIR)/src/main.c, $(wildcard $(RELEASEDIR)/src/*.c))
TESTSSRC:=$(wildcard $(TESTSDIR)/src/*.cpp)
RELEASEOBJS:=$(patsubst $(RELEASEDIR)/src/%.c,$(OUTTESTS)/%_xx.o,$(RELEASESRC))
TESTSOBJS:=$(patsubst $(TESTSDIR)/src/%.cpp,$(OUTTESTS)/%.o,$(TESTSSRC))
IFLAGS:=-I$(RELEASEDIR)
EXECNAME:=fourierscope
TESTSNAME:=runtests
.SILENT:
release: $(OBJS)
mkdir -p $(BINDIR)
printf "\033[0;32m"
printf "Creating $(EXECNAME) binary file in: $(BINDIR)\n"
printf "\033[0m"
$(LD) $(CFLAGS) -o $(BINDIR)/$(EXECNAME) $(OBJS) $(LDFLAGS)
debug: CXXFLAGS += -D DEBUG
debug: tests
tests: LDFLAGS += -lgtest
tests: $(TESTSOBJS) $(RELEASEOBJS)
mkdir -p $(BINDIR)
printf "\033[0;32m"
printf "Creating $(TESTSNAME) binary file in: $(BINDIR)\n"
printf "\033[0m"
$(LDXX) $(CXXFLAGS) -o $(BINDIR)/${TESTSNAME} $(RELEASEOBJS) $(TESTSOBJS) $(LDFLAGS)
$(OUTTESTS)/%.o: $(TESTSDIR)/src/%.cpp
mkdir -p $(OUTTESTS)
printf "\033[0;35m"
printf "Creating object file $(@F)\n"
printf "\033[0m"
$(CXX) $(IFLAGS) $(CXXFLAGS) -c $< -o $@
$(OUTTESTS)/%_xx.o: $(RELEASEDIR)/src/%.c
mkdir -p $(OUTTESTS)
printf "\033[0;35m"
printf "Creating object file $(@F)\n"
printf "\033[0m"
$(CXX) $(IFLAGS) $(CXXFLAGS) -c $< -o $@
$(OUT)/%.o: $(RELEASEDIR)/src/%.c
mkdir -p $(OUT)
printf "\033[0;35m"
printf "Creating object file $(@F)\n"
printf "\033[0m"
$(CC) $(IFLAGS) $(CFLAGS) -c $< -o $@
doc:
mkdir -p $(LOGDIR)
printf "\033[0;34m"
printf "Generating doc/images tikz images\n"
make LOGDIR=$(LOGDIR) -C $(DOCDIR)/images
printf "Generating Documentation\n"
doxygen $(DOCDIR)/config/doxygen.cfg
cat $(LOGDIR)/docwarnings
printf "\033[0m"
-ln -s $(DOCDIR)/html/index.html 2> /dev/null
.PHONY: doc
lint:
printf "\033[0;36m"
printf "Lint in progress\n"
$(LINT) $(SRC) | true
$(LINT) --root=$(CURDIR) $(INCLUDE) | true
$(LINT) $(TESTSSRC) | true
printf "\033[0m"
.PHONY: lint
valgrind:
mkdir -p $(LOGDIR)
printf "\033[0;36m"
printf "Valgrind in progress\n"
printf "\033[0m"
-$(VALGRIND) $(BINDIR)/$(EXECNAME) 2> $(LOGDIR)/$(EXECNAME)_valgrind
-$(VALGRIND) $(BINDIR)/$(TESTSNAME) 2> $(LOGDIR)/$(TESTSNAME)_valgrind
printf "\033[0;36m"
printf "Valgrind finished\n"
printf "\033[0m"
.PHONY: valgrind
clean:
printf "\033[0;33m"
printf "Cleaning build directory\n"
printf "\033[0m"
-rm -r $(BUILDDIR) 2> /dev/null
.PHONY: clean
mrproper: clean
printf "\033[0;33m"
printf "Cleaning binary directory\n"
printf "\033[0m"
-rm -r $(BINDIR) 2> /dev/null
printf "\033[0;33m"
printf "Cleaning doc/images directory\n"
make LOGDIR=$(LOGDIR) -C $(DOCDIR)/images $@
printf "Cleaning doc directory\n"
printf "\033[0m"
-rm -r $(DOCDIR)/{html,latex} 2> /dev/null
-rm gmon.out
-unlink index.html
.PHONY: mrproper