-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
62 lines (45 loc) · 1.21 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
# I am not very good at Makefiles.
INCLUDES += -I.
ifeq (,$(wildcard ../cutest))
CUTEST=.
else
CUTEST = ../cutest
INCLUDES += -I../cutest
endif
CFLAGS += -g -O3 -Wall -Wextra -Wstrict-aliasing=2 -Wno-unused-function
CPPFLAGS += -O3 -Wall
ifeq "$(CC)" "clang"
CFLAGS += -Weverything
# stop clang warning us about strncmp:
CFLAGS += -Wno-disabled-macro-expansion
endif
ifdef DLMALLOC
LIBS += ${DLMALLOC}/lib/libmalloc.a
endif
all: benchmarks test
bin obj:
mkdir -p $@
benchmarks: bin/benchmark bin/naive bin/james
@bin/benchmark 100 1
@bin/naive 100 1
@bin/james 100 1
test: bin/tests
@bin/tests
obj/%.c.o: %.c | obj
$(CC) -o $@ -c $^ $(CFLAGS) $(INCLUDES)
obj/%.cpp.o: %.cpp | obj
$(CXX) -o $@ -c $^ $(CPPFLAGS) $(INCLUDES)
bin/benchmark: obj/benchmark.c.o obj/critbit.c.o obj/strtolh.c.o | bin
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
bin/naive: obj/naive.c.o obj/strtolh.c.o | bin
$(CC) $(CFLAGS) $(INCLUDES) -o $@ $^ $(LIBS)
bin/james: obj/james.cpp.o obj/strtolh.c.o | bin
$(CXX) -o $@ $^ $(LIBS)
bin/tests: critbit_tests.c \
test_critbit.c critbit.c \
$(CUTEST)/CuTest.c | bin
$(CC) $(CFLAGS) $(INCLUDES) -lm -o $@ $^ $(LIBS)
clean:
@rm -rf *~ bin obj
valgrind: bin/tests
@valgrind --leak-check=full bin/tests