-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
180 lines (143 loc) · 6.4 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
include depends.mk
# OPT ?= -O2 -DNDEBUG # (A) Production use (optimized mode)
OPT ?= -g2 -Wall -Werror # (B) Debug mode, w/ full line-level debugging symbols
# OPT ?= -O2 -g2 -DNDEBUG # (C) Profiling mode: opt, but w/debugging symbols
CC = gcc
CXX = g++
SHARED_CFLAGS = -fPIC
SHARED_LDFLAGS = -shared -Wl,-soname -Wl,
INCPATH += -I./src -I./include -I./src/leveldb/include -I./src/leveldb $(DEPS_INCPATH)
CFLAGS += -std=c99 $(OPT) $(SHARED_CFLAGS) $(INCPATH)
CXXFLAGS += $(OPT) $(SHARED_CFLAGS) $(INCPATH)
LDFLAGS += -rdynamic $(DEPS_LDPATH) $(DEPS_LDFLAGS) -lpthread -lrt -lz -ldl
PROTO_FILES := $(wildcard src/proto/*.proto)
PROTO_OUT_CC := $(PROTO_FILES:.proto=.pb.cc)
PROTO_OUT_H := $(PROTO_FILES:.proto=.pb.h)
############################################################
OTHER_SRC := src/trace_flags.cc src/fs_inotify.cc
SDK_SRC := $(wildcard src/sdk/*.cc)
COMMON_SRC := $(wildcard src/common/*.cc)
UTIL_SRC := $(wildcard src/util/*.cc)
PROTO_SRC := $(filter-out %.pb.cc, $(wildcard src/proto/*.cc)) $(PROTO_OUT_CC)
VERSION_SRC := src/version.cc
MDTTOOL_SRC := $(wildcard src/mdt-tool/mdt-tool.cc)
UPDATESCHEMA_SRC := $(wildcard src/mdt-tool/test_update_schema.cc)
SAMPLE_SRC := $(wildcard src/sample/mdt_test.cc)
WRITE_TEST_SRC := $(wildcard src/benchmark/write_test.cc)
DUMPFILE_SRC := $(wildcard src/benchmark/dump_file.cc)
SYNC_WRITE_TEST_SRC := $(wildcard src/benchmark/sync_write_test.cc)
MULWRITE_TEST_SRC := $(wildcard src/benchmark/mulcli_write_test.cc)
SCAN_TEST_SRC := $(wildcard src/benchmark/scan_test.cc)
C_SAMPLE_SRC := $(wildcard src/sample/c_sample.c)
FTRACE_SRC := $(wildcard src/ftrace/*.cc)
FTRACE_TEST_SRC := $(wildcard src/ftrace/test/*.cc)
AGENT_SRC := $(wildcard src/agent/*.cc)
COLLECTOR_SRC := $(wildcard src/collector/*.cc)
SCHEDULER_SRC := $(wildcard src/scheduler/*.cc)
############################################################
OTHER_OBJ := $(OTHER_SRC:.cc=.o)
SDK_OBJ := $(SDK_SRC:.cc=.o)
COMMON_OBJ := $(COMMON_SRC:.cc=.o)
UTIL_OBJ := $(UTIL_SRC:.cc=.o)
PROTO_OBJ := $(PROTO_SRC:.cc=.o)
VERSION_OBJ := $(VERSION_SRC:.cc=.o)
SAMPLE_OBJ := $(SAMPLE_SRC:.cc=.o)
MDTTOOL_OBJ := $(MDTTOOL_SRC:.cc=.o)
UPDATESCHEMA_OBJ := $(UPDATESCHEMA_SRC:.cc=.o)
WRITE_TEST_OBJ := $(WRITE_TEST_SRC:.cc=.o)
DUMPFILE_OBJ := $(DUMPFILE_SRC:.cc=.o)
SYNC_WRITE_TEST_OBJ := $(SYNC_WRITE_TEST_SRC:.cc=.o)
MULWRITE_TEST_OBJ := $(MULWRITE_TEST_SRC:.cc=.o)
SCAN_TEST_OBJ := $(SCAN_TEST_SRC:.cc=.o)
C_SAMPLE_OBJ := $(C_SAMPLE_SRC:.c=.o)
FTRACE_OBJ := $(FTRACE_SRC:.cc=.o)
FTRACE_TEST_OBJ := $(FTRACE_TEST_SRC:.cc=.o)
AGENT_OBJ := $(AGENT_SRC:.cc=.o)
COLLECTOR_OBJ := $(COLLECTOR_SRC:.cc=.o)
SCHEDULER_OBJ := $(SCHEDULER_SRC:.cc=.o)
CXX_OBJ := $(SDK_OBJ) $(COMMON_OBJ) $(UTIL_OBJ) $(PROTO_OBJ) $(VERSION_OBJ) \
$(SAMPLE_OBJ) $(MDTTOOL_OBJ) $(WRITE_TEST_OBJ) $(MULWRITE_TEST_OBJ) \
$(SCAN_TEST_OBJ) $(SYNC_WRITE_TEST_OBJ) $(UPDATESCHEMA_OBJ) $(DUMPFILE_OBJ) \
$(COLLECTOR_OBJ) $(SCHEDULER_OBJ)
C_OBJ := $(C_SAMPLE_OBJ)
LEVELDB_LIB := src/leveldb/libleveldb.a
############################################################
PROGRAM = agent_main collector_main scheduler_main
FTRACELIBRARY = libftrace.a
FTRACE_TEST = TEST_log
LIBRARY = libmdt.a
SAMPLE = sample
MDTTOOL = mdt-tool
UPDATESCHEMA = test_update_schema
MDTTOOL_TEST = mdt-tool-test
WRITE_TEST = write_test
DUMPFILE = dumpfile
SYNC_WRITE_TEST = sync_write_test
MULWRITE_TEST = mulcli_write_test
SCAN_TEST = scan_test
C_SAMPLE = c_sample
.PHONY: all clean cleanall test
all: $(PROGRAM) $(LIBRARY) $(FTRACELIBRARY) $(SAMPLE) $(C_SAMPLE) $(MDTTOOL) $(WRITE_TEST) $(DUMPFILE) $(MULWRITE_TEST) $(SCAN_TEST) $(SYNC_WRITE_TEST) $(UPDATESCHEMA) $(FTRACE_TEST)
mkdir -p build/include build/lib build/bin
cp $(PROGRAM) build/bin
cp $(LIBRARY) build/lib
cp src/sdk/sdk.h build/include/mdt.h
cp src/sdk/c.h build/include/mdt_c.h
cp src/sdk/mdt.go build/include/mdt.go
cp -r conf build
cp $(DEPS_LIBRARIES) build/lib
echo 'Done'
clean:
rm -rf $(CXX_OBJ) $(C_OBJ) $(FTRACE_OBJ) $(AGENT_OBJ) $(SCHEDULER_OBJ) $(COLLECTOR_OBJ)
rm -rf $(PROGRAM) $(LIBRARY) $(FTRACELIBRARY) $(SAMPLE) $(C_SAMPLE) $(MDTTOOL) $(WRITE_TEST) $(MULWRITE_TEST) $(SCAN_TEST) $(SYNC_WRITE_TEST) $(UPDATESCHEMA) $(FTRACE_TEST)
rm -rf search_service
rm -rf $(DUMPFILE)
cleanall:
$(MAKE) clean
rm -rf build
src/leveldb/libleveldb.a: FORCE
$(MAKE) -C src/leveldb
sample: $(SAMPLE_OBJ) $(LIBRARY)
$(CXX) -o $@ $(SAMPLE_OBJ) $(LIBRARY) $(LDFLAGS)
mdt-tool: $(MDTTOOL_OBJ) $(LIBRARY) $(OTHER_OBJ)
$(CXX) -o $@ $(MDTTOOL_OBJ) $(LIBRARY) $(OTHER_OBJ) $(LDFLAGS) -lreadline -lhistory -lncurses
test_update_schema: $(UPDATESCHEMA_OBJ) $(LIBRARY)
$(CXX) -o $@ $(UPDATESCHEMA_OBJ) $(LIBRARY) $(LDFLAGS)
write_test: $(WRITE_TEST_OBJ) $(LIBRARY)
$(CXX) -o $@ $(WRITE_TEST_OBJ) $(LIBRARY) $(LDFLAGS)
dumpfile: $(DUMPFILE_OBJ) $(LIBRARY)
$(CXX) -o $@ $(DUMPFILE_OBJ) $(LIBRARY) $(LDFLAGS)
sync_write_test: $(SYNC_WRITE_TEST_OBJ) $(LIBRARY)
$(CXX) -o $@ $(SYNC_WRITE_TEST_OBJ) $(LIBRARY) $(LDFLAGS)
mulcli_write_test: $(MULWRITE_TEST_OBJ) $(LIBRARY)
$(CXX) -o $@ $(MULWRITE_TEST_OBJ) $(LIBRARY) $(LDFLAGS)
scan_test: $(SCAN_TEST_OBJ) $(LIBRARY)
$(CXX) -o $@ $(SCAN_TEST_OBJ) $(LIBRARY) $(LDFLAGS)
c_sample: $(C_SAMPLE_OBJ) $(LIBRARY)
$(CXX) -o $@ $(C_SAMPLE_OBJ) $(LIBRARY) $(LDFLAGS)
libmdt.a: $(SDK_OBJ) $(COMMON_OBJ) $(UTIL_OBJ) $(PROTO_OBJ) $(VERSION_OBJ)
$(AR) -rs $@ $(SDK_OBJ) $(COMMON_OBJ) $(UTIL_OBJ) $(PROTO_OBJ) $(VERSION_OBJ)
libftrace.a: $(FTRACE_OBJ) $(PROTO_OBJ)
$(AR) -rs $@ $(FTRACE_OBJ) $(PROTO_OBJ)
TEST_log: $(FTRACE_TEST_OBJ) $(FTRACELIBRARY)
$(CXX) -o $@ $(FTRACE_TEST_OBJ) $(FTRACELIBRARY) $(LDFLAGS)
agent_main: $(AGENT_OBJ) $(PROTO_OBJ) $(VERSION_OBJ) $(LEVELDB_LIB) $(OTHER_OBJ)
$(CXX) -o agent_main $(AGENT_OBJ) $(PROTO_OBJ) $(VERSION_OBJ) $(LDFLAGS) $(LEVELDB_LIB) $(OTHER_OBJ)
collector_main: $(COLLECTOR_OBJ) $(LIBRARY) $(OTHER_OBJ)
$(CXX) -o collector_main $(COLLECTOR_OBJ) $(LIBRARY) $(OTHER_OBJ) $(LDFLAGS)
scheduler_main: $(SCHEDULER_OBJ) $(PROTO_OBJ) $(VERSION_OBJ) $(OTHER_OBJ)
$(CXX) -o scheduler_main $(SCHEDULER_OBJ) $(PROTO_OBJ) $(VERSION_OBJ) $(OTHER_OBJ) $(LDFLAGS)
$(CXX_OBJ): %.o: %.cc $(PROTO_OUT_H)
$(CXX) $(CXXFLAGS) -c $< -o $@
$(C_OBJ): %.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
$(VERSION_SRC): FORCE
sh build_version.sh
.PHONY: proto
proto: $(PROTO_OUT_CC) $(PROTO_OUT_H)
%.pb.cc %.pb.h: %.proto
$(PROTOC) --proto_path=./src/proto/ --proto_path=$(PROTOBUF_INCDIR) \
--proto_path=$(SOFA_PBRPC_INCDIR) \
--cpp_out=./src/proto/ $<
.PHONY: FORCE
FORCE: