forked from lucas-louis/workflow-training
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
87 lines (69 loc) · 1.36 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
##
## PERSONAL PROJECT, 2020
## DO OP
## File description: Makefile
##
## Var def ##
SHELL = /bin/sh
CC = gcc
RM = rm -f
##############
## Sources ##
MAIN = main.c
# Enable CLION job
SRC = **/*.c
BIN_SRC = src/do-op.c \
src/error_handling.c \
TEST_SRC = tests/do-op.tests.c \
tests/error_handling.tests.c
INC = -I./include/
#############
## Obj ##
MAIN_OBJ = $(MAIN:.c=.o)
SRC_OBJ = $(BIN_SRC:.c=.o)
TEST_OBJ = $(TEST_SRC:.c=.o)
#############
## Flags ##
CFLAGS = -Wall -Wextra
CPPFLAGS = $(INC)
LDFLAGS =
#############
## Names ##
BIN = do-op
TEST_BIN = unit_tests
#############
## Rules ##
.PHONY: all
all: $(BIN)
$(BIN): $(MAIN_OBJ) $(SRC_OBJ)
$(CC) -o $(BIN) $(MAIN_OBJ) $(SRC_OBJ)
## Debug
.PHONY: debug
debug: fclean
debug: CFLAGS += -g3 -DDEBUG
debug: $(BIN)
## Run test
.PHONY: tests_run
tests_run: CFLAGS += --coverage
tests_run: LDFLAGS += -lcriterion -DUNIT_TEST
tests_run: $(SRC_OBJ) $(TEST_OBJ)
$(CC) -o $(TEST_BIN) $(SRC_OBJ) $(TEST_OBJ) $(LDFLAGS) $(CFLAGS) $(CPPFLAGS)
./$(TEST_BIN)
## Get coverage
.PHONY: coverage
coverage:
gcovr -b --exclude-directories tests
gcovr -r . --exclude-directories tests
## Clear rules
.PHONY: clean
clean:
@$(RM) $(MAIN_OBJ)
@$(RM) $(SRC_OBJ)
@$(RM) $(TEST_OBJ)
.PHONY: fclean
fclean: clean
@$(RM) $(BIN)
@$(RM) $(TEST_BIN)
@$(RM) **/*.gc*
.PHONY: re
re: fclean all clean