From 2bf066e37f438199b31459d6f78ff1dfcc8dd5de Mon Sep 17 00:00:00 2001 From: Gary Belvin Date: Fri, 29 May 2015 00:26:18 -0700 Subject: [PATCH] Golang needs whole packages to be compiled together. Added globbing. Generalized dependency rule Added error checking for LANGUAGE variable --- Makefile | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index dd6c205e..8c2a2d0b 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,6 @@ LANGUAGE ?= cpp # directory is not "/usr/local/include", you need to modify this file. # -DEPS:= $(shell find google -type f -name '*.proto' | sed 's/proto$$/pb.go/') FLAGS+= --proto_path=.:/usr/local/include ifeq ($(LANGUAGE),go) FLAGS+= --$(LANGUAGE)_out=plugins=grpc:$(OUTPUT) @@ -27,11 +26,25 @@ else FLAGS+= --plugin=protoc-gen-grpc=/usr/local/bin/grpc_$(LANGUAGE)_plugin endif -all: $(DEPS) +ifeq ($(LANGUAGE),go) +SUFFIX:= pb.go +endif +ifeq ($(LANGUAGE),cpp) +SUFFIX:= pb.cc +endif -%.pb.go: %.proto +DEPS:= $(shell find . -type f -name '*.proto' | sed "s/proto$$/$(SUFFIX)/") + +all: supported_lang $(DEPS) + +supported_lang: +ifndef SUFFIX + $(error unsupported language: [$(LANGUAGE)]) +endif + +%.$(SUFFIX): %.proto mkdir -p $(OUTPUT) - protoc $(FLAGS) $< + protoc $(FLAGS) $(dir $<)*.proto clean: rm $(patsubst %,$(OUTPUT)/%,$(DEPS)) 2> /dev/null