Rouzbahan Rashidi-Tabrizi | 7b1bab9 | 2016-11-21 14:28:50 -0500 | [diff] [blame] | 1 | # |
| 2 | # Copyright 2016 the original author or authors. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # |
| 16 | |
Rouzbahan Rashidi-Tabrizi | 663f01a | 2016-11-17 11:39:02 -0500 | [diff] [blame] | 17 | PROTO_FILES := $(wildcard *.proto) $(wildcard third_party/google/api/*proto) |
| 18 | PROTO_PB2_FILES := $(foreach f,$(PROTO_FILES),$(subst .proto,_pb2.py,$(f))) |
| 19 | PROTO_DESC_FILES := $(foreach f,$(PROTO_FILES),$(subst .proto,.desc,$(f))) |
| 20 | |
| 21 | PROTOC_PREFIX := /usr/local |
| 22 | PROTOC_LIBDIR := $(PROTOC_PREFIX)/lib |
| 23 | |
| 24 | PROTOC := $(PROTOC_PREFIX)/bin/protoc |
| 25 | |
| 26 | PROTOC_VERSION := "3.0.2" |
| 27 | PROTOC_DOWNLOAD_PREFIX := "https://github.com/google/protobuf/releases/download" |
| 28 | PROTOC_DIR := protobuf-$(PROTOC_VERSION) |
| 29 | PROTOC_TARBALL := protobuf-python-$(PROTOC_VERSION).tar.gz |
| 30 | PROTOC_DOWNLOAD_URI := $(PROTOC_DOWNLOAD_PREFIX)/v$(PROTOC_VERSION)/$(PROTOC_TARBALL) |
| 31 | PROTOC_BUILD_TMP_DIR := "/tmp/protobuf-build-$(shell uname -s | tr '[:upper:]' '[:lower:]')" |
| 32 | |
| 33 | $(PROTOC): |
| 34 | @echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" |
| 35 | @echo "It looks like you don't have protocol buffer tools installed." |
| 36 | @echo "To install the protocol buffer toolchain, you can run:" |
| 37 | @echo " make install-protoc" |
| 38 | @echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" |
| 39 | |
| 40 | install-protoc: $(PROTOC) |
| 41 | @echo "Downloading and installing protocol buffer support." |
| 42 | @echo "Installation will require sodo priviledges" |
| 43 | @echo "This will take a few minutes." |
| 44 | mkdir -p $(PROTOC_BUILD_TMP_DIR) |
| 45 | @echo "We ask for sudo credentials now so we can install at the end"; \ |
| 46 | sudo echo "Thanks"; \ |
| 47 | cd $(PROTOC_BUILD_TMP_DIR); \ |
| 48 | wget $(PROTOC_DOWNLOAD_URI); \ |
| 49 | tar xzvf $(PROTOC_TARBALL); \ |
| 50 | cd $(PROTOC_DIR); \ |
| 51 | ./configure --prefix=$(PROTOC_PREFIX); \ |
| 52 | make; \ |
| 53 | sudo make install |