-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
47 lines (34 loc) · 1.21 KB
/
Copy pathMakefile
File metadata and controls
47 lines (34 loc) · 1.21 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
CC ?= cc
OPT ?= -O2 -g
CFLAGS += $(OPT) -std=c11 -D_POSIX_C_SOURCE=200809L -Wall -Wextra -Wpedantic -Werror -Iinclude
LDLIBS += -pthread
BUILD ?= build
SRCS := $(wildcard src/*.c)
OBJS := $(SRCS:src/%.c=$(BUILD)/obj/%.o)
LIB := $(BUILD)/libck.a
TESTS := $(BUILD)/test_queues $(BUILD)/test_sync
BENCH := $(BUILD)/bench
.PHONY: all test bench asan tsan clean
all: $(LIB) $(TESTS) $(BENCH)
$(BUILD)/obj/%.o: src/%.c $(wildcard include/ck/*.h) | $(BUILD)/obj
$(CC) $(CFLAGS) -c $< -o $@
$(LIB): $(OBJS)
$(AR) rcs $@ $^
$(BUILD)/test_%: tests/test_%.c tests/test.h $(LIB)
$(CC) $(CFLAGS) $< $(LIB) -o $@ $(LDFLAGS) $(LDLIBS)
$(BENCH): bench/bench.c $(LIB)
$(CC) $(CFLAGS) $< $(LIB) -o $@ $(LDFLAGS) $(LDLIBS)
$(BUILD)/obj:
mkdir -p $@
test: $(TESTS)
@for t in $(TESTS); do echo "== $$t"; ./$$t || exit 1; done
bench: $(BENCH)
./$(BENCH)
# Sanitizer builds go to their own directories so they never mix objects.
asan:
$(MAKE) test BUILD=build-asan OPT="-O1 -g -fsanitize=address,undefined -fno-omit-frame-pointer" \
LDFLAGS="-fsanitize=address,undefined"
tsan:
$(MAKE) test BUILD=build-tsan OPT="-O1 -g -fsanitize=thread" LDFLAGS="-fsanitize=thread"
clean:
rm -rf build build-asan build-tsan