-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy pathMakefile
53 lines (36 loc) · 1.55 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
CC=gcc
OBJS=pipe.c pipe_test.c pipe_util.c
NAME=pipe
VALGRIND_FLAGS= --leak-check=full --show-leak-kinds=all -s --track-origins=yes
CFLAGS=-Wall -Wextra -Wpointer-arith -fstrict-aliasing -std=c99 -D_FORTIFY_SOURCE=2 -pipe -pedantic #-Werror
D_CFLAGS=-DDEBUG -g -O0
R_CFLAGS=-DNDEBUG -O3 -funroll-loops #-pg #-flto
target = $(shell sh -c '$(CC) -v 2>&1 | grep "Target:"')
ifeq (,$(findstring mingw,$(target)))
CFLAGS += -pthread
endif
all: pipe_debug pipe_release thread_ring_debug thread_ring_release
pipe_debug: $(OBJS) main.c
$(CC) $(CFLAGS) $(D_CFLAGS) -o pipe_debug $(OBJS) main.c
pipe_release: $(OBJS) main.c
$(CC) $(CFLAGS) $(R_CFLAGS) -o pipe_release $(OBJS) main.c
thread_ring_debug: $(OBJS) thread_ring.c
$(CC) $(CFLAGS) $(D_FLAGS) -o thread_ring_debug $(OBJS) thread_ring.c
thread_ring_release: $(OBJS) thread_ring.c
$(CC) $(CFLAGS) $(R_FLAGS) -o thread_ring_release $(OBJS) thread_ring.c
pipe.h:
main.c: pipe.h
pipe.c: pipe.h
pipe_test.c: pipe.h pipe_util.h
pipe_util.c: pipe.h pipe_util.h
.PHONY : clean analyze
analyze: $(OBJS) pipe_debug pipe_release
clang --analyze $(CFLAGS) $(OBJS)
valgrind $(VALGRIND_FLAGS) ./pipe_debug
valgrind $(VALGRIND_FLAGS) ./pipe_release
# do not know equivilant flags for these, attempting to specify generates unknown option
valgrind --tool=callgrind --dump-instr=yes --trace-jump=yes ./pipe_release
valgrind --tool=cachegrind ./pipe_release
valgrind --tool=massif ./pipe_release
clean:
rm -f *.plist pipe_debug pipe_release thread_ring_debug thread_ring_release callgrind.out* cachegrind.out* massif.out*