1# This is a simple Makefile that generates client library source code 2# for Google APIs using Protocol Buffers and gRPC for any supported 3# language. However, it does not compile the generated code into final 4# libraries that can be directly used with application code. 5# 6# Syntax example: make OUTPUT=./output LANGUAGE=java 7# 8 9# Choose the output directory 10OUTPUT ?= ./gens 11 12# Choose the target language. 13LANGUAGE ?= cpp 14 15# Choose grpc plugin 16GRPCPLUGIN ?= /usr/local/bin/grpc_$(LANGUAGE)_plugin 17 18# Choose the proto include directory. 19PROTOINCLUDE ?= /usr/local/include 20 21# Choose protoc binary 22PROTOC ?= protoc 23 24# Compile the entire repository 25# 26# NOTE: if "protoc" command is not in the PATH, you need to modify this file. 27# 28 29ifeq ($(LANGUAGE),go) 30$(error Go source files are not generated from this repository. See: https://github.com/google/go-genproto) 31endif 32 33FLAGS+= --proto_path=.:$(PROTOINCLUDE) 34FLAGS+= --$(LANGUAGE)_out=$(OUTPUT) --grpc_out=$(OUTPUT) 35FLAGS+= --plugin=protoc-gen-grpc=$(GRPCPLUGIN) 36 37SUFFIX:= pb.cc 38 39DEPS:= $(shell find google $(PROTOINCLUDE)/google/protobuf -type f -name '*.proto' | sed "s/proto$$/$(SUFFIX)/") 40 41all: $(DEPS) 42 43%.$(SUFFIX): %.proto 44 mkdir -p $(OUTPUT) 45 $(PROTOC) $(FLAGS) $*.proto 46 47clean: 48 rm $(patsubst %,$(OUTPUT)/%,$(DEPS)) 2> /dev/null 49 rm -rd $(OUTPUT) 50