-
Notifications
You must be signed in to change notification settings - Fork 5
/
GNUmakefile
62 lines (47 loc) · 1.79 KB
/
GNUmakefile
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
CFLAGS=-O2 -g -Wall -Wextra -Werror -std=c++0x -Wno-sign-compare
CFLAGS+=-DSNAPSHOT_ISOLATION=0 -DSMALL_RECORDS=0 -DREAD_COMMITTED=1
LIBS=-lnuma -lpthread -lrt -lcityhash
CXX=g++
LIBPATH=./libs/lib/
INC_DIRS=include libs/include
INCLUDE=$(foreach d, $(INC_DIRS), -I$d)
SRC=src
SOURCES:=$(wildcard $(SRC)/*.cc $(SRC)/*.c)
HEKATON:=$(wildcard $(SRC)/hek*.cc $(SRC)/hek*.c)
HEK_OBJ:=$(patsubst $(SRC)/%.cc,build/%.o,$(HEKATON))
OBJECTS:=$(patsubst $(SRC)/%.cc,build/%.o,$(SOURCES))
START:=$(wildcard start/*.cc start/*.c)
START_OBJECTS:=$(patsubst start/%.cc,start/%.o,$(START))
TEST:=test
TESTSOURCES:=$(wildcard $(TEST)/*.cc)
TESTOBJECTS:=$(patsubst test/%.cc,test/%.o,$(TESTSOURCES))
NON_HEK_OBJECTS:=$(filter-out $(HEK_OBJ),$(OBJECTS))
NON_MAIN_STARTS:=$(filter-out start/main.o,$(START_OBJECTS))
DEPSDIR:=.deps
DEPCFLAGS=-MD -MF $(DEPSDIR)/$*.d -MP
all:CFLAGS+=-DTESTING=0 -DUSE_BACKOFF=1 -fno-omit-frame-pointer
all:env build/db
test:CFLAGS+=-DTESTING=1 -DUSE_BACKOFF=1
test:env build/tests
-include $(wildcard $(DEPSDIR)/*.d)
build/%.o: src/%.cc $(DEPSDIR)/stamp GNUmakefile
@mkdir -p build
@echo + cc $<
@$(CXX) $(CFLAGS) $(DEPCFLAGS) $(INCLUDE) -c -o $@ $<
$(TESTOBJECTS):$(OBJECTS)
test/%.o: test/%.cc $(DEPSDIR)/stamp GNUmakefile
@echo + cc $<
@$(CXX) $(CFLAGS) -Wno-missing-field-initializers -Wno-conversion-null $(DEPCFLAGS) -Istart -I$(SRC) -I$(INCLUDE) -c -o $@ $<
start/%.o: start/%.cc $(DEPSDIR)/stamp GNUmakefile
@echo + cc $<
@$(CXX) $(CFLAGS) $(DEPCFLAGS) $(INCLUDE) -Istart -c -o $@ $<
build/db:$(START_OBJECTS) $(OBJECTS)
@$(CXX) $(CFLAGS) -o $@ $^ -L$(LIBPATH) $(LIBS)
build/tests:$(OBJECTS) $(TESTOBJECTS) $(NON_MAIN_STARTS)
@$(CXX) $(CFLAGS) -o $@ $^ $(LIBS)
$(DEPSDIR)/stamp:
@mkdir -p $(DEPSDIR)
@touch $@
.PHONY: clean env
clean:
rm -rf build $(DEPSDIR) $(TESTOBJECTS) start/*.o