-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
113 lines (83 loc) · 3.14 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
# Make file for the PUS Extension of the CORDET Framework
#
################################################################################
CC = gcc
#CC = clang
INCLUDES = -I./src -I./lib/cordetfw/src -I./tests -I./tests/PusConfig -I./lib/cordetfw/lib/fwprofile/src
# Compiler flags for test cases
CFLAGS_TE = -g2 -O0
# Compiler flags for C code libraries (fwprofile and cordetfw)
CFLAGS_LIB = -g2 -O0
# Compiler flags for PUS Extension code
CFLAGS = -W -Wall -Wextra -pedantic -g2 -O0 -fprofile-arcs -ftest-coverage -fno-exceptions
# Linker flags
LFLAGS =
# Libraries
LIBS = -pthread
HEADERS = $(shell find . -name *.h)
# Source files in FW Profile library
SRCS_FW = $(shell find ./lib/cordetfw/lib/fwprofile/src -name *.c)
# Source files in CORDET FW library
SRCS_CR = $(shell find ./lib/cordetfw/src -name *.c)
# Test Suite source files (excluding Mon Service test cases which are still under development)
# SRCS_TE = $(shell find ./tests -name *.c)
SRCS_TE = $(shell find ./tests f \( -iname '*.c' ! -iname 'CrPsMonTestCases*.c' \) )
# C source files of PUS Extension excluding those in dir Mon which is still under development
SRCS_TSC = $(shell find ./src -name *.c -not -path './src/Mon/*')
# gcov files
GCOV = $(patsubst %,$(ODIR)/%,$(SRCS_TSC:.c=.gcov))
# Object directory
ODIR = bin
# Object files
OBJS_FW = $(patsubst %,$(ODIR)/%,$(SRCS_FW:.c=.o))
OBJS_CR = $(patsubst %,$(ODIR)/%,$(SRCS_CR:.c=.o))
OBJS_TE = $(patsubst %,$(ODIR)/%,$(SRCS_TE:.c=.o))
OBJS_TSC = $(patsubst %,$(ODIR)/%,$(SRCS_TSC:.c=.o))
OBJS_DIR = $(dir $(OBJS_FW) $(OBJS_CR) $(OBJS_TE) $(OBJS_TSC))
# Executables
MAIN = $(ODIR)/CrPsTestSuite
.PHONY: clean test create_dir coverage run-test coverage-info coverage-cp info
# Print the name of a make variable (e.g. 'make print-SRCS_FW')
print-%: ; @echo $* is $($*)
all: test
info:
@echo $(shell echo $$0)
# Build the test suite
test: create_dir $(MAIN)
$(MAIN): $(OBJS_FW) $(OBJS_CR) $(OBJS_TSC) $(OBJS_TE)
$(CC) $(CFLAGS) $(INCLUDES) -o $(MAIN) $(OBJS_FW) $(OBJS_CR) $(OBJS_TSC) $(OBJS_TE) $(LFLAGS) $(LIBS)
$(OBJS_FW): $(ODIR)/%.o: %.c
$(CC) $(CFLAGS_LIB) $(INCLUDES) -c $< -o $@
$(OBJS_CR): $(ODIR)/%.o: %.c
$(CC) $(CFLAGS_LIB) $(INCLUDES) -c $< -o $@
$(OBJS_TSC): $(ODIR)/%.o: %.c
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
$(OBJS_TE): $(ODIR)/%.o: %.c
$(CC) $(CFLAGS_TE) $(INCLUDES) -c $< -o $@
$(GCOV): $(ODIR)/%.gcov: %.c
@gcov -b -r -o $(shell dirname $@) $<
$(OBJS_FW): $(HEADERS)
$(OBJS_CR): $(HEADERS)
$(OBJS_TSC): $(HEADERS)
$(OBJS_TE): $(HEADERS)
# Run the test suite
run-test:
$(MAIN)
run-test-valgrind:
valgrind --leak-check=yes $(MAIN)
# Generate the test coverage information
gen-lcov:
@lcov --capture --directory --rc lcov_branch_coverage=1 $(ODIR)/src -o coverage.info
@lcov --rc lcov_branch_coverage=1 --remove coverage.info '/usr/*' 'src/Dum/*' 'src/Lpt/*' 'src/Scd/*' -o filtered_coverage.info
@genhtml --branch-coverage filtered_coverage.info --output-directory lcov
gen-gcov: $(GCOV)
@mv *.gcov $(ODIR)
# Clean all generated files
clean:
@$(RM) filtered_coverage.info
@$(RM) coverage.info
@$(RM) *.gcov
@$(RM) -r lcov
@$(RM) -r $(ODIR)
create_dir:
@mkdir -p $(OBJS_DIR)