-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
85 lines (59 loc) · 1.27 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
.POSIX:
.SUFFIXES:
CC := gcc
CFLAGS += -std=c99
CFLAGS += -fno-builtin
CFLAGS += -fno-tree-loop-distribute-patterns
CFLAGS += -pipe
CFLAGS += -U_FORTIFY_SOURCE -Wno-format-security
CFLAGS += -O2 -march=native -mtune=native
CFLAGS += -Wall -Wextra -pedantic
CFLAGS += -Winit-self -Wredundant-decls
CFLAGS += -Winline -Wundef -Wshadow
CFLAGS += -Wstrict-overflow=2
CFLAGS += -Wunreachable-code
CFLAGS += -Wwrite-strings
CFLAGS += -iquote .
include sources.mk
vpath %.c $(VPATH)
BUILD_DIR := .build
LIB := libmy.a
UNIT := unit_tests
OBJ := $(SRC:%.c=$(BUILD_DIR)/%.o)
TOBJ := $(TSRC:%.c=$(BUILD_DIR)/%.o)
TFLAGS += -L .
TFLAGS += -lmy -lcriterion
RM ?= rm -f
AM ?= ar
all: $(LIB)
.PHONY: all
$(LIB): $(OBJ)
$(AR) rc $@ $^
$(BUILD_DIR)/%.o: %.c
@ mkdir -p $(dir $@)
$(CC) $(CFLAGS) -o $@ -c $<
clean:
$(RM) $(SRC:.c=.gcda)
$(RM) $(SRC:.c=.gcno)
$(RM) $(OBJ) $(TOBJ)
fclean: clean
$(RM) $(LIB)
$(RM) -r $(BUILD_DIR)
.PHONY: clean fclean
re: fclean
$(MAKE) all
.PHONY: re
NO_COV ?= 0
ifeq ($(NO_COV),0)
$(UNIT): CFLAGS += -g3 --coverage -fprofile-arcs
endif
$(UNIT): $(LIB) $(TOBJ)
$(CC) -g3 $(CFLAGS) -o $@ $(TOBJ) $(TFLAGS)
tests_run: $(UNIT)
./$^
.PHONY: tests_run
cov: fclean
$(MAKE) tests_run
gcovr --exclude tests
gcovr --exclude tests --branch
.PHONY: cov