blob: 0fbca86ec6e283e3506f8a66764b357e49020130 [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
Girish Gowdra252f4972020-09-07 21:24:01 -070021# openolt.proto, ext_config.proto and tech_profile.proto
nikesh.krishnan331d38c2023-04-06 03:24:53 +053022OPENOLT_PROTO_VER ?= v5.4.6
Craig Lutgenf040dba2018-09-27 11:21:43 -050023CXX ?= g++
Girish Gowdra489425a2020-02-22 13:07:42 +053024CPPFLAGS += `pkg-config --cflags protobuf grpc` -I googleapis/gens -I./
Shad Ansari19249582018-04-30 04:31:00 +000025CXXFLAGS += -std=c++11
Shad Ansari563ea822018-06-28 14:56:27 +000026#LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc` -ldl
Girish Gowdra489425a2020-02-22 13:07:42 +053027PROTOC = $(shell which protoc)
Shad Ansari19249582018-04-30 04:31:00 +000028GRPC_CPP_PLUGIN = grpc_cpp_plugin
Girish Gowdra489425a2020-02-22 13:07:42 +053029GRPC_CPP_PLUGIN_PATH ?= $(shell which grpc_cpp_plugin)
Shad Ansari19249582018-04-30 04:31:00 +000030
Girish Gowdra5287fde2021-07-31 00:41:45 +000031OBJS = 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/ext_config.pb.o voltha_protos/ext_config.grpc.pb.o voltha_protos/extensions.pb.o voltha_protos/extensions.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 +000032
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000033.DEFAULT_GOAL := all
34
Zack Williams8dbb1752020-04-08 10:37:09 -070035all: googleapis voltha_protos grpc-target protobuf-target libopenoltapi.a
Shad Ansari19249582018-04-30 04:31:00 +000036
37libopenoltapi.a: $(OBJS)
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000038 ar cr $@ $^
Shad Ansari19249582018-04-30 04:31:00 +000039 ranlib $@
40
41googleapis:
42 if [ ! -e "googleapis" ]; then \
nick6fa80732018-05-22 14:47:10 -040043 git clone https://github.com/googleapis/googleapis.git; \
Nicolas Palpacuer59f72ba2018-07-16 15:16:18 -040044 cd googleapis; \
45 git checkout 475d72b7405c92f06d7f2d4aba866278eb5ad8e9; \
46 cd ..; \
Craig Lutgenf040dba2018-09-27 11:21:43 -050047 make -C googleapis LANGUAGE=cpp GRPCPLUGIN=$(GRPC_CPP_PLUGIN_PATH) all; \
Shad Ansari19249582018-04-30 04:31:00 +000048 fi;
49
Zack Williams8dbb1752020-04-08 10:37:09 -070050voltha_protos:
51 mkdir voltha_protos
Burak Gurdag30222452020-04-23 20:00:52 +000052 if [ ! -e "voltha_protos/common.proto" ]; then \
53 wget -O voltha_protos/common.proto https://raw.githubusercontent.com/opencord/voltha-protos/$(OPENOLT_PROTO_VER)/protos/voltha_protos/common.proto; \
54 fi; \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000055 if [ ! -e "voltha_protos/openolt.proto" ]; then \
56 wget -O voltha_protos/openolt.proto https://raw.githubusercontent.com/opencord/voltha-protos/$(OPENOLT_PROTO_VER)/protos/voltha_protos/openolt.proto; \
57 fi; \
Girish Gowdrad0b6b4f2019-11-01 13:01:22 +053058 if [ ! -e "voltha_protos/tech_profile.proto" ]; then \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000059 wget -O voltha_protos/tech_profile.proto https://raw.githubusercontent.com/opencord/voltha-protos/$(OPENOLT_PROTO_VER)/protos/voltha_protos/tech_profile.proto; \
kesavandc1f2db92020-08-31 15:32:06 +053060 fi; \
61 if [ ! -e "voltha_protos/ext_config.proto" ]; then \
62 wget -O voltha_protos/ext_config.proto https://raw.githubusercontent.com/opencord/voltha-protos/$(OPENOLT_PROTO_VER)/protos/voltha_protos/ext_config.proto; \
63 fi;
Girish Gowdra5287fde2021-07-31 00:41:45 +000064 if [ ! -e "voltha_protos/extensions.proto" ]; then \
65 wget -O voltha_protos/extensions.proto https://raw.githubusercontent.com/opencord/voltha-protos/$(OPENOLT_PROTO_VER)/protos/voltha_protos/extensions.proto; \
66 fi;
kesavandc1f2db92020-08-31 15:32:06 +053067
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000068
Girish Gowdra489425a2020-02-22 13:07:42 +053069grpc-target:
Burak Gurdag30222452020-04-23 20:00:52 +000070 $(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 +053071 $(PROTOC) --proto_path=. -I./googleapis --grpc_out=. --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN_PATH) voltha_protos/openolt.proto
72 $(PROTOC) --proto_path=. -I./googleapis --grpc_out=. --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN_PATH) voltha_protos/tech_profile.proto
kesavandc1f2db92020-08-31 15:32:06 +053073 $(PROTOC) --proto_path=. -I./googleapis --grpc_out=. --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN_PATH) voltha_protos/ext_config.proto
Girish Gowdra5287fde2021-07-31 00:41:45 +000074 $(PROTOC) --proto_path=. -I./googleapis --grpc_out=. --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN_PATH) voltha_protos/extensions.proto
Shad Ansari19249582018-04-30 04:31:00 +000075
Zack Williams8dbb1752020-04-08 10:37:09 -070076protobuf-target: voltha_protos
Burak Gurdag30222452020-04-23 20:00:52 +000077 $(PROTOC) --proto_path=. -I./googleapis -I./ --cpp_out=. voltha_protos/common.proto
Girish Gowdra489425a2020-02-22 13:07:42 +053078 $(PROTOC) --proto_path=. -I./googleapis -I./ --cpp_out=. voltha_protos/openolt.proto
79 $(PROTOC) --proto_path=. -I./googleapis -I./ --cpp_out=. voltha_protos/tech_profile.proto
kesavandc1f2db92020-08-31 15:32:06 +053080 $(PROTOC) --proto_path=. -I./googleapis -I./ --cpp_out=. voltha_protos/ext_config.proto
Girish Gowdra5287fde2021-07-31 00:41:45 +000081 $(PROTOC) --proto_path=. -I./googleapis -I./ --cpp_out=. voltha_protos/extensions.proto
Shad Ansari19249582018-04-30 04:31:00 +000082
83clean:
Zack Williams8dbb1752020-04-08 10:37:09 -070084 rm -rf *.a voltha_protos
Shad Ansari19249582018-04-30 04:31:00 +000085
86distclean: clean
87 rm -rf googleapis
Girish Gowdra489425a2020-02-22 13:07:42 +053088
89.PHONY = grpc-target protobuf-target