blob: e63230203ca57a95a3c643628b7cd3a40e59c620 [file] [log] [blame]
Rouzbahan Rashidi-Tabrizi663f01a2016-11-17 11:39:02 -05001PROTO_FILES := $(wildcard *.proto) $(wildcard third_party/google/api/*proto)
2PROTO_PB2_FILES := $(foreach f,$(PROTO_FILES),$(subst .proto,_pb2.py,$(f)))
3PROTO_DESC_FILES := $(foreach f,$(PROTO_FILES),$(subst .proto,.desc,$(f)))
4
5PROTOC_PREFIX := /usr/local
6PROTOC_LIBDIR := $(PROTOC_PREFIX)/lib
7
8PROTOC := $(PROTOC_PREFIX)/bin/protoc
9
10PROTOC_VERSION := "3.0.2"
11PROTOC_DOWNLOAD_PREFIX := "https://github.com/google/protobuf/releases/download"
12PROTOC_DIR := protobuf-$(PROTOC_VERSION)
13PROTOC_TARBALL := protobuf-python-$(PROTOC_VERSION).tar.gz
14PROTOC_DOWNLOAD_URI := $(PROTOC_DOWNLOAD_PREFIX)/v$(PROTOC_VERSION)/$(PROTOC_TARBALL)
15PROTOC_BUILD_TMP_DIR := "/tmp/protobuf-build-$(shell uname -s | tr '[:upper:]' '[:lower:]')"
16
17$(PROTOC):
18 @echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
19 @echo "It looks like you don't have protocol buffer tools installed."
20 @echo "To install the protocol buffer toolchain, you can run:"
21 @echo " make install-protoc"
22 @echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
23
24install-protoc: $(PROTOC)
25 @echo "Downloading and installing protocol buffer support."
26 @echo "Installation will require sodo priviledges"
27 @echo "This will take a few minutes."
28 mkdir -p $(PROTOC_BUILD_TMP_DIR)
29 @echo "We ask for sudo credentials now so we can install at the end"; \
30 sudo echo "Thanks"; \
31 cd $(PROTOC_BUILD_TMP_DIR); \
32 wget $(PROTOC_DOWNLOAD_URI); \
33 tar xzvf $(PROTOC_TARBALL); \
34 cd $(PROTOC_DIR); \
35 ./configure --prefix=$(PROTOC_PREFIX); \
36 make; \
37 sudo make install