-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
executable file
·139 lines (111 loc) · 4.06 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
# Makefile for grpc_homa, which allows C++ applications based on gRPC
# to use Homa for message transport.
#
# Configuration: right now you'll need to modify this Makefile by hand
# to configure for your site. To do that, set the following variables
# below:
#
# HOMA_DIR: location of the top-level directory for the HomaModule repo
# GRPC_INSTALL_DIR: location where gRPC binaries are installed (note
# separate values for debugand release builds).
# DEBUG: can be set to "yes" to enable compilation with debugging
# enabled (must "make clean" after changing this).
HOMA_DIR := /users/ouster/homaModule
DEBUG := no
ifeq ($(DEBUG),no)
GRPC_INSTALL_DIR := /ouster/install.release
DEBUG_FLAGS := -O3 -DNDEBUG
else
GRPC_INSTALL_DIR := /ouster/install.debug
DEBUG_FLAGS := -g
endif
GRPC_LIBS := $(shell export PKG_CONFIG_PATH=$(GRPC_INSTALL_DIR)/lib/pkgconfig; \
pkg-config --libs protobuf grpc++) -lupb -lcares -lre2 -lz \
-laddress_sorting -lssl -lcrypto -lsystemd
ifeq ($(DEBUG),yes)
GRPC_LIBS := $(subst -lprotobuf,-lprotobufd,$(GRPC_LIBS))
endif
GTEST_INCLUDE_PATH = ../googletest/googletest/include
GTEST_LIB_PATH = ../googletest/build/lib
export PKG_LIB_PATH = $(GRPC_INSTALL_DIR)/lib/pkgconfig
GRPC_DIR = ../grpc
PROTOC = $(GRPC_INSTALL_DIR)/bin/protoc
CXX = g++
INCLUDES = -I $(GRPC_INSTALL_DIR)/include \
-I /users/ouster/homaModule \
-I $(GRPC_DIR) \
-I $(GRPC_DIR)/third_party/abseil-cpp \
-I $(GTEST_INCLUDE_PATH)
CXXFLAGS += $(DEBUG_FLAGS) -std=c++17 -Wall -Werror -Wno-comment \
-fno-strict-aliasing $(INCLUDES) -MD
CFLAGS = -Wall -Werror -fno-strict-aliasing $(DEBUG_FLAGS) -MD
OBJS = homa_client.o \
homa_incoming.o \
homa_listener.o \
homa_socket.o \
homa_stream.o \
stream_id.o \
time_trace.o \
util.o \
wire.o
HOMA_OBJS = homa_api.o
TEST_OBJS = mock.o \
test_incoming.o \
test_listener.o \
test_socket.o \
test_stream.o
LDFLAGS += -L/usr/local/lib $(GRPC_LIBS)\
-pthread\
-Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed\
-ldl
GRPC_CPP_PLUGIN = $(GRPC_INSTALL_DIR)/bin/grpc_cpp_plugin
PROTOS_PATH = .
all: libhoma.a stress test_client test_server tcp_test
libhoma.a: $(OBJS) $(HOMA_OBJS)
ar rcs libhoma.a $(OBJS) $^
stress: basic.grpc.pb.o basic.pb.o stress.o libhoma.a
$(CXX) $^ $(LDFLAGS) -o $@
test_client: test.grpc.pb.o test.pb.o test_client.o libhoma.a
$(CXX) $^ $(LDFLAGS) -o $@
test_server: test.grpc.pb.o test.pb.o test_server.o libhoma.a
$(CXX) $^ $(LDFLAGS) -o $@
tcp_test: test.grpc.pb.o test.pb.o tcp_test.o time_trace.o
$(CXX) $^ $(LDFLAGS) -o $@
unit: $(OBJS) $(TEST_OBJS) $(GTEST_LIB_PATH)/libgtest_main.a \
$(GTEST_LIB_PATH)/libgtest.a
$(CXX) $^ $(LDFLAGS) -o $@
test: unit
./unit --gtest_brief=1
homa_api.o: $(HOMA_DIR)/homa_api.c
cc -c $(CFLAGS) $< -o $@
clean:
rm -f test_client test_server unit tcp_test *.a *.o *.pb.* .deps
install: all
rsync -avz stress test_client test_server node-1:
rsync -avz stress test_client test_server node-2:
rsync -avz stress test_client test_server node-3:
rsync -avz stress test_client test_server node-4:
%.o: %.cc
$(CXX) -c $(CXXFLAGS) $< -o $@
%.o: %.c
cc -c $(CFLAGS) $< -o $@
%.grpc.pb.cc %.grpc.pb.h: %.proto %.pb.cc
$(PROTOC) -I $(PROTOS_PATH) --grpc_out=. --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN) $<
%.pb.cc %.pb.h: %.proto
$(PROTOC) -I $(PROTOS_PATH) --cpp_out=. $<
.PHONY: test clean
.PRECIOUS: test.grpc.pb.h test.grpc.pb.cc test.pb.h test.pb.cc
test_client.o test_server.o tcp_test.o : test.grpc.pb.h test.pb.h
stress.o: basic.grpc.pb.h basic.pb.h
# This magic (along with the -MD gcc option) automatically generates makefile
# dependencies for header files included from source files we compile,
# and keeps those dependencies up-to-date every time we recompile.
# See 'mergedep.pl' for more information.
.deps: $(wildcard *.d)
@mkdir -p $(@D)
perl mergedep.pl $@ $^
-include .deps
# The following target is useful for debugging Makefiles; it
# prints the value of a make variable.
print-%:
@echo $* = $($*)