blob: b117a09d0c9b5d63c1937076bf1c00a3a1e6de9a [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
Jason Huang09b73ea2020-01-08 17:52:05 +080022OPENOLT_PROTO_VER ?= v3.1.0
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++
26#powerpc64-fsl-linux-g++
Girish Gowdraddf9a162020-01-27 12:56:27 +053027CPPFLAGS += `PKG_CONFIG_PATH=$(HOME)/openolt-agent-test-lib/grpc/$(GRPC_VER)/lib/pkgconfig pkg-config --cflags protobuf grpc` -I googleapis/gens -I./
Shad Ansari19249582018-04-30 04:31:00 +000028CXXFLAGS += -std=c++11
Shad Ansari563ea822018-06-28 14:56:27 +000029#LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc` -ldl
Girish Gowdraddf9a162020-01-27 12:56:27 +053030PROTOC = $(HOME)/openolt-agent-test-lib/grpc/$(GRPC_VER)/bin/protoc
Shad Ansari19249582018-04-30 04:31:00 +000031GRPC_CPP_PLUGIN = grpc_cpp_plugin
Girish Gowdraddf9a162020-01-27 12:56:27 +053032GRPC_CPP_PLUGIN_PATH ?= $(HOME)/openolt-agent-test-lib/grpc/$(GRPC_VER)/bin/$(GRPC_CPP_PLUGIN)
Shad Ansari19249582018-04-30 04:31:00 +000033
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000034OBJS = 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 +000035
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000036.DEFAULT_GOAL := all
37
38all: googleapis get_openolt_proto libopenoltapi.a
Shad Ansari19249582018-04-30 04:31:00 +000039
40libopenoltapi.a: $(OBJS)
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000041 ar cr $@ $^
Shad Ansari19249582018-04-30 04:31:00 +000042 ranlib $@
43
44googleapis:
45 if [ ! -e "googleapis" ]; then \
nick6fa80732018-05-22 14:47:10 -040046 git clone https://github.com/googleapis/googleapis.git; \
Nicolas Palpacuer59f72ba2018-07-16 15:16:18 -040047 cd googleapis; \
48 git checkout 475d72b7405c92f06d7f2d4aba866278eb5ad8e9; \
49 cd ..; \
Craig Lutgenf040dba2018-09-27 11:21:43 -050050 make -C googleapis LANGUAGE=cpp GRPCPLUGIN=$(GRPC_CPP_PLUGIN_PATH) all; \
Shad Ansari19249582018-04-30 04:31:00 +000051 fi;
52
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000053get_openolt_proto:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000054 if [ ! -e "voltha_protos/openolt.proto" ]; then \
55 wget -O voltha_protos/openolt.proto https://raw.githubusercontent.com/opencord/voltha-protos/$(OPENOLT_PROTO_VER)/protos/voltha_protos/openolt.proto; \
56 fi; \
Girish Gowdrad0b6b4f2019-11-01 13:01:22 +053057 if [ ! -e "voltha_protos/tech_profile.proto" ]; then \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000058 wget -O voltha_protos/tech_profile.proto https://raw.githubusercontent.com/opencord/voltha-protos/$(OPENOLT_PROTO_VER)/protos/voltha_protos/tech_profile.proto; \
59 fi;
60
61.PRECIOUS: voltha_protos/%.grpc.pb.cc
62voltha_protos/%.grpc.pb.cc: voltha_protos/%.proto
Shad Ansari19249582018-04-30 04:31:00 +000063 $(PROTOC) --proto_path=. -I./googleapis --grpc_out=. --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN_PATH) $<
64
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000065.PRECIOUS: voltha_protos/%.pb.cc
66voltha_protos/%.pb.cc: voltha_protos/%.proto
67 $(PROTOC) --proto_path=. -I./googleapis -I./ --cpp_out=. $<
Shad Ansari19249582018-04-30 04:31:00 +000068
69clean:
Girish Gowdrad0b6b4f2019-11-01 13:01:22 +053070 rm -f *.a && cd voltha_protos/ && rm -f *.o *.pb.cc *.pb.h
Shad Ansari19249582018-04-30 04:31:00 +000071
72distclean: clean
73 rm -rf googleapis