Untitled

mail@pastecode.io avatar
unknown
makefile
2 years ago
1.2 kB
2
Indexable
Never
UNIT=libchurch_example
CLIENT = libchurch_client
SERVER = libchurch_server
PRODUCT= $(SERVER)

PROTO_DIR = .
PROTO_GEN_DIR = .

PROTO_FILES = $(wildcard libchurch_example.proto) \
	#
PROTO_SOURCES = $(wildcard libchurch_example.*.cc) \
	#
PROTO_HEADERS = $(wildcard libchurch_example.*.h) \
	#
PROTO_OBJ = $(PROTO_SOURCES:.cc=.o)

SERVER_SRC = server.cpp \
	#
SERVER_OBJ = $(SERVER_SRC:.cpp=.o)

CLIENT_SRC = client.cpp \
	#
CLIENT_OBJ = $(CLIENT_SRC:.cpp=.o)

CXXFLAGS = -O2 -fPIC -Wall -Wformat -std=c++17 $(PROTOBUF_CXXFLAGS) -I../$(BASE)

LIBS = $(PROTOBUF_LFLAGS) $(GRPC_LFLAGS)

all: library

generate: $(PROTO_FILES)
	$(shell mkdir -p $(PROTO_GEN_DIR))
	LD_LIBRARY_PATH=$(GRPC_LIBDIR):$(GRPC_LIB64DIR) $(PROTOC) \
		--plugin=protoc-gen-grpc=$(PROTOC_CPP_PLUGIN) -I$(PROTO_DIR) \
		--grpc_out=$(PROTO_GEN_DIR) --cpp_out=$(PROTO_GEN_DIR) $<

		

library: generate $(PRODUCT)

$(PROTO_OBJ): $(PROTO_HEADERS)

$(SERVER_OBJ):

$(SERVER): $(PROTO_OBJ) $(SERVER_OBJ)
	$(CXX) $(CXXFLAGS) -o $@ $(PROTO_OBJ) $(SERVER_OBJ) $(LIBS)

$(CLIENT): $(CLIENT_OBJ) $(PROTO_OBJ)
	$(CXX) $(CXXFLAGS) -o $@ $(CLIENT_OBJ) $(PROTO_OBJ) $(LIBS)

clean:
	-$(RM) $(PRODUCT) $(PROTO_HEADERS) $(PROTO_SOURCES) $(SERVER_OBJ) $(CLIENT_OBJ) $(PROTO_OBJ)