@@ -1,37 +1,41 @@
|
|
1 |
# target: prerequisites
|
2 |
# command to build target
|
3 |
|
4 |
-
|
5 |
-
|
|
|
|
|
|
|
|
|
6 |
|
7 |
.PHONY: lint
|
8 |
lint:
|
9 |
-
cpplint
|
10 |
|
11 |
.PHONY: memcheck
|
12 |
-
memcheck:
|
13 |
-
valgrind --tool=memcheck --leak-check=full
|
14 |
|
15 |
.PHONY: helgrind
|
16 |
-
helgrind:
|
17 |
-
valgrind --tool=helgrind
|
18 |
|
19 |
.PHONY: asan # invalid access & memory leaks
|
20 |
-
asan:
|
21 |
-
cc
|
22 |
|
23 |
.PHONY: msan # uninitialized memory
|
24 |
-
msan:
|
25 |
-
clang
|
26 |
|
27 |
.PHONY: tsan # thread sanitizer
|
28 |
-
tsan:
|
29 |
-
cc
|
30 |
|
31 |
.PHONY: ubsan # undefined behavior
|
32 |
-
ubsan:
|
33 |
-
cc
|
34 |
|
35 |
.PHONY: clean
|
36 |
clean:
|
37 |
-
rm -f
|
1 |
# target: prerequisites
|
2 |
# command to build target
|
3 |
|
4 |
+
APPNAME=$(shell basename $(shell pwd))
|
5 |
+
APPARGS=10
|
6 |
+
CFLAGS=-g -Wall -Wextra
|
7 |
+
|
8 |
+
$(APPNAME): $(APPNAME).c
|
9 |
+
cc $(CFLAGS) $< -o $@ -pthread
|
10 |
|
11 |
.PHONY: lint
|
12 |
lint:
|
13 |
+
cpplint --filter=-readability/casting $(APPNAME).c
|
14 |
|
15 |
.PHONY: memcheck
|
16 |
+
memcheck: $(APPNAME)
|
17 |
+
valgrind --tool=memcheck --leak-check=full ./$(APPNAME) $(APPARGS)
|
18 |
|
19 |
.PHONY: helgrind
|
20 |
+
helgrind: $(APPNAME)
|
21 |
+
valgrind --tool=helgrind ./$(APPNAME) $(APPARGS)
|
22 |
|
23 |
.PHONY: asan # invalid access & memory leaks
|
24 |
+
asan: $(APPNAME).c
|
25 |
+
cc $(CFLAGS) -fsanitize=address $(APPNAME).c -o $(APPNAME) -pthread
|
26 |
|
27 |
.PHONY: msan # uninitialized memory
|
28 |
+
msan: $(APPNAME).c
|
29 |
+
clang $(CFLAGS) -fsanitize=memory $(APPNAME).c -o $(APPNAME) -pthread
|
30 |
|
31 |
.PHONY: tsan # thread sanitizer
|
32 |
+
tsan: $(APPNAME).c
|
33 |
+
cc $(CFLAGS) -fsanitize=thread $(APPNAME).c -o $(APPNAME) -pthread
|
34 |
|
35 |
.PHONY: ubsan # undefined behavior
|
36 |
+
ubsan: $(APPNAME).c
|
37 |
+
cc $(CFLAGS) -fsanitize=undefined $(APPNAME).c -o $(APPNAME) -pthread
|
38 |
|
39 |
.PHONY: clean
|
40 |
clean:
|
41 |
+
rm -f $(APPNAME)
|