blob: 91df9e39d95d049b69273d1f8ecbb54d1b331a42 [file] [log] [blame]
Sergio Slobodrian6570c742017-08-07 23:11:33 -04001#
2# Copyright 2017 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
17# Makefile to build all protobuf and gRPC related artifacts
18
19ifeq ($(VOLTHA_BASE)_set,_set)
20 $(error To get started, please source the env.sh file from Voltha top level directory)
21endif
22
23default: build
24
25PROTO_PATH := ../voltha/protos
26PROTO_FILES := $(PROTO_PATH)/*.proto $(PROTO_PATH)/third_party/google/api/*proto
27PROTO_DESC_FILE := proto.pb
28
29PROTOC_PREFIX := /usr/local
30PROTOC_LIBDIR := $(PROTOC_PREFIX)/lib
31
32PROTOC := $(PROTOC_PREFIX)/bin/protoc
33
khenaidoo079a7762017-10-26 21:42:05 -040034PROTOC_VERSION := "3.3.0"
Sergio Slobodrian6570c742017-08-07 23:11:33 -040035PROTOC_DOWNLOAD_PREFIX := "https://github.com/google/protobuf/releases/download"
36PROTOC_DIR := protobuf-$(PROTOC_VERSION)
37PROTOC_TARBALL := protobuf-python-$(PROTOC_VERSION).tar.gz
38PROTOC_DOWNLOAD_URI := $(PROTOC_DOWNLOAD_PREFIX)/v$(PROTOC_VERSION)/$(PROTOC_TARBALL)
39PROTOC_BUILD_TMP_DIR := "/tmp/protobuf-build-$(shell uname -s | tr '[:upper:]' '[:lower:]')"
40
41build: $(PROTOC)
42 LD_LIBRARY_PATH=$(PROTOC_LIBDIR) $(PROTOC) -I $(PROTO_PATH)/third_party/ -I $(PROTO_PATH) --include_imports --include_source_info --descriptor_set_out=$(PROTO_DESC_FILE) $(PROTO_FILES)
43
44
45clean:
46 rm -f $(PROTO_DESC_FILE)
47
48$(PROTOC):
49 @echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
50 @echo "It looks like you don't have protocol buffer tools installed."
51 @echo "To install the protocol buffer toolchain, you can run:"
52 @echo " make install-protoc"
53 @echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
54
55install-protoc: $(PROTOC)
56 @echo "Downloading and installing protocol buffer support."
57 @echo "Installation will require sodo priviledges"
58 @echo "This will take a few minutes."
59 mkdir -p $(PROTOC_BUILD_TMP_DIR)
60 @echo "We ask for sudo credentials now so we can install at the end"; \
61 sudo echo "Thanks"; \
62 cd $(PROTOC_BUILD_TMP_DIR); \
63 wget $(PROTOC_DOWNLOAD_URI); \
64 tar xzvf $(PROTOC_TARBALL); \
65 cd $(PROTOC_DIR); \
66 ./configure --prefix=$(PROTOC_PREFIX); \
67 make; \
68 sudo make install
69
70uninstall-protoc:
71 cd $(PROTOC_BUILD_TMP_DIR)/$(PROTOC_DIR); \
72 sudo make uninstall
73