Shad Ansari | 1924958 | 2018-04-30 04:31:00 +0000 | [diff] [blame] | 1 | # 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 | |
| 15 | HOST_SYSTEM = $(shell uname | cut -f 1 -d_) |
| 16 | SYSTEM ?= $(HOST_SYSTEM) |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 17 | |
| 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 Gowdra | 252f497 | 2020-09-07 21:24:01 -0700 | [diff] [blame] | 21 | # openolt.proto, ext_config.proto and tech_profile.proto |
Burak Gurdag | a052359 | 2021-02-24 15:17:47 +0000 | [diff] [blame^] | 22 | OPENOLT_PROTO_VER ?= v4.0.14 |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 23 | |
Craig Lutgen | f040dba | 2018-09-27 11:21:43 -0500 | [diff] [blame] | 24 | CXX ?= g++ |
Girish Gowdra | 489425a | 2020-02-22 13:07:42 +0530 | [diff] [blame] | 25 | CPPFLAGS += `pkg-config --cflags protobuf grpc` -I googleapis/gens -I./ |
Shad Ansari | 1924958 | 2018-04-30 04:31:00 +0000 | [diff] [blame] | 26 | CXXFLAGS += -std=c++11 |
Shad Ansari | 563ea82 | 2018-06-28 14:56:27 +0000 | [diff] [blame] | 27 | #LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc` -ldl |
Girish Gowdra | 489425a | 2020-02-22 13:07:42 +0530 | [diff] [blame] | 28 | PROTOC = $(shell which protoc) |
Shad Ansari | 1924958 | 2018-04-30 04:31:00 +0000 | [diff] [blame] | 29 | GRPC_CPP_PLUGIN = grpc_cpp_plugin |
Girish Gowdra | 489425a | 2020-02-22 13:07:42 +0530 | [diff] [blame] | 30 | GRPC_CPP_PLUGIN_PATH ?= $(shell which grpc_cpp_plugin) |
Shad Ansari | 1924958 | 2018-04-30 04:31:00 +0000 | [diff] [blame] | 31 | |
Girish Gowdra | 252f497 | 2020-09-07 21:24:01 -0700 | [diff] [blame] | 32 | OBJS = 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/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 Ansari | 1924958 | 2018-04-30 04:31:00 +0000 | [diff] [blame] | 33 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 34 | .DEFAULT_GOAL := all |
| 35 | |
Zack Williams | 8dbb175 | 2020-04-08 10:37:09 -0700 | [diff] [blame] | 36 | all: googleapis voltha_protos grpc-target protobuf-target libopenoltapi.a |
Shad Ansari | 1924958 | 2018-04-30 04:31:00 +0000 | [diff] [blame] | 37 | |
| 38 | libopenoltapi.a: $(OBJS) |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 39 | ar cr $@ $^ |
Shad Ansari | 1924958 | 2018-04-30 04:31:00 +0000 | [diff] [blame] | 40 | ranlib $@ |
| 41 | |
| 42 | googleapis: |
| 43 | if [ ! -e "googleapis" ]; then \ |
nick | 6fa8073 | 2018-05-22 14:47:10 -0400 | [diff] [blame] | 44 | git clone https://github.com/googleapis/googleapis.git; \ |
Nicolas Palpacuer | 59f72ba | 2018-07-16 15:16:18 -0400 | [diff] [blame] | 45 | cd googleapis; \ |
| 46 | git checkout 475d72b7405c92f06d7f2d4aba866278eb5ad8e9; \ |
| 47 | cd ..; \ |
Craig Lutgen | f040dba | 2018-09-27 11:21:43 -0500 | [diff] [blame] | 48 | make -C googleapis LANGUAGE=cpp GRPCPLUGIN=$(GRPC_CPP_PLUGIN_PATH) all; \ |
Shad Ansari | 1924958 | 2018-04-30 04:31:00 +0000 | [diff] [blame] | 49 | fi; |
| 50 | |
Zack Williams | 8dbb175 | 2020-04-08 10:37:09 -0700 | [diff] [blame] | 51 | voltha_protos: |
| 52 | mkdir voltha_protos |
Burak Gurdag | 3022245 | 2020-04-23 20:00:52 +0000 | [diff] [blame] | 53 | if [ ! -e "voltha_protos/common.proto" ]; then \ |
| 54 | wget -O voltha_protos/common.proto https://raw.githubusercontent.com/opencord/voltha-protos/$(OPENOLT_PROTO_VER)/protos/voltha_protos/common.proto; \ |
| 55 | fi; \ |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 56 | if [ ! -e "voltha_protos/openolt.proto" ]; then \ |
| 57 | wget -O voltha_protos/openolt.proto https://raw.githubusercontent.com/opencord/voltha-protos/$(OPENOLT_PROTO_VER)/protos/voltha_protos/openolt.proto; \ |
| 58 | fi; \ |
Girish Gowdra | d0b6b4f | 2019-11-01 13:01:22 +0530 | [diff] [blame] | 59 | if [ ! -e "voltha_protos/tech_profile.proto" ]; then \ |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 60 | wget -O voltha_protos/tech_profile.proto https://raw.githubusercontent.com/opencord/voltha-protos/$(OPENOLT_PROTO_VER)/protos/voltha_protos/tech_profile.proto; \ |
kesavand | c1f2db9 | 2020-08-31 15:32:06 +0530 | [diff] [blame] | 61 | fi; \ |
| 62 | if [ ! -e "voltha_protos/ext_config.proto" ]; then \ |
| 63 | wget -O voltha_protos/ext_config.proto https://raw.githubusercontent.com/opencord/voltha-protos/$(OPENOLT_PROTO_VER)/protos/voltha_protos/ext_config.proto; \ |
| 64 | fi; |
| 65 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 66 | |
Girish Gowdra | 489425a | 2020-02-22 13:07:42 +0530 | [diff] [blame] | 67 | grpc-target: |
Burak Gurdag | 3022245 | 2020-04-23 20:00:52 +0000 | [diff] [blame] | 68 | $(PROTOC) --proto_path=. -I./googleapis --grpc_out=. --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN_PATH) voltha_protos/common.proto |
Girish Gowdra | 489425a | 2020-02-22 13:07:42 +0530 | [diff] [blame] | 69 | $(PROTOC) --proto_path=. -I./googleapis --grpc_out=. --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN_PATH) voltha_protos/openolt.proto |
| 70 | $(PROTOC) --proto_path=. -I./googleapis --grpc_out=. --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN_PATH) voltha_protos/tech_profile.proto |
kesavand | c1f2db9 | 2020-08-31 15:32:06 +0530 | [diff] [blame] | 71 | $(PROTOC) --proto_path=. -I./googleapis --grpc_out=. --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN_PATH) voltha_protos/ext_config.proto |
Shad Ansari | 1924958 | 2018-04-30 04:31:00 +0000 | [diff] [blame] | 72 | |
Zack Williams | 8dbb175 | 2020-04-08 10:37:09 -0700 | [diff] [blame] | 73 | protobuf-target: voltha_protos |
Burak Gurdag | 3022245 | 2020-04-23 20:00:52 +0000 | [diff] [blame] | 74 | $(PROTOC) --proto_path=. -I./googleapis -I./ --cpp_out=. voltha_protos/common.proto |
Girish Gowdra | 489425a | 2020-02-22 13:07:42 +0530 | [diff] [blame] | 75 | $(PROTOC) --proto_path=. -I./googleapis -I./ --cpp_out=. voltha_protos/openolt.proto |
| 76 | $(PROTOC) --proto_path=. -I./googleapis -I./ --cpp_out=. voltha_protos/tech_profile.proto |
kesavand | c1f2db9 | 2020-08-31 15:32:06 +0530 | [diff] [blame] | 77 | $(PROTOC) --proto_path=. -I./googleapis -I./ --cpp_out=. voltha_protos/ext_config.proto |
Shad Ansari | 1924958 | 2018-04-30 04:31:00 +0000 | [diff] [blame] | 78 | |
| 79 | clean: |
Zack Williams | 8dbb175 | 2020-04-08 10:37:09 -0700 | [diff] [blame] | 80 | rm -rf *.a voltha_protos |
Shad Ansari | 1924958 | 2018-04-30 04:31:00 +0000 | [diff] [blame] | 81 | |
| 82 | distclean: clean |
| 83 | rm -rf googleapis |
Girish Gowdra | 489425a | 2020-02-22 13:07:42 +0530 | [diff] [blame] | 84 | |
| 85 | .PHONY = grpc-target protobuf-target |