blob: 95629a8a18f314f717d0f4922fd9923922e4e546 [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)
17CXX = g++
18CPPFLAGS += `pkg-config --cflags protobuf grpc` -I googleapis/gens
19CXXFLAGS += -std=c++11
Shad Ansari2cddc552018-06-26 20:34:27 +000020#ifeq ($(SYSTEM),Darwin)
21#LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc`\
22# -lgrpc++_reflection\
23# -ldl
24#else
25#LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc`\
26# -Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed\
27# -ldl
28#endif
29LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc` -ldl
Shad Ansari19249582018-04-30 04:31:00 +000030PROTOC = protoc
31GRPC_CPP_PLUGIN = grpc_cpp_plugin
32GRPC_CPP_PLUGIN_PATH ?= `which $(GRPC_CPP_PLUGIN)`
33
34OBJS = openolt.pb.o 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
35
36all: googleapis libopenoltapi.a
37
38libopenoltapi.a: $(OBJS)
39 ar ru $@ $^
40 ranlib $@
41
42googleapis:
43 if [ ! -e "googleapis" ]; then \
nick6fa80732018-05-22 14:47:10 -040044 git clone https://github.com/googleapis/googleapis.git; \
Shad Ansari19249582018-04-30 04:31:00 +000045 make -C googleapis LANGUAGE=cpp all; \
46 fi;
47
48.PRECIOUS: %.grpc.pb.cc
49%.grpc.pb.cc: %.proto
50 $(PROTOC) --proto_path=. -I./googleapis --grpc_out=. --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN_PATH) $<
51
52.PRECIOUS: %.pb.cc
53%.pb.cc: %.proto
54 $(PROTOC) --proto_path=. -I./googleapis --cpp_out=. $<
55
56clean:
57 rm -f *.o *.pb.cc *.pb.h *.a
58
59distclean: clean
60 rm -rf googleapis