Rouzbahan Rashidi-Tabrizi | 663f01a | 2016-11-17 11:39:02 -0500 | [diff] [blame^] | 1 | PROTO_FILES := $(wildcard *.proto) $(wildcard third_party/google/api/*proto) |
| 2 | PROTO_PB2_FILES := $(foreach f,$(PROTO_FILES),$(subst .proto,_pb2.py,$(f))) |
| 3 | PROTO_DESC_FILES := $(foreach f,$(PROTO_FILES),$(subst .proto,.desc,$(f))) |
| 4 | |
| 5 | PROTOC_PREFIX := /usr/local |
| 6 | PROTOC_LIBDIR := $(PROTOC_PREFIX)/lib |
| 7 | |
| 8 | PROTOC := $(PROTOC_PREFIX)/bin/protoc |
| 9 | |
| 10 | PROTOC_VERSION := "3.0.2" |
| 11 | PROTOC_DOWNLOAD_PREFIX := "https://github.com/google/protobuf/releases/download" |
| 12 | PROTOC_DIR := protobuf-$(PROTOC_VERSION) |
| 13 | PROTOC_TARBALL := protobuf-python-$(PROTOC_VERSION).tar.gz |
| 14 | PROTOC_DOWNLOAD_URI := $(PROTOC_DOWNLOAD_PREFIX)/v$(PROTOC_VERSION)/$(PROTOC_TARBALL) |
| 15 | PROTOC_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 | |
| 24 | install-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 |