-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
84 lines (66 loc) · 3.07 KB
/
Makefile
File metadata and controls
84 lines (66 loc) · 3.07 KB
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
#
# Copyright 2015 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
HOST_SYSTEM = $(shell uname | cut -f 1 -d_)
SYSTEM ?= $(HOST_SYSTEM)
CXX = g++
CPPFLAGS += -Igrpc/include -Igrpc/third_party/protobuf/src -Itemp
CXXFLAGS += -std=c++11 -O2 -Wall -Werror
ifeq ($(SYSTEM),Darwin)
LDFLAGS += -O2 -Lgrpc/libs/opt -Lgrpc/third_party/protobuf/src/.libs -Lgrpc/third_party/zlib \
-lgrpc++_reflection\
-ldl -lgrpc -lgrpc++ -lgpr -lgrpc_unsecure -lprotobuf -lpthread -lz -static
else
LDFLAGS += -O2 -Lgrpc/libs/opt -Lgrpc/third_party/protobuf/src/.libs -Lgrpc/third_party/zlib \
-Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed\
-ldl -lgrpc -lgrpc++ -lgpr -lgrpc_unsecure -lprotobuf -lpthread -lz -static
endif
PROTOC = grpc/third_party/protobuf/src/protoc
GRPC_CPP_PLUGIN_PATH = grpc/bins/opt/grpc_cpp_plugin
BIN_PATH = bin
SRC_PATH = src
TEMP_PATH = temp
# Actual targets
all: $(BIN_PATH) $(TEMP_PATH) $(BIN_PATH)/gfs_client $(BIN_PATH)/gfs_master $(BIN_PATH)/gfs_server $(BIN_PATH)/bm_server
$(BIN_PATH)/gfs_client: $(TEMP_PATH)/gfs.pb.o $(TEMP_PATH)/gfs.grpc.pb.o $(TEMP_PATH)/gfs_client.o $(TEMP_PATH)/gfs_common.o
$(CXX) $(filter %.o,$^) $(LDFLAGS) -o $@
$(BIN_PATH)/gfs_master: $(TEMP_PATH)/gfs.pb.o $(TEMP_PATH)/gfs.grpc.pb.o $(TEMP_PATH)/gfs_master.o $(TEMP_PATH)/gfs_common.o $(TEMP_PATH)/sqlite3.o
$(CXX) $(filter %.o,$^) $(LDFLAGS) -o $@
$(BIN_PATH)/gfs_server: $(TEMP_PATH)/gfs.pb.o $(TEMP_PATH)/gfs.grpc.pb.o $(TEMP_PATH)/gfs_server.o $(TEMP_PATH)/gfs_common.o
$(CXX) $(filter %.o,$^) $(LDFLAGS) -o $@
$(BIN_PATH)/bm_server: $(TEMP_PATH)/gfs.pb.o $(TEMP_PATH)/gfs.grpc.pb.o $(TEMP_PATH)/bm_server.o $(TEMP_PATH)/gfs_common.o
$(CXX) $(filter %.o,$^) $(LDFLAGS) -o $@
# End actual targets
clean:
rm -rf $(BIN_PATH) $(TEMP_PATH)
$(BIN_PATH):
mkdir -p $(BIN_PATH)
$(TEMP_PATH):
mkdir -p $(TEMP_PATH)
.PRECIOUS: $(TEMP_PATH)/%.grpc.pb.cc
$(TEMP_PATH)/%.grpc.pb.cc: $(SRC_PATH)/%.proto
$(PROTOC) -I $(SRC_PATH) --grpc_out=$(TEMP_PATH) --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN_PATH) $<
.PRECIOUS: $(TEMP_PATH)/%.pb.cc
$(TEMP_PATH)/%.pb.cc: $(SRC_PATH)/%.proto
$(PROTOC) -I $(SRC_PATH) --cpp_out=$(TEMP_PATH) $<
# Special rule for SQLite which is C (not C++)
$(TEMP_PATH)/sqlite3.o: $(SRC_PATH)/sqlite3.c
gcc -c -O2 -o $@ $<
$(TEMP_PATH)/%.o: $(SRC_PATH)/%.cc $(SRC_PATH)/%.h $(SRC_PATH)/gfs_common.h
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
$(TEMP_PATH)/bm_server.o: $(SRC_PATH)/bm_server.cc $(SRC_PATH)/gfs_common.h
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
$(TEMP_PATH)/%.pb.o: $(TEMP_PATH)/%.pb.cc
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<