-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile.ubuntu
107 lines (80 loc) · 2.6 KB
/
Makefile.ubuntu
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
default: build
CC = gcc
CPP = g++
LINK = $(CPP)
RM = /bin/rm -f
# sanitize only works on 64-bit host
uname_m := $(shell uname -m)
SANITIZE.x86_64 := -fsanitize=address
SANITIZE += $(SANITIZE.$(uname_m))
CTIME := $(shell date +%s)
# add -flto=auto flag on non-arm platforms
ifneq ($(findstring arm,$(uname_m)),arm)
LINKOPT += -flto=auto
endif
#DEBUG_FLAGS = -g3 -rdynamic -ggdb -D_DEBUG -D_TEST -D_GLIBCXX_DEBUG -O0 $(SANITIZE) -fno-omit-frame-pointer
PROD_FLAGS = -O3 -march=native -ffast-math
#LEAK_FLAGS = -D_LEAK_DETECTION
#PROF_FLAGS = -pg -D_GLIBCXX_DEBUG
CFLAGS = -I include -std=c++11 -DCOMPILE_TIME=$(CTIME) -Wno-unused-result -Wno-format-truncation -Wno-psabi -Wno-deprecated-declarations $(LINKOPT) $(DEBUG_FLAGS) $(PROF_FLAGS) $(LEAK_FLAGS) $(PROD_FLAGS)
LFLAGS = -pthread $(LINKOPT) $(DEBUG_FLAGS) $(PROF_FLAGS)
LIBS = $(DEBUG_LIBS) -lz
INCS = $(wildcard include/*.h)
TINCS = $(wildcard test/include/*.h)
SRCS = $(wildcard src/*.cpp src/*/*.cpp)
TMPS = $(subst src,objs,$(SRCS))
OBJS = $(patsubst %.cpp,%.o,$(TMPS))
OBJI = $(filter-out objs/main.o,$(OBJS))
OBJJ = $(filter-out objs/stress_test.o,$(OBJI))
OBJL = $(filter-out objs/admin.o,$(OBJJ))
SRCT = $(wildcard test/*.cpp)
TMPT = $(subst test,objs,$(SRCT))
OBJT = $(patsubst %.cpp,%.o,$(TMPT))
TARGET = bin/tt
TESTS = bin/all_tests
TOOLS = bin/inspect
build: $(TARGET)
package: bin/tt bin/inspect
scripts/package.sh
bin/tt: $(OBJS)
@mkdir -p $(@D)
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJS) $(LIBS)
objs/%.o: src/%.cpp $(INCS)
@mkdir -p $(@D)
$(CPP) $(CFLAGS) -c $< -o $@
objs/*/%.o: src/*/%.cpp $(INCS)
@mkdir -p $(@D)
$(CPP) $(CFLAGS) -c $< -o $@
objs/tools/%.o: tools/%.cpp
@mkdir -p $(@D)
$(CPP) $(CFLAGS) -c $< -o $@
TSRCS = $(wildcard test/*.cpp)
TOBJS = $(patsubst %.cpp,objs/%.o,$(TSRCS))
test: $(TESTS)
objs/test/%.o: test/%.cpp $(INCS) $(TINCS)
@mkdir -p $(@D)
$(CPP) $(CFLAGS) -I test/include -c $< -o $@
bin/all_tests: $(OBJI) $(TOBJS)
@mkdir -p $(@D)
$(LINK) $(LFLAGS) -o $@ $(OBJI) $(TOBJS) $(LIBS)
tools: $(TOOLS)
UOBJS = $(wildcard objs/tools/*.o)
#bin/backfill: objs/tools/backfill.o
# @mkdir -p $(@D)
# $(LINK) $(LFLAGS) -o $@ $< $(LIBS)
bin/inspect: objs/tools/inspect.o $(OBJI)
@mkdir -p $(@D)
$(LINK) $(LFLAGS) -o $@ $< $(OBJI) $(LIBS)
bin/iobench: objs/tools/iobench.o $(OBJI)
@mkdir -p $(@D)
$(LINK) $(LFLAGS) -o $@ $< $(OBJI) $(LIBS)
bin/append: objs/tools/append.o $(OBJI)
@mkdir -p $(@D)
$(LINK) $(LFLAGS) -o $@ $< $(OBJI) $(LIBS)
bin/client_http: objs/tools/client_http.o
@mkdir -p $(@D)
$(LINK) $(LFLAGS) -o $@ $<
tt: clean build
all: build test tools
clean:
$(RM) $(OBJS) $(TOBJS) $(UOBJS) $(TARGET) $(TESTS) $(TOOLS)