forked from tjjh89017/ezio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
80 lines (61 loc) · 1.71 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
PROG = ezio
STATIC_PROG = static-$(PROG)
CC =
CXX = g++
LD = g++
CXXFLAGS = -std=c++11 -I./ -pthread
LDFLAGS = -ltorrent-rasterbar -lboost_system -lstdc++ -lm -lgcc -lssl -lcrypto -lboost_program_options -lboost_chrono -lboost_random -ldl -lpthread
PROTOC = protoc
GRPC_CPP_PLUGIN = grpc_cpp_plugin
GRPC_CPP_PLUGIN_PATH ?= `which $(GRPC_CPP_PLUGIN)`
PROTOS_PATH = ./
vpath %.proto $(PROTOS_PATH)
OBJS = main.o \
config.o \
raw_storage.o \
logger.o
INC =
PROTO_SRC =
GRPC_OBJS =
GRPC_INC =
PYTHON_OBJS =
ifneq ($(GRPC),)
OBJS += service.o
PROTO_SRC = ezio.proto
GRPC_OBJS += ezio.grpc.pb.o \
ezio.pb.o
GRPC_INC += ezio.grpc.pb.h \
ezio.pb.h
PYTHON_OBJS += ezio_pb2_grpc.py \
ezio_pb2.py
CXXFLAGS += -DENABLE_GRPC
LDFLAGS += -lprotobuf -pthread -lpthread -lgrpc++ -lgrpc -lz
endif
.PHONY: all
all: $(PROG) client
.PHONY: static
static: $(STATIC_PROG)
$(PROG): $(OBJS) $(GRPC_OBJS) $(INC)
$(LD) -o $(PROG) $(OBJS) $(GRPC_OBJS) $(LDFLAGS) $(CXXFLAGS)
$(STATIC_PROG): $(OBJS) $(GRPC_OBJS) $(INC)
$(LD) -static -o $(STATIC_PROG) $(OBJS) $(GRPC_OBJS) $(LDFLAGS) $(CXXFLAGS)
strip -s $(STATIC_PROG)
%.grpc.pb.cc: %.proto
$(PROTOC) -I $(PROTOS_PATH) --grpc_out=. --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN_PATH) $<
%.pb.cc: %.proto
$(PROTOC) -I $(PROTOS_PATH) --cpp_out=. $<
$(PYTHON_OBJS): $(PROTO_SRC)
python3 -m grpc_tools.protoc -I./ --python_out=. --grpc_python_out=. $(PROTO_SRC)
%.o: %.cpp headers
$(CXX) -c $(CXXFLAGS) $(LDFLAGS) -o $*.o $*.cpp
.PHONY: headers
headers: $(GRPC_OBJS:.o=.cc)
.PHONY: client
client: $(PYTHON_OBJS)
.PHONY: clean
clean:
rm -rf $(OBJS) $(GRPC_OBJS) $(GRPC_OBJS:.o=.cc) $(GRPC_INC) $(PYTHON_OBJS) $(PROG) $(STATIC_PROG)
make -C utils clean
.PHONY: netboot
netboot: static
make -C utils all