blob: 92b99d85219cfe48c7f7a672874b7eb5a4b9be83 [file] [log] [blame]
Shad Ansari19249582018-04-30 04:31:00 +00001# Copyright (c) 2018 Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at:
6#
7# http:#www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15HOST_SYSTEM = $(shell uname | cut -f 1 -d_)
16SYSTEM ?= $(HOST_SYSTEM)
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000017
18# OpenOLT Proto version.
19# This specifies the GIT tag in https://github.com/opencord/voltha-protos
20# repo that we need to refer to, to pick the right version of
21# openolt.proto and tech_profile.proto
Burak Gurdag2f2618c2020-04-23 13:20:30 +000022OPENOLT_PROTO_VER ?= v3.3.5
Girish Gowdraddf9a162020-01-27 12:56:27 +053023GRPC_VER ?= v1.10.x
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000024
Craig Lutgenf040dba2018-09-27 11:21:43 -050025CXX ?= g++
Girish Gowdra489425a2020-02-22 13:07:42 +053026CPPFLAGS += `pkg-config --cflags protobuf grpc` -I googleapis/gens -I./
Shad Ansari19249582018-04-30 04:31:00 +000027CXXFLAGS += -std=c++11
Shad Ansari563ea822018-06-28 14:56:27 +000028#LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc` -ldl
Girish Gowdra489425a2020-02-22 13:07:42 +053029PROTOC = $(shell which protoc)
Shad Ansari19249582018-04-30 04:31:00 +000030GRPC_CPP_PLUGIN = grpc_cpp_plugin
Girish Gowdra489425a2020-02-22 13:07:42 +053031GRPC_CPP_PLUGIN_PATH ?= $(shell which grpc_cpp_plugin)
Shad Ansari19249582018-04-30 04:31:00 +000032
Burak Gurdag30222452020-04-23 20:00:52 +000033OBJS = voltha_protos/common.pb.o voltha_protos/common.grpc.pb.o voltha_protos/tech_profile.pb.o voltha_protos/tech_profile.grpc.pb.o voltha_protos/openolt.pb.o voltha_protos/openolt.grpc.pb.o ./googleapis/gens/google/api/annotations.grpc.pb.o ./googleapis/gens/google/api/annotations.pb.o ./googleapis/gens/google/api/http.pb.o
Shad Ansari19249582018-04-30 04:31:00 +000034
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000035.DEFAULT_GOAL := all
36
Zack Williams8dbb1752020-04-08 10:37:09 -070037all: googleapis voltha_protos grpc-target protobuf-target libopenoltapi.a
Shad Ansari19249582018-04-30 04:31:00 +000038
39libopenoltapi.a: $(OBJS)
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000040 ar cr $@ $^
Shad Ansari19249582018-04-30 04:31:00 +000041 ranlib $@
42
43googleapis:
44 if [ ! -e "googleapis" ]; then \
nick6fa80732018-05-22 14:47:10 -040045 git clone https://github.com/googleapis/googleapis.git; \
Nicolas Palpacuer59f72ba2018-07-16 15:16:18 -040046 cd googleapis; \
47 git checkout 475d72b7405c92f06d7f2d4aba866278eb5ad8e9; \
48 cd ..; \
Craig Lutgenf040dba2018-09-27 11:21:43 -050049 make -C googleapis LANGUAGE=cpp GRPCPLUGIN=$(GRPC_CPP_PLUGIN_PATH) all; \
Shad Ansari19249582018-04-30 04:31:00 +000050 fi;
51
Zack Williams8dbb1752020-04-08 10:37:09 -070052voltha_protos:
53 mkdir voltha_protos
Burak Gurdag30222452020-04-23 20:00:52 +000054 if [ ! -e "voltha_protos/common.proto" ]; then \
55 wget -O voltha_protos/common.proto https://raw.githubusercontent.com/opencord/voltha-protos/$(OPENOLT_PROTO_VER)/protos/voltha_protos/common.proto; \
56 fi; \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000057 if [ ! -e "voltha_protos/openolt.proto" ]; then \
58 wget -O voltha_protos/openolt.proto https://raw.githubusercontent.com/opencord/voltha-protos/$(OPENOLT_PROTO_VER)/protos/voltha_protos/openolt.proto; \
59 fi; \
Girish Gowdrad0b6b4f2019-11-01 13:01:22 +053060 if [ ! -e "voltha_protos/tech_profile.proto" ]; then \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000061 wget -O voltha_protos/tech_profile.proto https://raw.githubusercontent.com/opencord/voltha-protos/$(OPENOLT_PROTO_VER)/protos/voltha_protos/tech_profile.proto; \
62 fi;
63
Girish Gowdra489425a2020-02-22 13:07:42 +053064grpc-target:
Burak Gurdag30222452020-04-23 20:00:52 +000065 $(PROTOC) --proto_path=. -I./googleapis --grpc_out=. --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN_PATH) voltha_protos/common.proto
Girish Gowdra489425a2020-02-22 13:07:42 +053066 $(PROTOC) --proto_path=. -I./googleapis --grpc_out=. --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN_PATH) voltha_protos/openolt.proto
67 $(PROTOC) --proto_path=. -I./googleapis --grpc_out=. --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN_PATH) voltha_protos/tech_profile.proto
Shad Ansari19249582018-04-30 04:31:00 +000068
Zack Williams8dbb1752020-04-08 10:37:09 -070069protobuf-target: voltha_protos
Burak Gurdag30222452020-04-23 20:00:52 +000070 $(PROTOC) --proto_path=. -I./googleapis -I./ --cpp_out=. voltha_protos/common.proto
Girish Gowdra489425a2020-02-22 13:07:42 +053071 $(PROTOC) --proto_path=. -I./googleapis -I./ --cpp_out=. voltha_protos/openolt.proto
72 $(PROTOC) --proto_path=. -I./googleapis -I./ --cpp_out=. voltha_protos/tech_profile.proto
Shad Ansari19249582018-04-30 04:31:00 +000073
74clean:
Zack Williams8dbb1752020-04-08 10:37:09 -070075 rm -rf *.a voltha_protos
Shad Ansari19249582018-04-30 04:31:00 +000076
77distclean: clean
78 rm -rf googleapis
Girish Gowdra489425a2020-02-22 13:07:42 +053079
80.PHONY = grpc-target protobuf-target