forked from eldipa/loki
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
76 lines (59 loc) · 1.72 KB
/
Makefile
File metadata and controls
76 lines (59 loc) · 1.72 KB
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
# Turn on/off debug mode (off by default).
#
# Debug mode disables compiler optimizations and
# adds debugging metadata.
DEBUG =
# Turn on/off the debug locks (off by default).
#
# If enabled, the lock free structures will use a traditional
# lock (a mutex). This makes easier to debug problems when the
# issue is in a atomic operation or memory reorder.
LOCK =
# Turn on/off the trace mode (off by default).
#
# If enabled, a global and shared ring buffer is created and
# different part of the system will log to it atomically (but
# see the limitations in the code).
# Use this for debugging and introspection.
TRACE =
# Turn on/off the sanitization mode. (off by default).
# This modes relays in the compiler's
# ability to instrument the code to detect race conditions in runtime.
# It makes the program between 5 and 15 times slower (and consumes around
# 15 times more memory)
# Makes sense to use this only for testing and with DEBUG turned off.
SANITIZE =
CC = gcc
CFLAGS = -std=gnu11 -march=core2
LDFLAGS =
LDLIBS = -lpthread
INCLUDES = -I.
CONFFLAGS = -DLOKI_CPU_RELAX_INSTR_PAUSE
CFLAGS += $(CONFFLAGS)
ifeq (1,$(DEBUG))
CFLAGS += -O0 -ggdb -DDEBUG
else
CFLAGS += -O2
endif
ifeq (1,$(LOCK))
CFLAGS += -DLOKI_ENABLE_DEBUG_LOCK
endif
ifeq (1,$(TRACE))
CFLAGS += -DLOKI_ENABLE_TRACE
endif
ifeq (1,$(SANITIZE))
CFLAGS += -fsanitize=thread
LDFLAGS += -fsanitize=thread
endif
HDRS = $(wildcard loki/*.h)
SRCS = $(wildcard loki/*.c)
OBJS = $(SRCS:.c=.o)
TESTSRCS = $(wildcard tests/*.c)
TESTS = $(TESTSRCS:.c=.test)
all: $(OBJS) $(TESTS)
%.o: %.c $(HDRS)
$(CC) $(INCLUDES) $(CFLAGS) -o $@ -c $<
%.test: %.c $(OBJS) $(HDRS)
$(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ $< $(OBJS) $(LDLIBS)
clean:
rm -f test/queue-test loki/*.o