blob: ba025c68c8e33a7b83a29e2cb49bc315fe4b4878 [file] [log] [blame]
Rouzbahan Rashidi-Tabrizi7b1bab92016-11-21 14:28:50 -05001#
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-Tabrizi663f01a2016-11-17 11:39:02 -050017PROTO_FILES := $(wildcard *.proto) $(wildcard third_party/google/api/*proto)
18PROTO_PB2_FILES := $(foreach f,$(PROTO_FILES),$(subst .proto,_pb2.py,$(f)))
19PROTO_DESC_FILES := $(foreach f,$(PROTO_FILES),$(subst .proto,.desc,$(f)))
20
21PROTOC_PREFIX := /usr/local
22PROTOC_LIBDIR := $(PROTOC_PREFIX)/lib
23
24PROTOC := $(PROTOC_PREFIX)/bin/protoc
25
26PROTOC_VERSION := "3.0.2"
27PROTOC_DOWNLOAD_PREFIX := "https://github.com/google/protobuf/releases/download"
28PROTOC_DIR := protobuf-$(PROTOC_VERSION)
29PROTOC_TARBALL := protobuf-python-$(PROTOC_VERSION).tar.gz
30PROTOC_DOWNLOAD_URI := $(PROTOC_DOWNLOAD_PREFIX)/v$(PROTOC_VERSION)/$(PROTOC_TARBALL)
31PROTOC_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
40install-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