-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
113 lines (84 loc) · 3.55 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
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
108
109
110
111
112
113
# Makefile for SuperFastMatch
#================================================================
# Setting Variables
#================================================================
# Generic settings
SHELL = /bin/sh
# Data path
DATA = ./data
# Targets
MYBINS = superfastmatch
OBJS = src/worker.o src/api.o src/queue.o src/posting.o src/document.o src/logger.o src/registry.o src/command.o src/postline.o src/association.o src/query.o src/task.o src/codec.o src/instrumentation.o src/search.o src/loader.o src/json/jsoncpp.o
MAIN = src/superfastmatch.o
# Building binaries
INCLUDES = -Isrc/ -I src/json/ -Itests -I/usr/local/ -Itests/utils/
#LDFLAGS = -Wl,-no_pie
CXXFLAGS = -Wall -Wextra -funsigned-char -m64 -mtune=native -g -O3 -DJSON_IS_AMALGAMATION
PROFILEFLAGS = -O1
LIBS = -lstdc++ -lz -lm -lc -lpthread -lkyototycoon -lkyotocabinet -lctemplate -lgflags -llzo2 -lre2
CXX = g++ $(INCLUDES)
#CXX = icc $(INCLUDES)
# Enviroments
# RUNENV = TCMALLOC_SAMPLE_PARAMETER=524288
# PROFILEENV = HEAPPROFILE=/tmp/superfastmatch.hprof
DEBUGENV = gdb
#================================================================
# Test variables
#================================================================
TESTS = tests/command-unittest.o tests/postline-unittest.o tests/document-unittest.o tests/association-unittest.o tests/posting-unittest.o tests/benchmark.o tests/hash-unittest.o tests/query-unittest.o tests/instrumentation-unittest.o tests/api-unittest.o
GTEST_DIR = tests/utils
#================================================================
# Suffix rules
#================================================================
.SUFFIXES :
.SUFFIXES : .cc .o
.cc.o :
$(CXX) $(CXXFLAGS) $< -o $@
#================================================================
# Dependency stuff
# http://www.scottmcpeak.com/autodepend/autodepend.html
#================================================================
%.o: %.cc
$(CXX) -c $(CXXFLAGS) $*.cc -o $*.o
$(CXX) -MM $(CXXFLAGS) $*.cc > $*.d
@mv -f $*.d $*.d.tmp
@sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
@sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
@rm -f $*.d.tmp
#================================================================
# Actions
#================================================================
all : $(MYBINS)
clean :
rm -rf $(MYBINS) tests/*.o $(GTEST_DIR)/*.o $(GTEST_DIR)/*.a *.a *.o *.exe src/*.o src/*.d src/jsoncpp/*.o src/jsoncpp/*.d
mkdir -p $(DATA)
run : all
mkdir -p $(DATA)
$(RUNENV) ./superfastmatch -reset -debug
production : LDFLAGS += -ltcmalloc
production : all
profile : CXXFLAGS += $(PROFILEFLAGS)
profile : tests/tests
valgrind --suppressions=valgrind.suppressions --leak-check=full --track-origins=yes --dsymutil=yes tests/tests
debug : CXXFLAGS += -O0
debug : all
check : tests/tests
tests/tests --gtest_filter=-*Slow*
.PHONY : all clean check profile debug run
#================================================================
# Building Tests
#================================================================
tests/gmock-gtest.a : $(GTEST_DIR)/gmock-gtest-all.o
$(AR) $(ARFLAGS) $@ $^
tests/tests : $(OBJS) $(TESTS) tests/tests.o tests/mock_registry.o tests/gmock-gtest.a
$(CXX) $(INCLUDES) $(CXXFLAGS) -o $@ $^ $(LIBS)
#================================================================
# Building binaries
#================================================================
superfastmatch : $(OBJS) $(MAIN)
$(CXX) $(OBJS) $(LDFLAGS) $(LIBS) $(MAIN) -o $@
# pull in dependency info for *existing* .o files
-include $(OBJS:.o=.d)
# END OF FILE
# DO NOT DELETE