-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
65 lines (47 loc) · 1.62 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
# make - to compile normal run
# make test - to compile for unit testing
#use this if googletest locally installed
ifdef LOCAL
GTEST_DIR=~/googletest/googletest
GTEST_INCLUDE=-I $(GTEST_DIR)/include
GTEST_LIB=libgtest.a
else
GTEST_DIR=
GTEST_INCLUDE=
GTEST_LIB=-lgtest
endif
COPTS=-Wall -fpermissive
COPTS_COV=$(COPTS) -fprofile-arcs -ftest-coverage
LDFLAGS=-fprofile-arcs -ftest-coverage
COV_OUTPUT=./cov_output
PROJ=ringbuffer
######### Main targets ##########
main: main.o $(PROJ).o
gcc main.o $(PROJ).o -o main $(LDFLAGS)
test: Gtest_main.o testcase.o $(PROJ)_test.o $(GTEST_LIB) libgtest.a
g++ $(LDFLAGS) -pthread $(PROJ)_test.o testcase.o Gtest_main.o $(GTEST_LIB) -o test
########## Normal ###########
$(PROJ).o: $(PROJ).c
gcc -c $(COPTS_COV) $(PROJ).c
main.o: main.c include.h
gcc -c $(COPTS) main.c
########## Unit test ########
Gtest_main.o: Gtest_main.c
g++ -c Gtest_main.c $(GTEST_INCLUDE)
$(PROJ)_test.o: $(PROJ).c
g++ -c $(PROJ).c -o $(PROJ)_test.o
testcase.o: testcase.c
g++ -c $(COPTS) testcase.c $(GTEST_INCLUDE)
########## Google Test framework ############
libgtest.a:
g++ -isystem $(GTEST_DIR)/include -I $(GTEST_DIR) -pthread -c $(GTEST_DIR)/src/gtest-all.cc
ar -rv libgtest.a gtest-all.o
########### Coverage analysis ############
report:
lcov -rc lcov_branch_coverage=1 -c -i -d . -o .coverage.base
lcov -rc lcov_branch_coverage=1 -c -d . -o .coverage.run
lcov -rc lcov_branch_coverage=1 -d . -a .coverage.base -a .coverage.run -o .coverage.total
genhtml --branch-coverage -o $(COV_OUTPUT) .coverage.total
rm -f .coverage.base .coverage.run .coverage.total
clean:
rm -f *.o test $(GTEST_LIB)